Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-12-13 23:04:25 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-12-13 23:23:14 +0300
commit27a4ec6fb76bf17b409685d146d6d3765686edf4 (patch)
treea17198e66f262f436963d33665b851e17107e5f3 /core/Db.php
parent6cd4dda2b479bf39b6c91669a7d68512577ea879 (diff)
refs #9131 lock name should be less than 64 characters for MySQL compatibility
Diffstat (limited to 'core/Db.php')
-rw-r--r--core/Db.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/Db.php b/core/Db.php
index f7eae8c8b2..387f9c7a4d 100644
--- a/core/Db.php
+++ b/core/Db.php
@@ -91,6 +91,17 @@ class Db
}
/**
+ * For tests only.
+ * @param $connection
+ * @ignore
+ * @internal
+ */
+ public static function setDatabaseObject($connection)
+ {
+ self::$connection = $connection;
+ }
+
+ /**
* Connects to the database.
*
* Shouldn't be called directly, use {@link get()} instead.
@@ -638,9 +649,14 @@ class Db
* @param string $lockName The lock name.
* @param int $maxRetries The max number of times to retry.
* @return bool `true` if the lock was obtained, `false` if otherwise.
+ * @throws \Exception if Lock name is too long
*/
public static function getDbLock($lockName, $maxRetries = 30)
{
+ if (strlen($lockName) > 64) {
+ throw new \Exception('DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.');
+ }
+
/*
* the server (e.g., shared hosting) may have a low wait timeout
* so instead of a single GET_LOCK() with a 30 second timeout,
@@ -652,7 +668,8 @@ class Db
$db = self::get();
while ($maxRetries > 0) {
- if ($db->fetchOne($sql, array($lockName)) == '1') {
+ $result = $db->fetchOne($sql, array($lockName));
+ if ($result == '1') {
return true;
}
$maxRetries--;