Skip to content
Extraits de code Groupes Projets
Valider 014d205d rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fixes #5178, enable STRICT_TRANS_TABLES in travis and fix remaining tests that...

Fixes #5178, enable STRICT_TRANS_TABLES in travis and fix remaining tests that do not pass w/ this mysql setting. Includes fixes to PrivacyManager plugin and fix for tracker when non-unicode site search keyword is stored in the DB (instead of storing the data as non-utf strings, we store the data as urlencoded if the keyword is not valid utf-8).
parent dab1ee71
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -256,13 +256,18 @@ class PageUrl ...@@ -256,13 +256,18 @@ class PageUrl
*/ */
public static function reencodeParameters(&$queryParameters, $encoding = false) public static function reencodeParameters(&$queryParameters, $encoding = false)
{ {
// if query params are encoded w/ non-utf8 characters (due to browser bug or whatever), if (function_exists('mb_check_encoding')) {
// encode to UTF-8. // if query params are encoded w/ non-utf8 characters (due to browser bug or whatever),
if (false !== $encoding // encode to UTF-8.
&& 'utf-8' != strtolower($encoding) if ($encoding != 'utf-8'
&& function_exists('mb_check_encoding') && $encoding != false
) { ) {
$queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding); Common::printDebug("Encoding page URL query parameters to $encoding.");
$queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding);
}
} else {
Common::printDebug("Page charset supplied in tracking request, but mbstring extension is not available.");
} }
return $queryParameters; return $queryParameters;
...@@ -349,5 +354,15 @@ class PageUrl ...@@ -349,5 +354,15 @@ class PageUrl
return array(); return array();
} }
}
public static function urldecodeValidUtf8($value)
{
$value = urldecode($value);
if (function_exists('mb_check_encoding')
&& !@mb_check_encoding($value, 'utf-8')
) {
return urlencode($value);
}
return $value;
}
}
\ No newline at end of file
...@@ -180,14 +180,19 @@ class ActionSiteSearch extends Action ...@@ -180,14 +180,19 @@ class ActionSiteSearch extends Action
if (is_array($actionName)) { if (is_array($actionName)) {
$actionName = reset($actionName); $actionName = reset($actionName);
} }
$actionName = trim(urldecode($actionName));
$actionName = PageUrl::urldecodeValidUtf8($actionName);
$actionName = trim($actionName);
if (empty($actionName)) { if (empty($actionName)) {
return false; return false;
} }
if (is_array($categoryName)) { if (is_array($categoryName)) {
$categoryName = reset($categoryName); $categoryName = reset($categoryName);
} }
$categoryName = trim(urldecode($categoryName)); $categoryName = PageUrl::urldecodeValidUtf8($categoryName);
$categoryName = trim($categoryName);
return array($url, $actionName, $categoryName, $count); return array($url, $actionName, $categoryName, $count);
} }
......
...@@ -146,8 +146,6 @@ before_script: ...@@ -146,8 +146,6 @@ before_script:
# configure mysql # configure mysql
- mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'" # Travis default - mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'" # Travis default
# Uncomment to enable sql_mode STRICT_TRANS_TABLES (new default in Mysql 5.6)
- mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'"
- mysql -e "SELECT @@sql_mode;" - mysql -e "SELECT @@sql_mode;"
- mysql -e "SHOW GLOBAL VARIABLES;" - mysql -e "SHOW GLOBAL VARIABLES;"
{% if pluginName is empty %} {% if pluginName is empty %}
......
...@@ -374,7 +374,7 @@ class PrivacyManagerTest extends SystemTestCase ...@@ -374,7 +374,7 @@ class PrivacyManagerTest extends SystemTestCase
// perform checks // perform checks
$this->checkLogDataPurged(); $this->checkLogDataPurged();
$this->_checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 68); // 5 blobs for 5 days $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 69); // 5 blobs for 5 days
} }
/** /**
...@@ -574,7 +574,7 @@ class PrivacyManagerTest extends SystemTestCase ...@@ -574,7 +574,7 @@ class PrivacyManagerTest extends SystemTestCase
// perform checks // perform checks
$this->checkLogDataPurged(); $this->checkLogDataPurged();
$this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 70); // 1 segmented blob + 5 day blobs $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 71); // 1 segmented blob + 5 day blobs
} }
// --- utility functions follow --- // --- utility functions follow ---
...@@ -720,15 +720,15 @@ class PrivacyManagerTest extends SystemTestCase ...@@ -720,15 +720,15 @@ class PrivacyManagerTest extends SystemTestCase
// one metric for jan & one for feb // one metric for jan & one for feb
Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][0])), Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][0])),
array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 1, 100)); array(self::GARBAGE_FIELD, $janDate1, $janDate1, 1, $janDate1, 100));
Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][1])), Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][1])),
array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 1, 200)); array(self::GARBAGE_FIELD, $febDate1, $febDate1, 1, $febDate1, 200));
// add garbage reports // add garbage reports
Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][0])), Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][0])),
array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 10, 'blobval')); array(self::GARBAGE_FIELD, $janDate1, $janDate1, 10, $janDate1, 'blobval'));
Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][1])), Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][1])),
array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 20, 'blobval')); array(self::GARBAGE_FIELD, $febDate1, $febDate1, 20, $febDate1, 'blobval'));
} }
protected function _checkNoDataChanges() protected function _checkNoDataChanges()
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter