Closed samyouel closed 2 months ago
Uri::current()
parse_url
fails as it cannot handle the parameter notation in the URL https://github.com/getkirby/kirby/blob/main/src/Http/Uri.php#L91$props
always is an array, while now it is false
Pinging @bastianallgeier @lukasbestle for ideas as you have a better insight on the Http classes, I think.
Am I correct that this only happens if Kirby's url
option was configured without a host (e.g. as 'url' => '/'
)?
But the underlying bug seems to be in Uri::current()
or actually in the Uri
constructor. Maybe we could solve it there by adding a fake host for non-absolute URLs and removing the injected data from the array that parse_url()
returns again. We do a similar thing in the Environment
class:
Those lines form the Environment class sound like exactly what's needed here as well.
This sounds kinda familiar. Not sure if it’s really helpful here, but I fixed a similar issue in the library that I use for my HTML minification plugin a while ago. See https://github.com/hexydec/htmldoc/pull/8
Am I correct that this only happens if Kirby's url option was configured without a host (e.g. as 'url' => '/')?
Exactly. As noted on php.net regarding parse_url()
:
This function may not give correct results for relative or invalid URLs [...]
and
This function is intended specifically for the purpose of parsing URLs and not URIs.
Description
I've been following the cookbook to setup 'Load More' Functionality with Kirby Pagination.
The model named 'Rewards' is using virtual pages, to fetch the children of the model from an API.
I'm using page cache to cache the content of the page. During the
function children()
, when I call the children of the model over API, I clear the page cache by usingkirby()->cache('pages')->remove('rewards.html')
in certain conditions.This accessing the page cache is not working once I click the 'Load More' Button, that calls the paginated children from the
rewards.json.php
.Expected behavior
The 'Load More' Button should fetch the children in the same way and display them, as an initial page load should be able to as well.
Actual behaviour
When I use the AJAX 'Load More' Button as outlined in the cookbook, the request fails upon the moment of accessing the page cache.
I've traced it down to
kirby/src/Http/Uri.php:91
, during accessing the page cache, it tries to build a URI, but somehow theparse_url()
function from php can't build a url from the pagination url"/rewards.json/page:2"
that is being sent with the call. I guess because of the colon:
.Stack trace
To reproduce
parse_url('/rewards.json/page:2')
that is used in the mentioned file-> Is there something wrong with this URI Constructor?
Your setup
Kirby Version
getkirby/cms (4.1.1) composer install