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

Bug: unable to add more than one file to FileCollection constructor #6290

Closed
AnakinA1 opened this issue Jul 23, 2022 · 5 comments · Fixed by #6291
Closed

Bug: unable to add more than one file to FileCollection constructor #6290

AnakinA1 opened this issue Jul 23, 2022 · 5 comments · Fixed by #6291
Assignees
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@AnakinA1
Copy link

PHP Version

7.3, 7.4, 8.0, 8.1

CodeIgniter4 Version

4.2.1

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

macOS, Linux

Which server did you use?

fpm-fcgi

Database

MariaDB 10.8

What happened?

When I'm trying to create FileCollection object from 2 or more files paths (not directories), passed in the __constructor, only first file is added. Because in FileCollection->add() method uses return $this->addFile($path); instead of $this->addFile($path); that ends the execution of the foreach loop

Steps to Reproduce

$object = new FileCollection(['/path/to/file', '/path/to/other-file']);

Expected Output

An object containing all passed files

Anything else?

No response

@AnakinA1 AnakinA1 added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 23, 2022
@datamweb
Copy link
Contributor

Hi @AnakinA1 ,
Do you get what you need with the following code?

use CodeIgniter\Files\FileCollection;

$files = new FileCollection();

$file= APPPATH . 'Config/Auth.php';
$otherFile = APPPATH . 'Config/AuthGroups.php';

dd($files->addFiles([$file,$otherFile]));

@AnakinA1
Copy link
Author

Hi, yes, but question is that inside docs mentioned that FileCollection allows to work with groups of files and by logic __constructor should provide an opportunity to add as many files/dirs as you want. And the current behavior is blocking the ability to add more than 1 file via the constructor, for no real reason

@kenjis
Copy link
Member

kenjis commented Jul 23, 2022

I've confirmed this bug.
I sent a PR to fix it. See #6291

@AnakinA1
Copy link
Author

Great, thank you!

@kenjis
Copy link
Member

kenjis commented Jul 23, 2022

This bug has only been sent a PR and has not yet been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants