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
getByPath multilanguage prefers name over language path #1550
Comments
Cross-linking to #1116 because I think it's related. |
Oh yes It's very similar. I only ran into this with multilanguage paths. I just tested the |
@timohausmann I can't seem to duplicate it here. Let me know if you can spot something I'm missing. I tested on 2 different multi-language installations, one large multi-language site, and one local default "test-languages" profile install. My homepage has 3 active languages, depending on the profile I'm testing, but I'll use the first as an example which has, "/" (default), "/de/" and "/es/", using the core LanguageSupportPageNames. I created a page named /test/ and have all languages checked "active" on the Setup tab. For the "de" language name, I entered "profile" (so that its URL would be /de/profile/). I created a /test.php file with this:
I viewed domain.com/test.php in my browser and this is the result I get:
I also tried using some other page names that already exist (replacing the "profile" part), but still getting the same result. Is it possible you don't have the "active" checkbox checked for the "fr" language of your /test/ page? |
That's weird, I followed your steps on a fresh docker but cannot reproduce your result.
The part about products in the first post was not accurate, I tested more and with these pages, getByPath('/test', ...) also gives me a Nullpage.
|
I tested this again on a fresh windows+xampp install and Multi-Language profile (my other sites were blank) - same issue. Here is a screen record of the setup. Changed de/uber to de/profile, pasted your snippet in a test.php, getByPath returns a NullPage for /de/profile. |
@timohausmann I work off the dev branch for GitHub issues, since it is the most up-to-date, and I just read your first message again and see you mentioned PW 3.0.184. The entire path-to-page system has been rewritten since that version. While getByPath() is a method independent of that system, I'm guessing the core version must be the difference. |
Oh, I can confirm it works with 3.0.197. Thanks, I should make a habbit out of using the dev branch. |
@timohausmann Actually, I started being able to duplicate this one today, after various combinations with the "profile" page name from the root of the web site in a multi-language environment, and 3+ pages having the name "profile", I would sometimes get the /processwire/profile/ page rather than the intended one. I've pushed an update in an attempt to fix this. This might be related to one that @Toutouwai found before and I previously had trouble duplicating. |
@timohausmann, can you please check if Ryan's fix works for you? |
I tested again on current dev branch and cannot reproduce the issue. |
Short description of the issue
Hey, I found using getByPath on a multilanguage site returns the wrong page if the last requested "url segment" of language path overlaps with an existing name.
Expected behavior
Get page purely based on the path, /de/produkte/ returning Products.
Actual behavior
getByPath('/de/produkte', ...)
will return the second page, because the last segment – the name – matches:Querying for this also works: /xxyyz-non-existing-path/produkte
Optional: Screenshots/Links that demonstrate the issue
I discovered this when client renamed the /bio page for ONE language to /en/profile and I got a 404 (it found the /processwire/profile page).
Steps to reproduce the issue
$pages->getByPath('/fr/profile', ['useLanguages'=>true]);
wont return the test pageSetup/Environment
The text was updated successfully, but these errors were encountered: