-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
get_files() grabs files with 'extension' anywhere in the name #202
Comments
if you rename : _test.php the plugin is not loaded, a plugin is loaded only when the class name and the file name are the same. in your case it's always false. |
Another use case (with a vanilla download of Pico): Create /content/new.md and put some content in it. Check on the site, and sure enough, there'll be a title in the navigation with a link to /new. Now go and rename it to new.md.disabled. Check the site again, the link will still be there, but to /new.disabled, which will 404 if you click it. Next, apply my little adjustment and try this again - now the file is (correctly) ignored and not present in the navigation. As for plugin PHPs - I can't get your suggestion to work. If I create test.php and put some junk in it so that it crashes out the request if it's included. If I name it test.php, _test.php, _test.php.disabled, ilike.phpprogramming or pretty much anything else it's still loaded. Or... am I doing something crazy? |
No you're not going crazy ;-) the only difference is that you test if
replacing the strstr() by a preg_match() is using more memory and time, this function is used frequently in pico, i'm not shure it's really useful. |
It's starting to sound like we agree on the problem...? I don't think it should be necessary to remove the 'extension' from the middle of a filename to have it ignored though. Some text editors just add a ".bak" or similar to the end of the filename when they save out drafts, and those shouldn't be included in file scans. I'm happy to differ about the implementation of a fix though (my change was quick, rather than high quality). Using
Alternatively, I guess you could also do something like:
Some looking around suggests that actually, the solution should be more like this (not tested it yet though):
It would take some benchmarking to figure out which is the quickest and lowest memory, but I'd suggest the |
Yes, ;-) Adding unit testing to Pico, could certainly be a great addition for discussing about benchmark and optimisation. The path_info is certainly better, you're right. i'm just wondering if adding the Symphony Finder component to do all the file system task, could not be a better solution, even to be used by our plugins. |
I just had a look at Symfony Finder - it looks pretty nice. Whether to use it or not, and indeed to implement some unit/performance testing looks more like a feature request rather than this little bug report though (as much as I agree with both sentiments). When I get a chance I'll produce a PR for this specific issue, although I understand that it'll probably sit in the pull queue for quite a long time :-( |
Fixed with #252 |
I renamed a PHP file in an extension I'm working on from test.php to test.php.disabled (thinking that it would stop it from being loaded). It turns out that the get_files() method in Pico still finds the file.
In the code, I found this (line 335):
...I think it should be more like this:
In the latter case, it finds the .php files, but not the .php.disabled files. What's the consensus on this? Shall I produce a patch/pull request?
The text was updated successfully, but these errors were encountered: