From 22fcc2120f77050c080da969133057fa47bc3ecf Mon Sep 17 00:00:00 2001 From: Christian Uhl Date: Tue, 9 Aug 2016 11:30:38 +0000 Subject: [PATCH] Modified code to travis compatibility --- installation/model/database.php | 11 ++++------- libraries/cms/schema/changeitem/mysql.php | 5 +++-- libraries/joomla/database/driver.php | 5 ++++- libraries/joomla/database/driver/mysqli.php | 6 ++++-- libraries/joomla/database/driver/pdomysql.php | 5 +++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/installation/model/database.php b/installation/model/database.php index db187d9fafcbe..95b30aef90e64 100755 --- a/installation/model/database.php +++ b/installation/model/database.php @@ -652,12 +652,7 @@ public function createTables($options) } } - /* in case the nullDate Conversion has to be triggered additionally - remove after testing - // Do the nullDate Conversion - JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php'); - $jinstallscript = new JoomlaInstallerScript; - $jinstallscript->convertTablesToNewNullDate(); - */ + // Handle default backend language setting. This feature is available for localized versions of Joomla. $app = JFactory::getApplication(); @@ -1034,8 +1029,10 @@ public function populateDatabase($db, $schema) * If the Driver has set a nullDate which differs from the default (oldschool) nullDate * replace it in the query */ - if($db->getNullDate()) + if ($db->getNullDate()) + { $query = $db->convertNullDate($query,$db->getNullDate()); + } /** * This is a query which was supposed to convert tables to utf8mb4 charset but the server doesn't diff --git a/libraries/cms/schema/changeitem/mysql.php b/libraries/cms/schema/changeitem/mysql.php index 56cad9811c335..fdfb4e2d6c099 100644 --- a/libraries/cms/schema/changeitem/mysql.php +++ b/libraries/cms/schema/changeitem/mysql.php @@ -63,8 +63,9 @@ protected function buildCheckQuery() if ((($command == 'UPDATE `#__UTF8_CONVERSION`' || $command == 'UPDATE #__UTF8_CONVERSION') && strtoupper($wordArray[2]) == 'SET' - && strtolower(substr(str_replace('`', '', $wordArray[3]), 0, 9)) == 'converted') || - (($command == 'INSERT INTO `#__nullDate_conversion`') && strtolower(substr(str_replace('`', '', $wordArray[3]), 0, 9)) == 'converted')) + && strtolower(substr(str_replace('`', '', $wordArray[3]), 0, 9)) == 'converted') + || (($command == 'INSERT INTO `#__nullDate_conversion`') + && strtolower(substr(str_replace('`', '', $wordArray[3]), 0, 9)) == 'converted')) { // Statement is special statement to reset conversion status $this->queryType = 'UTF8CNV'; diff --git a/libraries/joomla/database/driver.php b/libraries/joomla/database/driver.php index 8281b020045c4..40f9baff6b25f 100755 --- a/libraries/joomla/database/driver.php +++ b/libraries/joomla/database/driver.php @@ -877,13 +877,16 @@ public function getAlterTableCharacterSet($tableName) /** * Automatically changes the null date in the Query File + * * @param string $query The query to convert * + * @param string $nullDate The used nullDate + * * @return string The converted query */ public function convertNullDate($query,$nullDate) { - if($nullDate != '0000-00-00 00:00:00') + if ($nullDate != '0000-00-00 00:00:00') { $query = str_replace('0000-00-00 00:00:00', $nullDate, $query); } diff --git a/libraries/joomla/database/driver/mysqli.php b/libraries/joomla/database/driver/mysqli.php index ffa50c53b7e86..9b0fe79d0ba36 100644 --- a/libraries/joomla/database/driver/mysqli.php +++ b/libraries/joomla/database/driver/mysqli.php @@ -195,9 +195,11 @@ public function connect() // Pre-populate the UTF-8 Multibyte compatibility flag based on server version $this->utf8mb4 = $this->serverClaimsUtf8mb4Support(); - //Use different NullTime - if($this->serverUsesNewNullTime()) + // Use different NullTime + if ($this->serverUsesNewNullTime()) + { $this->nullDate = '1000-01-01 00:00:00'; + } // Set the character set (needed for MySQL 4.1.2+). $this->utf = $this->setUtf(); diff --git a/libraries/joomla/database/driver/pdomysql.php b/libraries/joomla/database/driver/pdomysql.php index 3a61485c2e266..04ec5bcb7ae45 100644 --- a/libraries/joomla/database/driver/pdomysql.php +++ b/libraries/joomla/database/driver/pdomysql.php @@ -152,9 +152,10 @@ public function connect() /* * checking if the new null type format of myaql 5.7.0 is used */ - - if(version_compare($serverVersion, '5.7.0', '>=')) + if (version_compare($serverVersion, '5.7.0', '>=')) + { $this->nullDate = '1000-01-01 00:00:00'; + } $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);