Quick tip: How to Debug Prestashop Error 500 (1.5)

If you just upgraded Prestashop to version 1.5, or are trying to make your modules compatible with this new version, you might have run into the cryptic Internal Server Error (500). Let’s see how to make it more understandable in Prestashop.

Watch the screencast

UPDATE – Fixing Paypal error 500 in Prestashop 1.5

I am just out of a hourly struggle with the Paypal module in 1.5. If you happen to get error 500, and can’t solve it in anyway, it’s mostly due to the url. The paypal module uses the following url to perform the payment (express checkout):

http://mystore.com/modules/paypal/express_checkout/submit.php

And this is BAD, since Prestashop 1.5 uses the following structure:

http://mystore.com/index.php?fc=module&module=modulename&controller=modulecontroller

So, it’s necessary to change the url that points to the first link, into something Presta 1.5 likes, using the second API reference. So! Here is an example if you use express checkout, like the link above.

Go to modules/paypal/views/templates/front/express_checkout/paypal.tpl and change the action of the form with ID paypal_payment_form from

action=""{$base_dir_ssl}modules/paypal/express_checkout/submit.php"

to

action="{$base_dir_ssl}index.php?fc=module&module=paypal&controller=expresscheckoutsubmit"

Again, this is for the one page checkout! If you’re using 5 steps checkout, you will need to edit the links in modules/paypal/views/templates/front/paypal.tpl

Now open up modules/paypal/express_checkout/paypal_express_checkout.php. Go to (approximately) line 223 and change this:

		$fields['RETURNURL'] = PayPal::getShopDomainSsl(true, true)._MODULE_DIR_.$this->name.'/express_checkout/submit.php';

Into this:
 

		$fields['RETURNURL'] = PayPal::getShopDomainSsl(true, true)._PS_DIRECTORY_.'index.php?fc=module&module=paypal&controller=expresscheckoutsubmit';

This way, we ensure Paypal returns to the correct page when coming back to the site and confirming the order.

Text version – How to Debug Prestashop Error 500

Error 500 is a nightmare for every developer, because it doesn’t tell you anything at all about what’s going on. It’s more or less like the scary Blank Page.

If you had this error with Prestashop 1.4, it was probably due to some .htaccess misconfiguration when activating friendly urls, or some folders permissions not set to 0755. However, Prestashop was crystal clear about errors if the display_errors setting in config.inc.php was set to true. But now you already did it, and you also turned on ps_debug_sql! Plus, you are not using any htaccess special configuration, and you are whether set the folders permissions to 0755 or running the store on a local environment. So, what’s the catch?

Prestashop 1.5 comes with some new Exception classes, to help the developer have a better tracking of the errors’ source. Howver, what Prestashop doesn’t tell you, since it does not have a decent user manual, is that you have to enable the development mode to take advantage of the new debugging features.

So, just head to config/ and open up defines.inc.php. Then, set _PS_MODE_DEV_ to TRUE as shown below

define('_PS_MODE_DEV_', true);
define('_PS_DEBUG_PROFILING_', false);
define('_PS_MODE_DEMO_', false);

It should be at line 28.

Now go back to the error page and refresh, you should see something like this (may vary depending of the exception thrown)

Prestashop error 500 Debugged

In this case, I can now see that a table I’m referencing doesn’t exist.

So, this is everything on how to debug prestashop error 500. Even if you don’t understand a single line of the error above, you might hopefully be able to fix it with your developer (by the way, if you need one, you can hire me!).

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • Axel

    When updating from PS 1.6.0.5 to 1.6.0.6 using 1-click Upgrade, Server Error 500 popped up. I solved it by re-associating the theme to the shop.

    This post helped me a lot.

    THX

  • http://www.painefreecrafts.com Sarah Paine

    Unfortunately with the change to 1.5.3.1 that folder (/modules/paypal/views/template/front) now doesn’t even have any subdirectories under it.

    PayPal isn’t sending the authorisation back to Prestashop at the moment – looks like a similar issue.

    • mattia

      that’s right! have you found any solution?

  • akiraceo

    I did as per video but still getting the server error page. :(

    what i did, went to config/ and change the code to TRUE in define.inc

    • http://nemops.com Nemo

      You also have to turn errors on if youre using a version prior to 1.5.3, go to config.inc.php and change display_errors to “on” and debug_sql to true

  • http://meridiansupplements.com globaltrader

    Hi,

    Thanksfor the solution but unfortunately this does not work because once you change the syntax,cPanel gives you a communication error and does not allow the file to be saved. This is in the first step which means you can’t even go to the second step.

    Regards.

    • http://nemops.com Nemo

      Hi,
      What kind of error? It worked for many people as far as I know (and for me too)

Store Top Sales

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: