Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\File::files() do not return files in correct sorting anymore, it is working fine in laravel version 5.4 #23883

Closed
ajcastro opened this issue Apr 15, 2018 · 5 comments

Comments

@ajcastro
Copy link

  • Laravel Version: 5.5.*
  • PHP Version: 7.0
  • Database Driver & Version: any

Description:

I have a menu files seeder and each file is a menu.
Before when I am using laravel 5.4, $menuFiles = \File::files(base_path('database/seeds/menus/')') return files in correct order but now in 5.5, it is not sorted properly. the files are:

01_dashboard.php
02_branches.php
02_users.php
03_items.php
04_credit_plan_groups.php
04_customers.php
05_suppliers.php
06_transactions.php
08_account_ledgers.php
08_collections.php
08_remittances.php
09_check_stocks.php
09_inventory_report.php
09_inventory_summary.php
10_reorder_items_report.php
10_sales_report.php
11_serial_tracking.php
99_sys_config.php

Currently the workaround I did to fix this is:

$menuFiles = collect(File::files(__dir__.'/menus'))->sortBy(function ($file) {
            return $file->getBasename();
        })->all();

Steps To Reproduce:

@staudenmeir
Copy link
Contributor

This has been fixed in 5.6, but not yet in 5.5. I'll create a Pull Request.

@ajcastro
Copy link
Author

Cool thanks!

@staudenmeir
Copy link
Contributor

The backport to 5.5 was declined. You'll have to use the workaround until you upgrade to 5.6.

@ajcastro
Copy link
Author

ajcastro commented Apr 16, 2018

Why?

I think they should accept the PR... because some devs will not upgrade to 5.6 immediately.

@devcircus
Copy link
Contributor

Because 5.5 is in bug-fix only, it's not a bug, and it's simple to do in your own project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants