? ? Pending

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
19 Mar 2016

Summary of Changes

Sets the pdomysql driver to use mysql non strict mode to have the same behavior that mysql and mysqli drivers.

Testing Instructions

Use a mysql 5.6.6+ db server (or emulate the strict sql mode in pdomysql driver).

  1. Set mysql driver mode to "PDO (Mysql)" in global configuration
  2. Go to Extensions -> Install languages - Find Languages. You'll get an sql strict mode error.
  3. Apply the patch
  4. Repeat step 2. You will not get a sql mode strict error.

@wilsonge: when solved the install language and find updates strict problems, i think you can merge this.

Note:

To emulate strict mode before the patch (like is default in mysql 5.6.29), go to https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/database/driver/pdomysql.php#L149

And add this line after

$this->connection->query("SET @@SESSION.sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION';");
avatar andrepereiradasilva andrepereiradasilva - open - 19 Mar 2016
avatar andrepereiradasilva andrepereiradasilva - change - 19 Mar 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Mar 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Mar 2016

@mbabker should this be in joomla framework too?

BTW this is failing a unit test

1) JDatabaseDriverPdomysqlTest::testExecute
641
Failed asserting that '0' matches expected 5.

Anyone can help with this?

avatar mbabker
mbabker - comment - 19 Mar 2016

I'd argue that the Framework should actually remove the strict_mode thing given its intended audience and if developers can't figure out how to tune their MySQL servers and application code to work right they've got bigger issues.

avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Mar 2016

makes sense

And reggarding the failing unit test can you help solving this?

avatar mbabker
mbabker - comment - 19 Mar 2016

Apply this diff:

diff --git a/tests/unit/suites/database/driver/pdomysql/JDatabaseDriverPdomysqlTest.php b/tests/unit/suites/database/driver/pdomysql/JDatabaseDriverPdomysqlTest.php
index 60da486..41ed865 100644
--- a/tests/unit/suites/database/driver/pdomysql/JDatabaseDriverPdomysqlTest.php
+++ b/tests/unit/suites/database/driver/pdomysql/JDatabaseDriverPdomysqlTest.php
@@ -629,18 +629,7 @@ class JDatabaseDriverPdomysqlTest extends TestCaseDatabasePdomysql
            "REPLACE INTO `jos_dbtest` SET `id` = 5, `title` = 'testTitle', `start_date` = '2014-08-17 00:00:00', `description` = 'testDescription'"
        );

-       $this->assertThat(
-           (bool) self::$driver->execute(),
-           $this->isTrue(),
-           __LINE__
-       );
-
-       $this->assertThat(
-           self::$driver->insertid(),
-           $this->equalTo(5),
-           __LINE__
-       );
-
+       $this->assertInstanceOf('PDOStatement', self::$driver->execute());
    }

    /**

Ya it's changing the test completely, but that second assertion isn't part of validating that the driver's execute method runs without an error (it's actually validating the insert data). To me this change is good enough for what we're aiming to test.

avatar joomla-cms-bot joomla-cms-bot - change - 19 Mar 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Mar 2016

@mbabker

I'd argue that the Framework should actually remove the strict_mode thing given its intended audience and if developers can't figure out how to tune their MySQL servers and application code to work right they've got bigger issues.

I agree with you, but mysql and mysqli drivers in the framework use sql_mode = '', so those should be removed to, or, my preferred option, define a strict mode to use in all drivers in the framework for consistency across mysql drivers and mysql versions.

avatar wilsonge wilsonge - change - 19 Mar 2016
Labels Added: ?
avatar mbabker
mbabker - comment - 19 Mar 2016

The Framework doesn't have a driver for ext/mysql. Its MysqlDriver is the PDO driver. So it's just MySQLi that needs to remove it.

avatar richard67
richard67 - comment - 19 Mar 2016

@andrepereiradasilva I wanna help with test but not have such a new mysql version available.

For such a case, I assume for the before patch test, the pdomysql driver shall be hacked like it was with George's PRs, means in the same where your patch has this new line to set sql session mode to empty, I have to add the line with the hack to the file before patch right?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9485.

avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Mar 2016

to emulate strict mode before the patch (like is default in mysql 5.6.29), go to https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/database/driver/pdomysql.php#L149

And add this line after

$this->connection->query("SET @@SESSION.sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION';");
avatar richard67 richard67 - test_item - 19 Mar 2016 - Tested successfully
avatar richard67
richard67 - comment - 19 Mar 2016

I have tested this item :white_check_mark: successfully on d7533fc

Tested on a mysql < 5.6.6 so I had to hack the pdomysql.php to get the error before patch.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9485.

avatar wilsonge wilsonge - change - 20 Mar 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-03-20 16:42:27
Closed_By wilsonge
avatar wilsonge wilsonge - change - 20 Mar 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment