Jump to content

Error with DB connection - No 500 http header


CocciNet

Recommended Posts

Hi there !

We are managing quite a lot of Prestashop websites, as an Agency.

On one of these, I realized a strange behavior of PS (1.6).

When PS has an issue with the DB connection and displays its famous "Link to database cannot be established ..." it fires a 200 OK header.

I assume a 500 error would make more sense and would be more appropriate ? (For instance when you have an uptime tool, it canno't detect that your website is actually down).

Is there a way to change this?

 

Thank you in advance for your feedback!

Max

Link to comment
Share on other sites

14 hours ago, Presta Bucket said:

Hello,

You can check inside config/settings.php to see the db link, name, user and password.

It might search for the database in the wrong location.

 

Best regards

Hello Presta Bucket,

Sorry for being a bit rude but... did you really read my original post?

I didn't say I'm not able to connect to the DB! Just trying to figure out, when for instance Mysql is down, why is PS sending a 200 OK answer...

Link to comment
Share on other sites

16 hours ago, CocciNet said:

Hello Presta Bucket,

Sorry for being a bit rude but... did you really read my original post?

I didn't say I'm not able to connect to the DB! Just trying to figure out, when for instance Mysql is down, why is PS sending a 200 OK answer...

We are sorry, we understood wrong your question. We will try to test this tomorrow and try to find a solution. You want a 500 error to be triggered when you are not able to connect to the DB, right?

Best regards

Link to comment
Share on other sites

Hello!

Thank you very much for your new answer.

Yes I think a 500 error would be more appropriate in case of DB connection issue. (As it is the case for all other CMS we're using).

Triggering a 500 error allows Uptime Robots to spot and report that something is going wrong.

Thank you for your support!

Max

Link to comment
Share on other sites

  • 3 months later...

Hi again!

Forget it - it is probably a common issue with this PS version.

I managed to fix it by changing line 102 of /classes/db/DbPDO.php

From : 

die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));

to 

throw new PrestaShopException('Link to database cannot be established:'.$e->getMessage());

 

Max

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...