Jump to content

Server Error 500 when accessing Modules Manager ->Alerts or Updates


Warbird

Recommended Posts

Hi,

I recently moved my prestashop 1.7.6 from a subfolder to my domain root (/PS/ to /).
Updated the base URI, flushed the cache, regenerated robots and .htaccess.

As far as I can tell the front and backend work fine with one single exception: only the Module Manager -> Alerts and Module Manager -> Updates pages do not work and produce a Server Error 500 (ups etc...). The interesting part is if I enable debug mode and access both pages, they work perfectly fine. I only get the error when debug mode is disabled.

Any ideas?

Thanks !

Link to comment
Share on other sites

  • 4 weeks later...

You need to check the error log, the error file may be within the PrestaShop root directory or the directory below it.

In one of the cases i have witnessed, this error was caused by "require_once" -- requiring a  missing module file

e.g

require_once(/......./...../public_html/shop/modules/contactform/recaptcha.php): failed to open stream: No such file or directory in /....../......./public_html/shop/src/Adapter/Module/Module.php on line 354

 

I updated the method instanciateLegacyModule to the one below.

I used php file_exists function to check if the file exists before requiring the file   

 protected function instanciateLegacyModule()
    {
        /*
         * @TODO Temporary: This test prevents an error when switching branches with the cache.
         * Can be removed at the next release (when we will be sure that it is defined)
         */
        $path = $this->disk->get('path', ''); // Variable needed for empty() test
        if (empty($path)) {
            $this->disk->set('path', _PS_MODULE_DIR_ . DIRECTORY_SEPARATOR . $this->attributes->get('name'));
        }
        // End of temporary content
        
        if(file_exists($this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php')) {
            require_once $this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php';
             $this->instance = LegacyModule::getInstanceByName($this->attributes->get('name'));
        }
        
       
    }

Hope this helps

Edited by DeParagon (see edit history)
Link to comment
Share on other sites

Thanks a lot for the pointer.
I managed to identify the following error which pops up each time I visit the modules page, modules alert and module upgrade page.

[28-Aug-2019 19:25:20] WARNING: [pool xxxx] child 11212 said into stderr: "NOTICE: PHP message: PHP Fatal error:  require_once(): Failed opening required '/home/xxxx/public_html/ps/modules/ps_newproducts/ps_newproducts.php' (include_path='/home/xxxx/public_html/vendor/pear/pear_exception:/home/xxxx/public_html/vendor/pear/console_getopt:/home/xxxx/public_html/vendor/pear/pear-core-minimal/src:/home/xxxx/public_html/vendor/pear/archive_tar:.:/opt/alt/php-fpm72/usr/lib/php') in /home/xxxx/public_html/src/Adapter/Module/Module.php on line 360"

It clearly shows that the page still tries to find content in the old, no longer existing, PS subfolder.

I tested a bit further and tried to disable some modules which failed.
Checking the log file shows that also these modules are still expected in the old directory. Example: the category tree:
 

require_once(): Failed opening required '/home/xxxx/public_html/ps/modules/ps_categorytree/ps_categorytree.php

The question is how to clear this error? I have cleared the cache in PS backend but no luck so far.

Any ideas?

Thanks !

Edited by Warbird (see edit history)
Link to comment
Share on other sites

You can override the method or replace the method 

OLD  instanciateLegacyModule method

    protected function instanciateLegacyModule()
    {
        /*
         * @TODO Temporary: This test prevents an error when switching branches with the cache.
         * Can be removed at the next release (when we will be sure that it is defined)
         */
        $path = $this->disk->get('path', ''); // Variable needed for empty() test
        if (empty($path)) {
            $this->disk->set('path', _PS_MODULE_DIR_ . DIRECTORY_SEPARATOR . $this->attributes->get('name'));
        }
        // End of temporary content
        require_once $this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php';
        $this->instance = LegacyModule::getInstanceByName($this->attributes->get('name'));
    }

To  New instanciateLegacyModule method

 

    protected function instanciateLegacyModule()
    {
        /*
         * @TODO Temporary: This test prevents an error when switching branches with the cache.
         * Can be removed at the next release (when we will be sure that it is defined)
         */
        $path = $this->disk->get('path', ''); // Variable needed for empty() test
        if (empty($path)) {
            $this->disk->set('path', _PS_MODULE_DIR_ . DIRECTORY_SEPARATOR . $this->attributes->get('name'));
        }
        // End of temporary content
       if(file_exists($this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php')){
          require_once $this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php';
        $this->instance = LegacyModule::getInstanceByName($this->attributes->get('name'));
      }
      
    }

Let me know how it goes....

Link to comment
Share on other sites

Thanks for the help.

I finally managed to fix it by manually deleting all the cache via FTP/SSH as outlined here: 

Quote

Manual cache clearing

Using an FTP client or hosting file manager, go to the root directory of your site on the server.

Delete content of the following directories (except index.php files):

        /cache/smarty/compile/
        /cache/smarty/cache/
        These are main cache directories. Also, if necessary, you can clean the following directories:

        /cache/cachefs/
        /img/tmp/
        /themes/your_theme/cache/
        Similarly, delete all files inside these directories, except for index.php files

   3. Delete file /cache/class_index.php. It is cache of PHP classes. You need to clear it when you make some overrides of classes and controllers.

   4. Cache cleared. Refresh the page you worked on and check the result.

followed by 

Quote

Try deleting the (dev and prod) folders inside the "/var/cache" directory .

this solved my problem

 

 

  • Like 1
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...