I am starting to test out Fast 404 on a multilingual site that uses path prefixes. Our multilingual sites are www.domain.com/en-gb, www.domain.com/fr-fr, etc.
Fast 404 is working for me as expected in my initial tests. However, anytime I try to navigate to a different language with a path prefix, Fast 404 interprets that path as not found. Is there some way I should be adding these language path prefixes to my whitelist in settings.php or is there a different problem?
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | fix-missing-class-2820923-51.patch | 768 bytes | timmy_cos |
| #46 | D10_8x3x-2820923-46.patch | 7.62 KB | joseph.olstad |
| #40 | 2820923-40.patch | 7.79 KB | juanolalla |
Comments
Comment #2
paulmckibbenThe problem specifically occurs when (1) language negotiation is enabled and is configured to use a URL path prefix, and (2) Fast404 path checking is enabled in settings.php.
The attached patch addresses the issue by checking whether URL path prefix language negotiation is enabled, and whether the first component of the path matches a configured path prefix.
Comment #4
paulmckibbenThe patch in #2 fails for translated URLs.
Comment #5
paulmckibbenThis patch adds a check for configured URL aliases. This allows matching of translated paths.
Comment #7
paulmckibbenI don't think this module is set up for automated testing. Putting this back in "needs review" status.
Comment #8
paulmckibbenI found a new issue where a trailing slash after the path prefix (and nothing else) gets blocked by fast404 path checking. It should not be blocked.
Submitting new patch and interdiff.
Comment #10
paulmckibbenPutting back in needs review: I don't think automated tests are working for this project.
Comment #11
jasonawantI can confirm that when using the option
$settings['fast404_path_check'] = TRUE;, language prefix paths return the fast_404 404 message without this patch. With the patch, the language prefix path renders as expected. Thanks Paul!Comment #12
jasonawantAfter reviewing a related issue #2743965: Fast 404 results in 404s on valid routes when using fast404_path_check, I think this patch needs a re-roll because it combines logic for language path prefixing as well as url aliases as seen in this bit below.
Here's a a new patch with the additional logic for path aliases removed. See this issue for path aliases, https://www.drupal.org/project/fast_404/issues/2743965
Comment #13
gg4 commentedQuickly noticing that Drupal static is being used here a class context when dependency injection should be used instead.
Comment #14
gg4 commentedComment #15
robpowellHere is my attempt at DI the configfactory. I have both an alpha3 and dev version.
Comment #16
gg4 commentedComment #17
robpowellAlright, need alpha3 patch to test our code on hosted env. Will post summary of changes and dev patch shortly.
Comment #18
gg4 commentedThanks @robpowell - looking forward to reviewing the dev patch.
Comment #19
robpowellclean up setter method and put translation check back in Fast404::checkPath().
Comment #20
robpowellComment #21
robpowellAlright, here we go, this works for us on alpha3. High level refactor points: it wasn't a matter of just adding DI. What we determined was Fast404 was coupled too closely to Fast404EventSubscriber. This means, that for any dependency to be injected it would have come from Fast404EventSubscriber and that is not maintainable. Instead, we implemented a factory, Fast404Factory/Fast404FactoryInterface that handles the instantiation of the Fast404 obj. Moving forward, if any code needs to create Fast404 object, it needs to include the Fast404Factory as a dependencies and call $this->fast404Factory->createInstance(). The createInstance() method is the centralize place to create Fast404 objects. Because we know that, we can make the Fast404 class unaware of the confg factory and load the language_negotiation conditionally saving the processing for only when translations are set.
Comment #22
robpowellHere is the dev patch.
Comment #23
robpowellComment #27
gg4 commentedThanks, @robpowell. Attached is a quick code style cleanup for your dev patch.
Comment #28
ismail08 commentedI included the following patch in composer.json file and when I run "composer update drupal/fast_404" I am getting the below Error. Infact I even tried with the other versions of patch listed right at the top but I still get the same error. Please let me know how to apply this patch?
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2018-07-05/fast_404_2820923_24_dev.p...
Comment #29
robpowell@ismail08 I have the following in my composer.json
Composer update should show a .reject somewhere in the module directory. This will tell you why the patch couldn't apply. It is my experience that this is when the version of the patch is out of sync of the local version of the dependency. My suspicion is that you are not on the 8.x-1.x branch of the module.
Comment #30
robpowell@bonus I was able to test dev with you updated changes. To get the site updated, I ran
composer require "drupal/fast_404:1.x-dev" --update-with-dependenciesand update my composer.json as follows:I tested that fr-fr/ brought up a translated page. I also confirm that fr-fr/foo-bar brought up a quick 404. I think before this moves forward, it should get some tests and that is dependent on #2715585. I will put this is needs work and add the tag needs tests.
Comment #31
robpowellComment #32
robpowellComment #33
jasonawantI've re-rolled latest patch against a version that includes patch from #2838359: Fast404 path checking is incompatible with Redirect module. I uploaded here, so I can test with project build.
Comment #34
jasonawantAnother try, did not include new files in my diff patch...also incorrect yaml indentation.
Comment #35
jasonawantIn the latest patches (including that from #27) Fast404Factory:: createInstance() it instantiates a new fast404 object with
$fast404 = new Fast404($this->requestStack->getCurrentRequest());.The patch from #2838359: Fast404 path checking is incompatible with Redirect module, adds $module_handler to the Fast404 constructor, so that it can check if redirect module is enabled or not. This next patch adds $module_handler to the Fast404Factory constructor so it can instantiate Fast404 with it.
Here's another patch.
Comment #36
gg4 commentedComment #37
bbombachiniI had to clean up a bit so it's not exactly a reroll but should apply on 8.x-2.x-dev and it's working for me.
PS: Missing tests.
Comment #38
bbombachiniComment #39
juanolalla commentedI've re-rolled #27, which was the last working patch.
Comment #40
juanolalla commentedFixed unit test failure from #39 with new construct() parameters.
Comment #41
joseph.olstadPatch 40 works great! Thanks @juanolalla and everyone else above, especially @robpowell, @jasonawant @gg4 and @paulmckibbon
Comment #42
juanolalla commentedComment #43
joseph.olstadComment #44
joseph.olstadComment #46
joseph.olstadComment #48
joseph.olstadComment #49
joseph.olstadhttps://www.drupal.org/project/fast_404/releases/8.x-3.0-alpha1
Comment #51
timmy_cos commentedHey there,
The changes to fix this issue seem to have introduced a class not found error on https://git.drupalcode.org/project/fast_404/-/blob/8.x-3.x/src/EventSubs... (due to the removal of Fast404).
The bug has made its way into v3.0. I've attached a patch that works for me, not sure if this needs to be a new issue.
Comment #52
kristen pol@Timmy_Cos Fyi, best to create a new issue, especially for fatal errors. Once an issue is closed/fixed, people often aren't looking at them.
New issue was opened here and fix was just merged:
#3374546: Fatal error : Class Fast404 not found