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:
Diffstat (limited to 'plugins/CoreUpdater/Tasks.php')
-rw-r--r--plugins/CoreUpdater/Tasks.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/CoreUpdater/Tasks.php b/plugins/CoreUpdater/Tasks.php
index 7998a83925..f3ecae955d 100644
--- a/plugins/CoreUpdater/Tasks.php
+++ b/plugins/CoreUpdater/Tasks.php
@@ -8,11 +8,23 @@
*/
namespace Piwik\Plugins\CoreUpdater;
+use Piwik\Config;
+use Piwik\Container\StaticContainer;
+use Piwik\Db;
+use Piwik\DbHelper;
+
class Tasks extends \Piwik\Plugin\Tasks
{
public function schedule()
{
$this->daily('sendNotificationIfUpdateAvailable', null, self::LOWEST_PRIORITY);
+
+ $dbSettings = new \Piwik\Db\Settings();
+ $settings = StaticContainer::get('Piwik\Plugins\CoreUpdater\SystemSettings');
+
+ if ($dbSettings->getUsedCharset() !== 'utf8mb4' && DbHelper::getDefaultCharset() === 'utf8mb4' && $settings->updateToUtf8mb4->getValue()) {
+ $this->daily('convertToUtf8mb4', null, self::HIGHEST_PRIORITY);
+ }
}
public function sendNotificationIfUpdateAvailable()
@@ -22,4 +34,20 @@ class Tasks extends \Piwik\Plugin\Tasks
$coreUpdateCommunication->sendNotificationIfUpdateAvailable();
}
}
+
+ public function convertToUtf8mb4()
+ {
+ $queries = DbHelper::getUtf8mb4ConversionQueries();
+
+ foreach ($queries as $query) {
+ Db::get()->exec($query);
+ }
+
+ $config = Config::getInstance();
+ $config->database['charset'] = 'utf8mb4';
+ $config->forceSave();
+
+ $settings = StaticContainer::get('Piwik\Plugins\CoreUpdater\SystemSettings');
+ $settings->updateToUtf8mb4->setValue(false);
+ }
} \ No newline at end of file