ale.pixel Posted June 4 Share Posted June 4 Hello everyone! After some troubles I have managed to update my shop from 1.7.6.4 to 1.7.8.11 and then to 8.2.1. Everything seems to have gone pretty well, except for an annoying issue: I get a frontend error and it seems to be cause by the second installed language, which I already had before the upgrade. The only way to make the frontend work is to disable it. I have already tried to update the languages through the backoffice as well as deleting and reinstalling it from scratch but it's not working. Main language: IT Second language: EN Of course I have already googled this but I wasn't able to find anything useful. Did anyone have the same problem? Someone knows how to fix it? Thanks in advance 🙂 This is the error I get: Fatal error: Uncaught TypeError: FrontControllerCore::sanitizeUrl(): Argument #1 ($url) must be of type string, null given, called in /home/my-username/public_html/classes/controller/FrontController.php on line 2181 and defined in /home/my-username/public_html/classes/controller/FrontController.php:2194 Stack trace: #0 /home/my-username/public_html/classes/controller/FrontController.php(2181): FrontControllerCore->sanitizeUrl(NULL) #1 /home/my-username/public_html/classes/controller/FrontController.php(1620): FrontControllerCore->getAlternativeLangsUrl() #2 /home/my-username/public_html/classes/controller/FrontController.php(1753): FrontControllerCore->getTemplateVarUrls() #3 /home/my-username/public_html/classes/controller/FrontController.php(563): FrontControllerCore->getTemplateVarShop() #4 /home/my-username/public_html/classes/controller/FrontController.php(625): FrontControllerCore->assignGeneralPurposeVariables() #5 /home/my-username/public_html/controllers/front/IndexController.php(38): FrontControllerCore->initContent() #6 /home/my-username/public_html/classes/controller/Controller.php(319): IndexControllerCore->initContent() #7 /home/my-username/public_html/classes/Dispatcher.php(510): ControllerCore->run() #8 /home/my-username/public_html/index.php(28): DispatcherCore->dispatch() #9 {main} thrown in /home/my-username/public_html/classes/controller/FrontController.php on line 2194 Link to comment Share on other sites More sharing options...
El Patron Posted June 4 Share Posted June 4 1. Verify the second language is installed and active • Go to International → Localization → Languages. • Confirm your second language (e.g., English) appears in the list, is enabled, and has the correct ISO code (e.g., en). • If it’s missing or disabled, click “Add new language” (or re-open the existing entry) and make sure “Active” is toggled ON. 2. Regenerate Friendly URLs and the .htaccess file • Go to Shop Parameters → Traffic & SEO. • Under “Set shop URL”, check that Shop domain, SSL domain, and Base URI are filled in correctly for both languages (same domain if you use /it/ and /en/, or separate subdomains if you use it.example.com and en.example.com). • Scroll down to “Friendly URL”: Disable Friendly URLs and click Save. Re-enable Friendly URLs and click Save again. • Clear the cache: delete everything under /var/cache/prod/ and /var/cache/dev/ (or use “Clear cache” in Performance settings). 3. Ensure each language has a valid “Friendly URL” entry • Still in Shop Parameters → Traffic & SEO, look at the “Set shop URL” table showing one row per language. • Verify that the “Friendly URL” column for your second language (e.g., English) is not blank. It should show something like /en/ or another clean URL. • If it’s blank, click the pencil icon on the English row and simply click Save (no changes needed). This forces PrestaShop to re-generate the route for that language. • After saving, toggle Friendly URLs off → on again, then clear cache one more time. 4. Check your theme’s header/language switcher • If you use a custom theme, open its header.tpl (or nav.tpl) and confirm you still have the {hook h='header'} (or {hook h='displayNav2'}) in place. Themes that override the language switcher sometimes call $controller->getTemplateVarUrls() without checking for a valid URL. • To verify whether the theme is the culprit, temporarily switch to the default “Classic” theme and see if the error disappears. If Classic works fine, you know the problem lies in your theme override. 5. Test a direct URL in the second language • After completing steps 1–4, open a browser and go to a direct “index” URL with the second language ID, for example: perl CopyEdit https://yourdomain.com/index.php?controller=index&lang=2 (Replace lang=2 with your actual English language ID.) • If that works but the friendly version (https://yourdomain.com/en/) still fails, you know it’s still a URL-rewriting issue—go back to step 2 and double-check everything. (Only if steps 1–5 still fail) Temporary code workaround Use this only as a last resort, because it “hides” the symptom rather than fixing the root cause. Edit classes/controller/FrontController.php and locate the line where sanitizeUrl() is called on the alternative‐language URL (around line 2180). Replace the direct call to sanitizeUrl($this->getAlternativeLangsUrl()) with a guard check, for example: $rawAlt = $this->getAlternativeLangsUrl(); if (is_string($rawAlt) && $rawAlt !== '') { $altUrl = $this->sanitizeUrl($rawAlt); } else { // Fallback: link to homepage in the default language $altUrl = $this->context->link->getPageLink( 'index', true, (int) Configuration::get('PS_LANG_DEFAULT') ); } 1 Link to comment Share on other sites More sharing options...
ale.pixel Posted June 4 Author Share Posted June 4 (edited) Hello El Patron, thanks for the answer! My website is a multistore and the steps are a little bit different from yours so I had to search for the "Set shop URL" section under Advanced Parameters - Multistore. I tried what you said until the url list of my pages under Traffic&SEO and I see that for the index page the rewrited url is empty. I saved it without editing but the trick didn't seem to work. I have also cleaned the cache as you suggested. I'm already using the Classic theme I have also tried the temporary workaround but I don't have that line on my FrontController.php. It might be different in PrestaShop 8.2.1 ? Just asking 🙂 I'm sadly stuck at the same point of before Edited June 4 by ale.pixel Forgot a detail (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted June 4 Share Posted June 4 In the image, you can see that for the “index” row the “Friendly URL” field is empty. You need to enter index (or another slug of your choice) here. Regenerate .htaccess and re-enable Friendly URLs • Still using the same shop context, navigate to Shop Parameters → Traffic & SEO. Because you have multistore enabled, these settings apply per shop. • Double-check that Domain, SSL domain, and Base URI exactly match what you set in the Multistore section (e.g. /it/ and /en/). • Scroll down to “Friendly URLs”: Disable Friendly URLs and click Save. Then enable Friendly URLs again and click Save. • This forces PrestaShop to rebuild the .htaccess file and recreate the URL rewriting rules for each language in that specific shop. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now