-
Notifications
You must be signed in to change notification settings - Fork 616
404 and around #708
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
Comments
This comment was marked as outdated.
This comment was marked as outdated.
I'm afraid there isn't. There were plans for Pico 4.0 to fix that (by adding "virtual pages"), but that never materialized. Since your plugin is taking control anyway, you don't really have to care about
No, |
Ok, thanks. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍 |
@PhrozenByte I'm currently investigating this issue. At the moment, I can hook into Alternatively, I can hook into I believe it's possible (without breaking anything) to modify Is this the right approach, or would a major refactoring of the Pico system be necessary? |
@digitalinferno, you should do both, i.e. hook into both Optionally you can also hook into It's without any doubt extremely cumbersome and more feels like a workaround than a proper solution, but it's actually how it was intended with Pico 3.0 and earlier. This unnecessary complexity and "hackiness" was the main reason why I wanted to change that with Pico 4.0. |
Yes, it's a bit cumbersome, so I'm also looking into possible small core-level changes. Currently, Pico follows this flow:
I assume this order is primarily for performance reasons, so Pico can serve the current page as quickly as possible. My idea is to introduce a new event (like
Out of curiosity, which data flow would be ideally better from a design standpoint?
|
I'd love to say that this is the case, but in reality it's just historic reasons: In Gilbert's first versions of Pico there wasn't even a pages array. It was added later and since then we just never changed the processing order. In a complete rewrite of Pico I'd probably just switch the order, i.e. discover pages first and then decide what to render. However, this will likely break compatibility with many plugins (not sure whether there's even a way to implement this in a BC way). If I'd want to improve support for virtual pages without breaking too many things, I'd probably just add a parameter to Caching is a whole different story. Caching has some advantages, but also disadvantages, like the necessity to detect an outdated cache - for both the requested page, and any other page (think about the site's nav menu). See #317 for some of my ideas for caching in Pico 4.0. |
Thanks for the hints. Discovering all pages first does make sense architecturally, but isn’t it a heavy task to perform at the very beginning of each request? Or would this kind of rewrite go hand in hand with some form of caching? |
I don't think it really make any difference in which order we execute the tasks ("page discovery" and "page parsing") if the tasks itself don't change. I might totally miss something here (I'm afraid I haven't worked on Pico for ages…), but as far as I can reconstruct things in my mind right now the logic within the task doesn't really change (I don't mean "just call However, I once again want to stress that this will likely fundamentally break many plugins and I'm not sure whether it's even possible to preserve BC with this. It's the better approach architecturally though, I'm just not sure whether it's still Pico then or more like a fork. IMHO such radical change should come with other major improvements (like the things outlined in #317), but that's really no longer up to me to decide, but anyone (or group of people) who wants to take over Pico's development. |
I understand the decision is no longer in your hands, but I’d still value your perspective on this. For fun, I started by moving 404 handling into a plugin instead of keeping it hardcoded in the core. Now, I’m experimenting to see how far I can push things based on #317 without breaking things. Restructuring the flow and potentially rebuilding the pages array with OOP is the next step... if it stays fun and I can learn along the way. :) |
If I create a plugin that serves a page when I request
site/fakepage
, for example usingonPageRendering
with$twigTemplate = 'fakepage.twig'
, Pico still considers this as 404 content. On the user side, everything works fine, butis404Content()
returns true (similarly,on404ContentLoaded(&$rawContent)
is also triggered). Is there a way to work around this? For instance, if I want to log all the requests that result in a 404, calls tosite/fakepage
would also be logged as 404s, but they shouldn't be.Another question about 404 behavior: If I create a
404.md
page and point tomysite/404
, Pico serves the 404 page, but with a200 OK
response, because the page actually exists. Is it an expected behavior? A better practice would be to only allow a_404.md
file, which is not accessible directly but is used by Pico to serve a 404 message when there is a bad request. This approach, like before, avoids false positives when plugins check foris404Content()
.The text was updated successfully, but these errors were encountered: