-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Improve directory tree read performance #30629
Conversation
Hi @Nazar65. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
This is good news! |
@magento run all tests |
@magento run all tests |
private function recursiveRead(string $pattern, int $flags = 0): array | ||
{ | ||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
$directories = glob($pattern, $flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the \Magento\Framework\Filesystem\DriverInterface::search method be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@le0n4ik this would be great, but main idea is the flag to read directories only, and search method have no ability to set this flag, and it will search only for one level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but thanks, we can use Magento\Framework\Filesystem\Glob as well
$directories = glob($pattern, $flags); | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
foreach (glob($this->driver->getParentDirectory($pattern) . '/*', $flags) as $dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment
@magento run all tests |
@magento run all tests |
@thomas-kl1 So I spent many many hours testing things this weekend and trying every possible combination of fixes. What I finally determined was the problem for me was having both my static files and media files on 2 different AWS Cloudfront Distributions. Here is what I determined this weekend:
4.#30629 DOES work fine with large amounts of images (in my case over 2 million images) when the Static URL is change back to local server. I WAS able to use the media Cloudfront distribution though. So, something about Magento files does not like the static files being served from a Cloudfront Distribution. Bottom line, with #30629 pull, Static URL pointed to local and media URL pointed to Cloudfront server, everything worked perfect. The search bar shows, clicking on folders adds them as the active filters that you can X out and close. Search terms work fine. Adobe Stock Images works perfectly and I can add previews and images with no problems. Basically, I can say everything works perfectly as expected with #30629 and just changing Static URL to the local server.
So, I hope this is helpful to those working on these files. I would love to have a fix to be able to use my Static file CDN on AWS. I am not sure what the issue is, I can only report what is happening. Thanks |
Anyone else having problems with this - excluding directories from the media gallery can help a lot; https://devdocs.magento.com/guides/v2.4/ext-best-practices/tutorials/modify-image-library-permissions/ We had to exclude everything except for |
@jayshields: so this is more or less the same problem as #22609, where for some reason they wanted all directories under |
Yes - for me this is related to that issue. 2.4 opened the media gallery up to We created a module with a
|
@jayshields when you say you made a module, what does that exactly mean? What does the module do and what files are in this module besides the di.xml file? Seems crazy we need to do this and that the Magento team still hasn't fixed this issue after almost a year! Why they wont make the wysiwyg as the root directory is beyond me. Seems like someone made a huge mistake allowing the catalog images to basically cripple the Media Gallery or pretty much make it unusable. What's it going to take for them to correct this bad judgement?? |
@perfpcs at least they should've done an "include directory" list instead of an "exclude" one.. |
@thomas-kl1 Yes Sir. Seems they don't even read half these posts to fix these critical errors. :( |
@thomas-kl1 @perfpcs I think it was bcs, the wisywig folder means this for wisywig package, and media folder means that there should be files for media right ? so it sounds logical why they have the media folder for the media gallery, but i think the core issue here is that directory tree component render's you full tree at one request, which i think is wrong, bcs we should render the first level of directory, and then the others only when user click's on parent, that how it was done on the olds media gallery, So with that implementation we will not have any performance issue. But anyway this is a new media gallery with new approach so it completely different from what we had before |
By module I mean a directory in |
@jayshields thank you |
It seems that, bot moved the PR into Review in Progress automatically, so moving back to Changes Requested. Thank You! |
closing in favor -> #35404 |
Description (*)
Scan only directories for directory tree component
The result of using glob instead of iterator with more than 500000 files in media folder
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)