WebDesires

PrestaShop 503 Internal Server Error Paypal Module

PrestaShop 503 Internal Server Error Paypal Module

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support
There is a mobile optimized version of this page, view AMP Version.

One of our clients was having serious issues with their PrestaShop store, it would randomly start returning 503 Internal Server Error and would not come back up again, we found the only way to make the site work was to disable the PayPal Module and the site would magically start working again. To make things even stranger, if we re-enabled the PayPal Module again the site would continue to work for several weeks before the behaviour would repeat again. Eventually we managed to narrow this down to the following file: /modules/paypal/paypal_logos.php Open this file in a text editor and find these lines below, roughly line 134 (at the very bottom):

<?php
private function updatePictures($source, $destination, $force = false)
{
    
    $wrappers = stream_get_wrappers();
    $https_wrapper = in_array('https', $wrappers) ? true : false;
    
    // 604800 => One week timestamp
    if (!file_exists(_PS_MODULE_DIR_.$destination) || ((time() - filemtime(_PS_MODULE_DIR_.$destination)) > 604800) || $force) {
        $picture = Tools::file_get_contents($source);
        if ((bool) $picture !== false) {
            if ($handle = @fopen(_PS_MODULE_DIR_.$destination, 'w+')) {
                $size = fwrite($handle, $picture);
                if ($size > 0 || (file_exists(_MODULE_DIR_.$destination) && (@filesize(_MODULE_DIR_.$destination) > 0))) {
                    return _MODULE_DIR_.$destination;
                }
            
            }
        } elseif (strstr($source, 'https')) {
            return $this->updatePictures(str_replace('https', 'http', $source), $destination);
        } else {
            return false;
        }
    
    }
    
    return _MODULE_DIR_.$destination;
}
?>

Comment out everything in this function and place a “return false;” like this:

<?php
private function updatePictures($source, $destination, $force = false)
{
    
    //$wrappers = stream_get_wrappers();
    //$https_wrapper = in_array('https', $wrappers) ? true : false;
    
    // 604800 => One week timestamp
    /*if (!file_exists(_PS_MODULE_DIR_.$destination) || ((time() - filemtime(_PS_MODULE_DIR_.$destination)) > 604800) || $force) {
        $picture = Tools::file_get_contents($source);
        if ((bool) $picture !== false) {
            if ($handle = @fopen(_PS_MODULE_DIR_.$destination, 'w+')) {
                $size = fwrite($handle, $picture);
                if ($size > 0 || (file_exists(_MODULE_DIR_.$destination) && (@filesize(_MODULE_DIR_.$destination) > 0))) {
                    return _MODULE_DIR_.$destination;
                }
            
            }
        } elseif (strstr($source, 'https')) {
            return $this->updatePictures(str_replace('https', 'http', $source), $destination);
        } else {
            return false;
        }
    
    }
    
    return _MODULE_DIR_.$destination;*/
    return false;
}
?>

And now everything should work fine…

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support

Author: Dean Williams

Professional PHP Web Developer with expertise in OpenCart Web Development, WordPress Web Development, Bespoke Systems - also a seasoned Linux Server Administrator.