Skip to content

Commit

Permalink
Fix serverClaimsUtf8mb4Support()
Browse files Browse the repository at this point in the history
As previously defined, the method could return true even when
$client_version < 5.5.3 (for non-mysqlnd clients).
  • Loading branch information
zjw committed Nov 21, 2015
1 parent 240cdca commit 90bb176
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
19 changes: 13 additions & 6 deletions libraries/joomla/database/driver/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,24 @@ private function hasProfiling()
private function serverClaimsUtf8mb4Support()
{
$client_version = mysql_get_client_info();
$server_support = version_compare($this->getVersion(), '5.5.3', '>=');
$server_version = $this->getVersion();

if (strpos($client_version, 'mysqlnd') !== false && $server_support)
if (version_compare($server_version, '5.5.3', '<'))
{
$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);

return version_compare($client_version, '5.0.9', '>=');
return false;
}
else
{
return $server_support;
if (strpos($client_version, 'mysqlnd') !== false)
{
$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);

return version_compare($client_version, '5.0.9', '>=');
}
else
{
return version_compare($client_version, '5.5.3', '>=');
}
}
}

Expand Down
19 changes: 13 additions & 6 deletions libraries/joomla/database/driver/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,17 +952,24 @@ private function hasProfiling()
private function serverClaimsUtf8mb4Support()
{
$client_version = mysqli_get_client_info();
$server_support = version_compare($this->getVersion(), '5.5.3', '>=');
$server_version = $this->getVersion();

if (strpos($client_version, 'mysqlnd') !== false && $server_support)
if (version_compare($server_version, '5.5.3', '<'))
{
$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);

return version_compare($client_version, '5.0.9', '>=');
return false;
}
else
{
return $server_support;
if (strpos($client_version, 'mysqlnd') !== false)
{
$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);

return version_compare($client_version, '5.0.9', '>=');
}
else
{
return version_compare($client_version, '5.5.3', '>=');
}
}
}

Expand Down

0 comments on commit 90bb176

Please sign in to comment.