Jump to content

Undefined index: HTTP_REFERER in AdminController.php


Recommended Posts

Hi,

When I try to disable a product clicking the green checkmark next to the quantity, I am redirected to a 404 error page. Nginx logs throw the following errors:

2022/05/20 12:41:58 [error] 816#816: *345781 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined offset: 1 in /home/REDACTED/REDACTED/prestashop/classes/controller/AdminController.php on line 1281" while reading response header from upstream, client: REDACTED, server: REDACTED, request: "GET /REDACTED/index.php?controller=AdminProducts&id_product=266&statusproduct&token=REDACTED HTTP/2.0", upstream: "fastcgi://unix:/run/php/REDACTED.sock:", host: "REDACTED", referrer: "https://REDACTED/"
2022/05/20 12:42:04 [error] 816#816: *345781 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: HTTP_REFERER in /home/REDACTED/REDACTED/prestashop/classes/controller/AdminController.php on line 1280
PHP message: PHP Notice:  Undefined offset: 1 in /home/REDACTED/REDACTED/prestashop/classes/controller/AdminController.php on line 1281
PHP message: PHP Notice:  Undefined index: HTTP_REFERER in /home/REDACTED/REDACTED/prestashop/classes/controller/AdminController.php on line 1282" while reading response header from upstream, client: REDACTED, server: REDACTED, request: "GET /REDACTED/index.php?controller=AdminProducts&id_product=266&statusproduct&token=REDACTED HTTP/2.0", upstream: "fastcgi://unix:/run/php/www.lilweasel.com.sock:", host: "REDACTED"

Here is the relevant lines in the file:

$matches = array();
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false
    && strtolower($matches[1]) != strtolower(preg_replace('/controller/i', '', get_class($this)))) {
    $this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
} else {
    $this->redirect_after = self::$currentIndex.'&token='.$this->token;
}

Thanks in advance for your help.

Link to comment
Share on other sites

Just now, Prestachamps said:

Hi,

most probably you have the debug mode enabled, and Prestashop is throwing these notices. Try disabling the debug mode, and check if then the product disabling is working.

I hope that I could help.
Have a nice day, Leo.

Dear Leo,

Thank you for answering my message. I confirm that I don't have the debug mode enabled

Best regards,

Link to comment
Share on other sites

Hi,

in this case it could be caused by the nginx configuration, please contact your hosting company and ask them to check and fix this redirect inside the nginx configuration, or add an exclusion inside the nginx for the admin folder of the shop. Most probably they will ask for a backoffice account in order for them to check and fix this.

Are there other backoffice pages have strange redirects or behaviour like this 404?

Have a nice day, Leo.

Link to comment
Share on other sites

Just now, Prestachamps said:

Hi,

in this case it could be caused by the nginx configuration, please contact your hosting company and ask them to check and fix this redirect inside the nginx configuration, or add an exclusion inside the nginx for the admin folder of the shop. Most probably they will ask for a backoffice account in order for them to check and fix this.

Are there other backoffice pages have strange redirects or behaviour like this 404?

Have a nice day, Leo.

Hey,

I'm from the hosting company. :)
The Nginx configuration is on par with the official documentation: https://devdocs.prestashop.com/1.7/basics/installation/nginx/, no differences.

It's the only page (to my knowledge) who behave like this.

Thanks again,

Link to comment
Share on other sites

On 5/21/2022 at 11:19 PM, Prestachamps said:

Hi,

You can test it out by temporarily disabling the nginx on the server, to be sure that the nginx is causing this 404 redirect or there is some Prestashop issue on your shop.

Have a nice day, Leo.

Dear Leo,

Pardon my question but how shall I trigger the request causing the error if I shut off the web server?

Have a good day!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...