omine Posted February 9, 2016 Share Posted February 9, 2016 I was having problem to upgrade PrestaShop since 1.6.1.1. The upgrade process was being interrupted with message 'Invalid database configuration.' Mitigating the problem, i found the reson on this file: /modules/autoupgrade/AdminSelfUpgrade.php The original code with my personal comments: //check DB access $this->db; // <-- this should be here? seems a mistyping. error_reporting(E_ALL); $resultDB = Db::checkConnection(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_); /** Disabled to avoid the "Invalid database configuration" error while upgrading the PrestaShop. The variable $resultDB always returning 1 or different of 0. */ /** if ($resultDB !== 0) { // $logger->logError('Invalid database configuration.'); $this->next = 'error'; $this->nextQuickInfo[] = $this->l('Invalid database configuration'); $this->nextErrors[] = $this->l('Invalid database configuration'); return false; } */ After disable this code, the upgrade process finished successful. More detailed information I did search over all PrestaShop files, searching for "Db::checkConnection". The only file using this function is "AdminSelfUpgrade.php". I think this should be removed or fixed for next releases. Db::checkConnection invokes call_user_func_array() which in turn, calls the database library dynamically. public static function checkConnection($server, $user, $pwd, $db, $new_db_link = true, $engine = null, $timeout = 5) { return call_user_func_array(array(Db::getClass(), 'tryToConnect'), array($server, $user, $pwd, $db, $new_db_link, $engine, $timeout)); } The library is returned by Db::getClass() public static function getClass() { $class = 'MySQL'; if (PHP_VERSION_ID >= 50200 && extension_loaded('pdo_mysql')) { $class = 'DbPDO'; } elseif (extension_loaded('mysqli')) { $class = 'DbMySQLi'; } return $class; } This code returns different value on this same server. From BackOffice, returns DbMySQLi However, running the same script outside PrestaShop, on same server, returns DbPDO The PHP_VERSION_ID is 50528 and extension_loaded('pdo_mysql') returns boolean true.So, i don't understand why within PrestaShop BackOffice returning DbMySQLi. By the way, DbMySQLi::tryToConnect() code is: public static function tryToConnect($server, $user, $pwd, $db, $new_db_link = true, $engine = null, $timeout = 5) { $link = mysqli_init(); if (!$link) { return -1; } if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout)) { return 1; } // There is an @ because mysqli throw a warning when the database does not exists if (!@$link->real_connect($server, $user, $pwd, $db)) { return (mysqli_connect_errno() == 1049) ? 2 : 1; } $link->close(); return 0; } The problem may be something on this method. Whatever, the simplest way was skip the $resultDB = Db::checkConnection to complete the upgrade.If someone face the same issue, this information can be useful. 1 Link to comment Share on other sites More sharing options...
qslkjhlhoiuhb Posted February 10, 2017 Share Posted February 10, 2017 You saved me. Thank you. I had the same problem upgrading from 1.6.1.10 to 1.6.11. Link to comment Share on other sites More sharing options...
TartekaMedia Posted March 9, 2017 Share Posted March 9, 2017 Thanks a lot, i had the same problem upgrading from 1.6.8 to 1.6.11 and the fix works like a charm. Best Wishes. Link to comment Share on other sites More sharing options...
Robneva Posted April 2, 2017 Share Posted April 2, 2017 Thanks heaps for this, it has fixed our issue with upgrade as well. Link to comment Share on other sites More sharing options...
andrew Posted August 10, 2017 Share Posted August 10, 2017 Thank you so much This fixed it for me (upgrading from 1.5.6.2 to 1.6) Regards - Andrew http://brilliantbikes.co.uk Link to comment Share on other sites More sharing options...
kaleske Posted September 16, 2017 Share Posted September 16, 2017 I have to say thank you, your post helped to me too. Link to comment Share on other sites More sharing options...
omine Posted July 10, 2018 Author Share Posted July 10, 2018 3 years later i have the same problem and found my own solution here.. PS 1.6.1.17 -> 1.6.1.20 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now