diff options
52 files changed, 179 insertions, 160 deletions
diff --git a/composer.json b/composer.json index 492a9d5392..dbaca699cd 100644 --- a/composer.json +++ b/composer.json @@ -53,6 +53,8 @@ "symfony/console": "~2.6.0", "symfony/event-dispatcher": "~2.6.0", "symfony/monolog-bridge": "~2.6.0", + "symfony/polyfill-iconv": "^1.20", + "symfony/polyfill-mbstring": "^1.20", "szymach/c-pchart": "^2.0", "tecnickcom/tcpdf": "~6.0", "tedivm/jshrink": "~v1.4.0", diff --git a/composer.lock b/composer.lock index 2954b8f1fe..554d71cf81 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1fb038ec3571e182b3c780951401a2a8", + "content-hash": "19ff7d7481f48d2222780911dcf7f8b8", "packages": [ { "name": "composer/ca-bundle", @@ -1867,6 +1867,86 @@ "time": "2020-10-23T14:02:19+00:00" }, { + "name": "symfony/polyfill-iconv", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-iconv.git", + "reference": "c536646fdb4f29104dd26effc2fdcb9a5b085024" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/c536646fdb4f29104dd26effc2fdcb9a5b085024", + "reference": "c536646fdb4f29104dd26effc2fdcb9a5b085024", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-iconv": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Iconv\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Iconv extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "iconv", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.20.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" + }, + { "name": "symfony/polyfill-mbstring", "version": "v1.20.0", "source": { diff --git a/core/API/ApiRenderer.php b/core/API/ApiRenderer.php index cfc851b748..6e665a184c 100644 --- a/core/API/ApiRenderer.php +++ b/core/API/ApiRenderer.php @@ -120,7 +120,7 @@ abstract class ApiRenderer */ public static function factory($format, $request) { - if (Common::mb_strtolower($format) === 'json2') { + if (mb_strtolower($format) === 'json2') { $format = 'json'; } $formatToCheck = '\\' . ucfirst(strtolower($format)); diff --git a/core/CliMulti/Output.php b/core/CliMulti/Output.php index 73985abe24..a9c34530ec 100644 --- a/core/CliMulti/Output.php +++ b/core/CliMulti/Output.php @@ -63,8 +63,8 @@ class Output $search = '#!/usr/bin/env php'; if (!empty($content) && is_string($content) - && Common::mb_substr(trim($content), 0, strlen($search)) === $search) { - $content = trim(Common::mb_substr(trim($content), strlen($search))); + && mb_substr(trim($content), 0, strlen($search)) === $search) { + $content = trim(mb_substr(trim($content), strlen($search))); } return $content; } diff --git a/core/Common.php b/core/Common.php index 7085aea33f..c1a0a72a55 100644 --- a/core/Common.php +++ b/core/Common.php @@ -184,21 +184,13 @@ class Common * * @param string $string * @param int $start - * @param int ... optional length + * @param int|null $length optional length * @return string - * @api + * @deprecated since 4.4 - directly use mb_substr instead */ - public static function mb_substr($string, $start) + public static function mb_substr($string, $start, $length = null) { - $length = func_num_args() > 2 - ? func_get_arg(2) - : self::mb_strlen($string); - - if (function_exists('mb_substr')) { - return mb_substr($string, $start, $length, 'UTF-8'); - } - - return substr($string, $start, $length); + return mb_substr($string, $start, $length, 'UTF-8'); } /** @@ -233,15 +225,11 @@ class Common * * @param string $string * @return int - * @api + * @deprecated since 4.4 - directly use mb_strlen instead */ public static function mb_strlen($string) { - if (function_exists('mb_strlen')) { - return mb_strlen($string, 'UTF-8'); - } - - return strlen($string); + return mb_strlen($string, 'UTF-8'); } /** @@ -251,16 +239,11 @@ class Common * * @param string $string * @return string - * @api + * @deprecated since 4.4 - directly use mb_strtolower instead */ public static function mb_strtolower($string) { - if (function_exists('mb_strtolower')) { - return mb_strtolower($string, 'UTF-8'); - } - - // return unchanged string as using `strtolower` might cause unicode problems - return $string; + return mb_strtolower($string, 'UTF-8'); } /** @@ -270,16 +253,11 @@ class Common * * @param string $string * @return string - * @api + * @deprecated since 4.4 - directly use mb_strtoupper instead */ public static function mb_strtoupper($string) { - if (function_exists('mb_strtoupper')) { - return mb_strtoupper($string, 'UTF-8'); - } - - // return unchanged string as using `strtoupper` might cause unicode problems - return $string; + return mb_strtoupper($string, 'UTF-8'); } /** diff --git a/core/Concurrency/Lock.php b/core/Concurrency/Lock.php index 2019c2955f..9959a533c9 100644 --- a/core/Concurrency/Lock.php +++ b/core/Concurrency/Lock.php @@ -82,11 +82,11 @@ class Lock { $this->lockKey = $this->lockKeyStart . $id; - if (Common::mb_strlen($this->lockKey) > self::MAX_KEY_LEN) { + if (mb_strlen($this->lockKey) > self::MAX_KEY_LEN) { // Lock key might be too long for DB column, so we hash it but leave the start of the original as well // to make it more readable $md5Len = 32; - $this->lockKey = Common::mb_substr($id, 0, self::MAX_KEY_LEN - $md5Len - 1) . md5($id); + $this->lockKey = mb_substr($id, 0, self::MAX_KEY_LEN - $md5Len - 1) . md5($id); } $lockValue = substr(Common::generateUniqId(), 0, 12); diff --git a/core/CronArchive.php b/core/CronArchive.php index ec52fe9a31..9e5ffb365b 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -673,11 +673,11 @@ class CronArchive { if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) { $m = str_replace(array("\n", "\t"), " ", $m); - if (Common::mb_strlen($m) > self::TRUNCATE_ERROR_MESSAGE_SUMMARY) { + if (mb_strlen($m) > self::TRUNCATE_ERROR_MESSAGE_SUMMARY) { $numCharactersKeepFromEnd = 100; - $m = Common::mb_substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY - $numCharactersKeepFromEnd) + $m = mb_substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY - $numCharactersKeepFromEnd) . ' ... ' . - Common::mb_substr($m, -1 * $numCharactersKeepFromEnd); + mb_substr($m, -1 * $numCharactersKeepFromEnd); } } $this->errors[] = $m; diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php index 496e995f47..7097aa7a64 100644 --- a/core/DataAccess/LogAggregator.php +++ b/core/DataAccess/LogAggregator.php @@ -212,10 +212,10 @@ class LogAggregator $bind = $this->getGeneralQueryBindParams(); $tableName = self::LOG_TABLE_SEGMENT_TEMPORARY_PREFIX . md5(json_encode($bind) . $this->segment->getString()); - $lengthPrefix = Common::mb_strlen(Common::prefixTable('')); + $lengthPrefix = mb_strlen(Common::prefixTable('')); $maxLength = Db\Schema\Mysql::MAX_TABLE_NAME_LENGTH - $lengthPrefix; - return Common::mb_substr($tableName, 0, $maxLength); + return mb_substr($tableName, 0, $maxLength); } public function cleanup() diff --git a/core/Date.php b/core/Date.php index 328467ab67..82a3df42a6 100644 --- a/core/Date.php +++ b/core/Date.php @@ -800,7 +800,7 @@ class Date } if ($ucfirst) { - $out = Common::mb_strtoupper(Common::mb_substr($out, 0, 1)) . Common::mb_substr($out, 1); + $out = mb_strtoupper(mb_substr($out, 0, 1)) . mb_substr($out, 1); } return $out; diff --git a/core/DeviceDetector/DeviceDetectorFactory.php b/core/DeviceDetector/DeviceDetectorFactory.php index 6aa340e639..83931aaa1c 100644 --- a/core/DeviceDetector/DeviceDetectorFactory.php +++ b/core/DeviceDetector/DeviceDetectorFactory.php @@ -39,7 +39,7 @@ class DeviceDetectorFactory public static function getNormalizedUserAgent($userAgent) { - return Common::mb_substr(trim($userAgent), 0, 500); + return mb_substr(trim($userAgent), 0, 500); } /** diff --git a/core/Tracker/Failures.php b/core/Tracker/Failures.php index 5756b85ed1..1e96ea933d 100644 --- a/core/Tracker/Failures.php +++ b/core/Tracker/Failures.php @@ -101,7 +101,7 @@ class Failures if (!empty($token) && $value === $token) { $params[$key] = '__TOKEN_AUTH__'; // user accidentally posted the token in a wrong field } elseif (!empty($value) && is_string($value) - && Common::mb_strlen($value) >= 29 && Common::mb_strlen($value) <= 36 + && mb_strlen($value) >= 29 && mb_strlen($value) <= 36 && ctype_xdigit($value)) { $params[$key] = '__TOKEN_AUTH__'; // user maybe posted a token in a different field... it looks like it might be a token } diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 7957021143..1d1e3314d1 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -731,7 +731,7 @@ class GoalManager if (empty($lastActionTime)) { $conversion['buster'] = $this->makeRandomMySqlUnsignedInt(10); } else { - $conversion['buster'] = $this->makeRandomMySqlUnsignedInt(2) . Common::mb_substr($visitProperties->getProperty('visit_last_action_time'), 2); + $conversion['buster'] = $this->makeRandomMySqlUnsignedInt(2) . mb_substr($visitProperties->getProperty('visit_last_action_time'), 2); } } diff --git a/core/Tracker/PageUrl.php b/core/Tracker/PageUrl.php index b20c4999a7..0d875145a0 100644 --- a/core/Tracker/PageUrl.php +++ b/core/Tracker/PageUrl.php @@ -179,7 +179,7 @@ class PageUrl } if (!empty($parsedUrl['host'])) { - $parsedUrl['host'] = Common::mb_strtolower($parsedUrl['host']); + $parsedUrl['host'] = mb_strtolower($parsedUrl['host']); } if (!empty($parsedUrl['fragment'])) { @@ -365,7 +365,7 @@ class PageUrl $hostSiteCache = false; foreach ($siteUrlCache as $siteUrl) { - if (strpos(Common::mb_strtolower($siteUrl), Common::mb_strtolower('https://' . $host)) === 0) { + if (strpos(mb_strtolower($siteUrl), mb_strtolower('https://' . $host)) === 0) { $hostSiteCache = true; break; } diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 0a85a95aeb..954ca042de 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -262,8 +262,8 @@ class Request $valueRightMember = urldecode($matches[3]); } $actual = Common::getRequestVar($leftMember, '', 'string', $this->params); - $actual = Common::mb_strtolower($actual); - $valueRightMember = Common::mb_strtolower($valueRightMember); + $actual = mb_strtolower($actual); + $valueRightMember = mb_strtolower($valueRightMember); switch ($operation) { case SegmentExpression::MATCH_EQUAL: if ($actual === $valueRightMember) { diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 627f46d58d..cfc2a4830f 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -411,7 +411,7 @@ class Visit implements VisitInterface private static function toCanonicalHost($host) { - $hostLower = Common::mb_strtolower($host); + $hostLower = mb_strtolower($host); return str_replace('www.', '', $hostLower); } diff --git a/core/Twig.php b/core/Twig.php index 22c9b6fb81..f94ba78c67 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -26,7 +26,7 @@ use Twig\TwigTest; function piwik_filter_truncate($string, $size) { - if (Common::mb_strlen(html_entity_decode($string)) <= $size) { + if (mb_strlen(html_entity_decode($string)) <= $size) { return $string; } else { preg_match('/^(&(?:[a-z\d]+|#\d+|#x[a-f\d]+);|.){'.$size.'}/i', $string, $shortenString); diff --git a/core/Updates/4.0.0-b1.php b/core/Updates/4.0.0-b1.php index 79932200ab..13c7bdd868 100644 --- a/core/Updates/4.0.0-b1.php +++ b/core/Updates/4.0.0-b1.php @@ -238,7 +238,7 @@ class Updates_4_0_0_b1 extends PiwikUpdates $sessions = Db::fetchAll('SELECT id from ' . Common::prefixTable('session')); foreach ($sessions as $session) { - if (!empty($session['id']) && Common::mb_strlen($session['id']) != 128) { + if (!empty($session['id']) && mb_strlen($session['id']) != 128) { $bind = [ hash('sha512', $session['id'] . $salt), $session['id'] ]; try { Db::query(sprintf('UPDATE %s SET id = ? WHERE id = ?', Common::prefixTable('session')), $bind); diff --git a/core/Url.php b/core/Url.php index 14b685c6f5..03c8c5c15c 100644 --- a/core/Url.php +++ b/core/Url.php @@ -240,10 +240,10 @@ class Url } $trustedHosts = str_replace("/", "\\/", $trustedHosts); - $untrustedHost = Common::mb_strtolower($host); + $untrustedHost = mb_strtolower($host); $untrustedHost = rtrim($untrustedHost, '.'); - $hostRegex = Common::mb_strtolower('/(^|.)' . implode('$|', $trustedHosts) . '$/'); + $hostRegex = mb_strtolower('/(^|.)' . implode('$|', $trustedHosts) . '$/'); $result = preg_match($hostRegex, $untrustedHost); return 0 !== $result; @@ -666,7 +666,7 @@ class Url return; } - return Common::mb_strtolower($parsedUrl['host']); + return mb_strtolower($parsedUrl['host']); } /** @@ -684,11 +684,11 @@ class Url return false; } - $host = Common::mb_strtolower($host); + $host = mb_strtolower($host); if (!empty($urls)) { foreach ($urls as $url) { - if (Common::mb_strtolower($url) === $host) { + if (mb_strtolower($url) === $host) { return true; } diff --git a/core/Validators/CharacterLength.php b/core/Validators/CharacterLength.php index 213732b0cc..d40b11bfcb 100644 --- a/core/Validators/CharacterLength.php +++ b/core/Validators/CharacterLength.php @@ -44,7 +44,7 @@ class CharacterLength extends BaseValidator return; } - $lenValue = Common::mb_strlen($value); + $lenValue = mb_strlen($value); if (isset($this->min) && $this->min > $lenValue) { throw new Exception(Piwik::translate('General_ValidatorErrorCharacterTooShort', array($lenValue, $this->min))); diff --git a/libs/upgradephp/upgrade.php b/libs/upgradephp/upgrade.php index 3ac2b8ae8c..8dcddf6351 100644 --- a/libs/upgradephp/upgrade.php +++ b/libs/upgradephp/upgrade.php @@ -674,32 +674,6 @@ if (!function_exists('utf8_decode')) { } /** - * Use strtolower if mb_strtolower doesn't exist (i.e., php not compiled with --enable-mbstring) - * This is not a functional replacement for mb_strtolower. - * - * @param string $input - * @param string $charset - */ -if(!function_exists('mb_strtolower')) { - function mb_strtolower($input, $charset = '') { - return strtolower($input); - } -} - -/** - * Use strlen if mb_strlen doesn't exist (i.e., php not compiled with --enable-mbstring) - * This is not a functional replacement for mb_strlen. - * - * @param string $input - * @param string $charset - */ -if(!function_exists('mb_strlen')) { - function mb_strlen($input, $charset = '') { - return strlen($input); - } -} - -/** * On ubuntu in some cases, there is a bug that gzopen does not exist and one must use gzopen64 instead */ if (!function_exists('gzopen') diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php index 2fb196d291..8fc0d66806 100644 --- a/plugins/API/Controller.php +++ b/plugins/API/Controller.php @@ -195,7 +195,7 @@ class Controller extends \Piwik\Plugin\Controller $item['letters'] = array(); foreach ($item['entries'] as &$entry) { $cleanEntryName = preg_replace('/["\']/', '', $entry['name']); - $entry['letter'] = Common::mb_strtoupper(substr($cleanEntryName, 0, 1)); + $entry['letter'] = mb_strtoupper(substr($cleanEntryName, 0, 1)); $item['letters'][] = $entry['letter']; } diff --git a/plugins/Actions/Actions/ActionSiteSearch.php b/plugins/Actions/Actions/ActionSiteSearch.php index 450321442f..a65be0aecb 100644 --- a/plugins/Actions/Actions/ActionSiteSearch.php +++ b/plugins/Actions/Actions/ActionSiteSearch.php @@ -137,14 +137,14 @@ class ActionSiteSearch extends Action // strtolower the parameter names for smooth site search detection $parameters = array(); foreach ($parametersRaw as $k => $v) { - $parameters[Common::mb_strtolower($k)] = $v; + $parameters[mb_strtolower($k)] = $v; } // decode values if they were sent from a client using another charset PageUrl::reencodeParameters($parameters, $pageEncoding); // Detect Site Search keyword foreach ($keywordParameters as $keywordParameterRaw) { - $keywordParameter = Common::mb_strtolower($keywordParameterRaw); + $keywordParameter = mb_strtolower($keywordParameterRaw); if (!empty($parameters[$keywordParameter])) { $actionName = $parameters[$keywordParameter]; break; @@ -160,7 +160,7 @@ class ActionSiteSearch extends Action : array(); foreach ($categoryParameters as $categoryParameterRaw) { - $categoryParameter = Common::mb_strtolower($categoryParameterRaw); + $categoryParameter = mb_strtolower($categoryParameterRaw); if (!empty($parameters[$categoryParameter])) { $categoryName = $parameters[$categoryParameter]; break; diff --git a/plugins/Actions/DataTable/Filter/Actions.php b/plugins/Actions/DataTable/Filter/Actions.php index fff3491d1c..319db3cd77 100644 --- a/plugins/Actions/DataTable/Filter/Actions.php +++ b/plugins/Actions/DataTable/Filter/Actions.php @@ -72,7 +72,7 @@ class Actions extends BaseFilter $host = parse_url($url, PHP_URL_HOST); if ($host && PageUrl::shouldUseHttpsHost($site->getId(), $host)) { - $row->setMetadata('url', 'https://' . Common::mb_substr($url, 7 /* = strlen('http://') */)); + $row->setMetadata('url', 'https://' . mb_substr($url, 7 /* = strlen('http://') */)); } } } else if ($folderUrlStart) { diff --git a/plugins/Actions/VisitorDetails.php b/plugins/Actions/VisitorDetails.php index 2d3e4dde6d..86330f1603 100644 --- a/plugins/Actions/VisitorDetails.php +++ b/plugins/Actions/VisitorDetails.php @@ -166,7 +166,7 @@ class VisitorDetails extends VisitorDetailsAbstract $host = parse_url($action['url'], PHP_URL_HOST); if ($host && PageUrl::shouldUseHttpsHost($visitorDetails['idSite'], $host)) { - $action['url'] = 'https://' . Common::mb_substr($action['url'], 7 /* = strlen('http://') */); + $action['url'] = 'https://' . mb_substr($action['url'], 7 /* = strlen('http://') */); } } diff --git a/plugins/CoreHome/Columns/UserId.php b/plugins/CoreHome/Columns/UserId.php index 7bb8e20037..db23f9b7f0 100644 --- a/plugins/CoreHome/Columns/UserId.php +++ b/plugins/CoreHome/Columns/UserId.php @@ -57,7 +57,7 @@ class UserId extends VisitDimension { $value = $request->getForcedUserId(); if (!empty($value)) { - return Common::mb_substr($value, 0, self::MAXLENGTH); + return mb_substr($value, 0, self::MAXLENGTH); } return $value; } diff --git a/plugins/CoreVisualizations/Visualizations/Cloud.php b/plugins/CoreVisualizations/Visualizations/Cloud.php index 7ca3b98fa6..43ae5505f2 100644 --- a/plugins/CoreVisualizations/Visualizations/Cloud.php +++ b/plugins/CoreVisualizations/Visualizations/Cloud.php @@ -182,8 +182,8 @@ class Cloud extends Visualization { $word = Common::unsanitizeInputValue($word); - if (Common::mb_strlen($word) > $this->truncatingLimit) { - return Common::mb_substr($word, 0, $this->truncatingLimit - 3) . '...'; + if (mb_strlen($word) > $this->truncatingLimit) { + return mb_substr($word, 0, $this->truncatingLimit - 3) . '...'; } return $word; diff --git a/plugins/CustomDimensions/Tracker/CustomDimensionsRequestProcessor.php b/plugins/CustomDimensions/Tracker/CustomDimensionsRequestProcessor.php index b84b3d1569..c933ad0858 100644 --- a/plugins/CustomDimensions/Tracker/CustomDimensionsRequestProcessor.php +++ b/plugins/CustomDimensions/Tracker/CustomDimensionsRequestProcessor.php @@ -173,7 +173,7 @@ class CustomDimensionsRequestProcessor extends RequestProcessor private static function prepareValue($value) { - return Common::mb_substr(trim($value), 0, 250); + return mb_substr(trim($value), 0, 250); } public static function buildCustomDimensionTrackingApiName($idDimensionOrDimension) diff --git a/plugins/DevicesDetection/Columns/BrowserName.php b/plugins/DevicesDetection/Columns/BrowserName.php index 74ded90e01..fa997d6f84 100644 --- a/plugins/DevicesDetection/Columns/BrowserName.php +++ b/plugins/DevicesDetection/Columns/BrowserName.php @@ -41,9 +41,9 @@ class BrowserName extends Base $segment->setSqlFilterValue(function ($val) { $browsers = Browser::getAvailableBrowsers(); $browsers = array_map(function($val) { - return Common::mb_strtolower($val); + return mb_strtolower($val); }, $browsers); - $result = array_search(Common::mb_strtolower($val), $browsers); + $result = array_search(mb_strtolower($val), $browsers); if ($result === false) { $result = 'UNK'; diff --git a/plugins/DevicesDetection/Columns/Os.php b/plugins/DevicesDetection/Columns/Os.php index f5ba2bf36d..80ef344194 100644 --- a/plugins/DevicesDetection/Columns/Os.php +++ b/plugins/DevicesDetection/Columns/Os.php @@ -43,9 +43,9 @@ class Os extends Base $segment->setSqlFilterValue(function ($val) { $oss = OperatingSystem::getAvailableOperatingSystems(); $oss = array_map(function($val) { - return Common::mb_strtolower($val); + return mb_strtolower($val); }, $oss); - $result = array_search(Common::mb_strtolower($val), $oss); + $result = array_search(mb_strtolower($val), $oss); if ($result === false) { $result = 'UNK'; diff --git a/plugins/Diagnostics/Diagnostic/PhpExtensionsCheck.php b/plugins/Diagnostics/Diagnostic/PhpExtensionsCheck.php index e5b5f654b8..469e19da4c 100644 --- a/plugins/Diagnostics/Diagnostic/PhpExtensionsCheck.php +++ b/plugins/Diagnostics/Diagnostic/PhpExtensionsCheck.php @@ -59,11 +59,7 @@ class PhpExtensionsCheck implements Diagnostic { $requiredExtensions = array( 'zlib', - 'SPL', - 'iconv', 'json', - 'mbstring', - 'Reflection', 'filter', 'hash', 'session', @@ -75,14 +71,10 @@ class PhpExtensionsCheck implements Diagnostic private function getHelpMessage($missingExtension) { $messages = array( - 'zlib' => 'Installation_SystemCheckZlibHelp', - 'SPL' => 'Installation_SystemCheckSplHelp', - 'iconv' => 'Installation_SystemCheckIconvHelp', - 'json' => 'Installation_SystemCheckWarnJsonHelp', - 'mbstring' => 'Installation_SystemCheckMbstringHelp', - 'Reflection' => 'Required extension that is built in PHP, see http://www.php.net/manual/en/book.reflection.php', - 'filter' => 'Installation_SystemCheckFilterHelp', - 'hash' => 'Installation_SystemCheckHashHelp', + 'zlib' => 'Installation_SystemCheckZlibHelp', + 'json' => 'Installation_SystemCheckWarnJsonHelp', + 'filter' => 'Installation_SystemCheckFilterHelp', + 'hash' => 'Installation_SystemCheckHashHelp', 'session' => 'Installation_SystemCheckSessionHelp' ); diff --git a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png index 9e1e93661d..217d467984 100644 --- a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png +++ b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcc30ea2194c731a6aaa48f51316ec58015cb1d14adf2025ade229dbc953b204 -size 460614 +oid sha256:6593a2ff32e777b2f1c0b0ae5f0726d6e2b13917bc3beae28e1824e44cee4675 +size 455930 diff --git a/plugins/GeoIp2/GeoIP2AutoUpdater.php b/plugins/GeoIp2/GeoIP2AutoUpdater.php index 90bc42ecc7..29bcafd975 100644 --- a/plugins/GeoIp2/GeoIP2AutoUpdater.php +++ b/plugins/GeoIp2/GeoIP2AutoUpdater.php @@ -463,7 +463,7 @@ class GeoIP2AutoUpdater extends Task $schema = $parsedUrl['scheme'] ?? ''; $host = $parsedUrl['host'] ?? ''; - if (empty($schema) || empty($host) || !in_array(Common::mb_strtolower($schema), ['http', 'https'])) { + if (empty($schema) || empty($host) || !in_array(mb_strtolower($schema), ['http', 'https'])) { throw new Exception(Piwik::translate('GeoIp2_MalFormedUpdateUrl', '<i>'.Common::sanitizeInputValue($url).'</i>')); } diff --git a/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php b/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php index 3bf1496d02..af73b1624c 100644 --- a/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php +++ b/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php @@ -274,7 +274,7 @@ class Php extends GeoIp2 } foreach ($regionNames[$countryCode] as $isoCode => $name) { - if (Common::mb_strtolower($name) === Common::mb_strtolower($regionName)) { + if (mb_strtolower($name) === mb_strtolower($regionName)) { return $isoCode; } } diff --git a/plugins/Installation/lang/en.json b/plugins/Installation/lang/en.json index 802e40dd28..fc31d0e1eb 100644 --- a/plugins/Installation/lang/en.json +++ b/plugins/Installation/lang/en.json @@ -95,11 +95,8 @@ "SystemCheckGzcompressHelp": "You need to enable the zlib extension and gzcompress function.", "SystemCheckGzuncompressHelp": "You need to enable the zlib extension and gzuncompress function.", "SystemCheckHashHelp": "You need to configure and rebuild PHP with hash() support enabled by excluding the option --disable-hash.", - "SystemCheckIconvHelp": "You need to configure and rebuild PHP with \"iconv\" support enabled, --with-iconv.", "SystemCheckJsonHelp": "The php-json extension is required for Matomo to read and write JSON data.", "SystemCheckMailHelp": "Feedback and Lost Password messages will not be sent without mail().", - "SystemCheckMbstring": "mbstring", - "SystemCheckMbstringHelp": "The mbstring extension is required to handle multibyte characters in the User interface and API responses. Also, please check that mbstring.func_overload is set to \"0\" in php.ini.", "SystemCheckMemoryLimit": "Memory limit", "SystemCheckMemoryLimitHelp": "On a high traffic website, the archiving process may require more memory than currently allowed. If necessary, change the memory_limit directive in your php.ini file.", "SystemCheckMemoryNoMemoryLimitSet": "There is no memory limit set", @@ -116,7 +113,6 @@ "SystemCheckPdoAndMysqliHelp": "On a GNU\/Linux server you can compile php with the following options: %1$s In your php.ini, add the following lines: %2$s", "SystemCheckPhp": "PHP version", "SystemCheckPhpPdoAndMysqli": "More information on: %1$sPHP PDO%2$s and %3$sMYSQLI%4$s.", - "SystemCheckSplHelp": "You need to configure and rebuild PHP with the Standard PHP Library (SPL) enabled (by default).", "SystemCheckSessionHelp": "You need to configure and rebuild PHP with \"session\" support enabled (don't use --disable-session).", "SystemCheckSettings": "Required PHP configuration (php.ini)", "SystemCheckSummaryNoProblems": "Huzzah! There are no problems with your Matomo setup. Give yourself a pat on the back.", diff --git a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png index b00f9225b7..0fb01dd2c2 100644 --- a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png +++ b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06e0d2d6da9a0b54d49aae32d0edb42e0110cb8626f8bd56c56a5e719bc8d815 -size 278939 +oid sha256:a0d013beb53d2028e736a45d5e9ee0a48878c0ecc1052603e5ce21ede5db45e9 +size 273869 diff --git a/plugins/Intl/Commands/GenerateIntl.php b/plugins/Intl/Commands/GenerateIntl.php index d69e8e573b..a2f35a92dd 100644 --- a/plugins/Intl/Commands/GenerateIntl.php +++ b/plugins/Intl/Commands/GenerateIntl.php @@ -58,7 +58,7 @@ class GenerateIntl extends ConsoleCommand } preg_match_all("~^(.)(.*)$~u", $str, $arr); - return Common::mb_strtoupper($arr[1][0]).$arr[2][0]; + return mb_strtoupper($arr[1][0]).$arr[2][0]; } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/plugins/MobileMessaging/SMSProvider.php b/plugins/MobileMessaging/SMSProvider.php index 297308b14a..fda7dcc2ec 100644 --- a/plugins/MobileMessaging/SMSProvider.php +++ b/plugins/MobileMessaging/SMSProvider.php @@ -217,7 +217,7 @@ abstract class SMSProvider private static function sizeOfSMSContent($smsContent, $containsUCS2Chars) { if ($containsUCS2Chars) { - return Common::mb_strlen($smsContent); + return mb_strlen($smsContent); } $sizeOfSMSContent = 0; diff --git a/plugins/Referrers/Columns/Base.php b/plugins/Referrers/Columns/Base.php index b4e840656d..838e1138a7 100644 --- a/plugins/Referrers/Columns/Base.php +++ b/plugins/Referrers/Columns/Base.php @@ -106,7 +106,7 @@ abstract class Base extends VisitDimension if (!$referrerDetected && !empty($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_WEBSITE; - $this->nameReferrerAnalyzed = Common::mb_strtolower($this->referrerHost); + $this->nameReferrerAnalyzed = mb_strtolower($this->referrerHost); $urlsByHost = $this->getCachedUrlsByHostAndIdSite(); @@ -421,8 +421,8 @@ abstract class Base extends VisitDimension // fallback logic if the referrer domain is not known to any site to not break BC if (!$excludeUnknowns && isset($this->currentUrlParse['host'])) { // this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site - $currentHost = Common::mb_strtolower($this->currentUrlParse['host']); - if ($currentHost == Common::mb_strtolower($this->referrerHost)) { + $currentHost = mb_strtolower($this->currentUrlParse['host']); + if ($currentHost == mb_strtolower($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } @@ -493,10 +493,10 @@ abstract class Base extends VisitDimension $this->detectCampaignKeywordFromReferrerUrl(); - $referrerNameAnalayzed = Common::mb_strtolower($this->nameReferrerAnalyzed); + $referrerNameAnalayzed = mb_strtolower($this->nameReferrerAnalyzed); $referrerNameAnalayzed = $this->truncateReferrerName($referrerNameAnalayzed); - $isCurrentVisitACampaignWithSameName = Common::mb_strtolower($visitor->getVisitorColumn('referer_name')) == $referrerNameAnalayzed; + $isCurrentVisitACampaignWithSameName = mb_strtolower($visitor->getVisitorColumn('referer_name')) == $referrerNameAnalayzed; $isCurrentVisitACampaignWithSameName = $isCurrentVisitACampaignWithSameName && $visitor->getVisitorColumn('referer_type') == Common::REFERRER_TYPE_CAMPAIGN; // if we detected a campaign but there is still no keyword set, we set the keyword to the Referrer host @@ -522,8 +522,8 @@ abstract class Base extends VisitDimension return false; } - $this->keywordReferrerAnalyzed = Common::mb_strtolower($this->keywordReferrerAnalyzed); - $this->nameReferrerAnalyzed = Common::mb_strtolower($this->nameReferrerAnalyzed); + $this->keywordReferrerAnalyzed = mb_strtolower($this->keywordReferrerAnalyzed); + $this->nameReferrerAnalyzed = mb_strtolower($this->nameReferrerAnalyzed); return true; } @@ -612,10 +612,10 @@ abstract class Base extends VisitDimension { if ($type === Common::REFERRER_TYPE_CAMPAIGN) { if (!empty($name)) { - $name = Common::mb_strtolower($name); + $name = mb_strtolower($name); } if (!empty($keyword)) { - $keyword = Common::mb_strtolower($keyword); + $keyword = mb_strtolower($keyword); } } } @@ -632,8 +632,8 @@ abstract class Base extends VisitDimension protected function hasReferrerColumnChanged(Visitor $visitor, $information, $infoName) { - $existing = Common::mb_strtolower($visitor->getVisitorColumn($infoName)); - $new = Common::mb_strtolower($information[$infoName]); + $existing = mb_strtolower($visitor->getVisitorColumn($infoName)); + $new = mb_strtolower($information[$infoName]); $result = $existing != $new; if ($result) { @@ -655,12 +655,12 @@ abstract class Base extends VisitDimension private function truncateReferrerName($name) { - return Common::mb_substr($name, 0, 255); + return mb_substr($name, 0, 255); } private function truncateReferrerKeyword($refererKeyword) { - return Common::mb_substr($refererKeyword, 0, 255); + return mb_substr($refererKeyword, 0, 255); } protected function isCurrentReferrerDirectEntry(Visitor $visitor) diff --git a/plugins/Referrers/Columns/ReferrerUrl.php b/plugins/Referrers/Columns/ReferrerUrl.php index 918e7d73fd..bf009484df 100644 --- a/plugins/Referrers/Columns/ReferrerUrl.php +++ b/plugins/Referrers/Columns/ReferrerUrl.php @@ -44,8 +44,8 @@ class ReferrerUrl extends Base private function trimUrl($url) { - if (!empty($url) && is_string($url) && Common::mb_strlen($url) > self::MAX_LEN) { - return Common::mb_substr($url, 0, self::MAX_LEN); + if (!empty($url) && is_string($url) && mb_strlen($url) > self::MAX_LEN) { + return mb_substr($url, 0, self::MAX_LEN); } return $url; } diff --git a/plugins/Referrers/SearchEngine.php b/plugins/Referrers/SearchEngine.php index f77bd2ab8f..8b94d02855 100644 --- a/plugins/Referrers/SearchEngine.php +++ b/plugins/Referrers/SearchEngine.php @@ -320,7 +320,7 @@ class SearchEngine extends Singleton if (!empty($definitions['charsets'])) { $key = $this->convertCharset($key, $definitions['charsets']); } - $key = Common::mb_strtolower($key); + $key = mb_strtolower($key); } return array( @@ -379,13 +379,9 @@ class SearchEngine extends Singleton */ protected function convertCharset($string, $charsets) { - if (function_exists('iconv') - && !empty($charsets) - ) { + if (!empty($charsets)) { $charset = $charsets[0]; - if (count($charsets) > 1 - && function_exists('mb_detect_encoding') - ) { + if (count($charsets) > 1) { $charset = mb_detect_encoding($string, $charsets); if ($charset === false) { $charset = $charsets[0]; diff --git a/plugins/ScheduledReports/Controller.php b/plugins/ScheduledReports/Controller.php index 3e79e35beb..8f60a4093a 100644 --- a/plugins/ScheduledReports/Controller.php +++ b/plugins/ScheduledReports/Controller.php @@ -40,7 +40,7 @@ class Controller extends \Piwik\Plugin\Controller $reportTypes = API::getReportTypes(); $reportTypeOptions = array(); foreach ($reportTypes as $reportType => $icon) { - $reportTypeOptions[$reportType] = Common::mb_strtoupper($reportType); + $reportTypeOptions[$reportType] = mb_strtoupper($reportType); } $view->reportTypes = $reportTypes; $view->reportTypeOptions = $reportTypeOptions; @@ -67,7 +67,7 @@ class Controller extends \Piwik\Plugin\Controller $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType); $reportFormatsByReportTypeOptions[$reportType] = $reportFormatsByReportType[$reportType]; foreach ($reportFormatsByReportTypeOptions[$reportType] as $type => $icon) { - $reportFormatsByReportTypeOptions[$reportType][$type] = Common::mb_strtoupper($type); + $reportFormatsByReportTypeOptions[$reportType][$type] = mb_strtoupper($type); } $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType); diff --git a/plugins/SegmentEditor/SegmentFormatter.php b/plugins/SegmentEditor/SegmentFormatter.php index 67c791b467..fe0ef7eac8 100644 --- a/plugins/SegmentEditor/SegmentFormatter.php +++ b/plugins/SegmentEditor/SegmentFormatter.php @@ -110,7 +110,7 @@ class SegmentFormatter $translation = Piwik::translate($this->matchesMetric[$operator]); } - return Common::mb_strtolower($translation); + return mb_strtolower($translation); } private function getFormattedValue($operand) diff --git a/plugins/SegmentEditor/SegmentSelectorControl.php b/plugins/SegmentEditor/SegmentSelectorControl.php index 411209f1b9..6aec61c51f 100644 --- a/plugins/SegmentEditor/SegmentSelectorControl.php +++ b/plugins/SegmentEditor/SegmentSelectorControl.php @@ -56,7 +56,7 @@ class SegmentSelectorControl extends UIControl if ($segment['category'] == $visitTitle && ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp') ) { - $metricsLabel = Common::mb_strtolower(Piwik::translate('General_Metrics')); + $metricsLabel = mb_strtolower(Piwik::translate('General_Metrics')); $segment['category'] .= ' (' . $metricsLabel . ')'; } $segmentsByCategory[$segment['category']][] = $segment; diff --git a/plugins/SitesManager/SiteUrls.php b/plugins/SitesManager/SiteUrls.php index 6e719ab7e8..2441b823fe 100644 --- a/plugins/SitesManager/SiteUrls.php +++ b/plugins/SitesManager/SiteUrls.php @@ -211,7 +211,7 @@ class SiteUrls private function toCanonicalHost($host) { - $host = Common::mb_strtolower($host); + $host = mb_strtolower($host); if (strpos($host, 'www.') === 0) { $host = substr($host, 4); } @@ -224,7 +224,7 @@ class SiteUrls $path = '/'; if (isset($urlParsed['path'])) { - $path = Common::mb_strtolower($urlParsed['path']); + $path = mb_strtolower($urlParsed['path']); if (!Common::stringEndsWith($path, '/')) { $path .= '/'; } diff --git a/plugins/TwoFactorAuth/Dao/RecoveryCodeDao.php b/plugins/TwoFactorAuth/Dao/RecoveryCodeDao.php index 4445edec07..10b2f6ef70 100644 --- a/plugins/TwoFactorAuth/Dao/RecoveryCodeDao.php +++ b/plugins/TwoFactorAuth/Dao/RecoveryCodeDao.php @@ -38,7 +38,7 @@ class RecoveryCodeDao for ($i = 0; $i < 10; $i++) { $code = $this->generator->generateCode(); - $code = Common::mb_strtoupper($code); + $code = mb_strtoupper($code); $this->insertRecoveryCode($login, $code); $codes[] = $code; } diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php index cc51316e33..d47292d09c 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php @@ -33,7 +33,7 @@ class RecoveryCodeRandomGeneratorTest extends IntegrationTestCase public function test_generatorCode_length() { - $this->assertSame(16, Common::mb_strlen($this->generator->generateCode())); + $this->assertSame(16, mb_strlen($this->generator->generateCode())); } public function test_generatorCode_alwaysDifferent() diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php index 1d5193208d..a5668ebb17 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php @@ -33,7 +33,7 @@ class RecoveryCodeStaticGeneratorTest extends IntegrationTestCase public function test_generatorCode_length() { - $this->assertSame(16, Common::mb_strlen($this->generator->generateCode())); + $this->assertSame(16, mb_strlen($this->generator->generateCode())); } public function test_generatorCode_alwaysDifferent() diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php index bdd847205e..6f04416457 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php @@ -33,7 +33,7 @@ class TwoFaSecretRandomGeneratorTest extends IntegrationTestCase public function test_generatorCode_length() { - $this->assertSame(16, Common::mb_strlen($this->generator->generateSecret())); + $this->assertSame(16, mb_strlen($this->generator->generateSecret())); } public function test_generatorCode_alwaysDifferent() diff --git a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php index 3b466e6a04..b4ede7e6ab 100644 --- a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php @@ -56,7 +56,7 @@ class TwoFactorAuthenticationTest extends IntegrationTestCase public function test_generateSecret() { - $this->assertSame(16, Common::mb_strlen($this->twoFa->generateSecret())); + $this->assertSame(16, mb_strlen($this->twoFa->generateSecret())); } public function test_isUserRequiredToHaveTwoFactorEnabled_notByDefault() diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index 559099245d..a8b57c5bc3 100644 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -667,7 +667,7 @@ class API extends \Piwik\Plugin\API throw new Exception(Piwik::translate('UsersManager_ExceptionEmailExists', $email)); } - if ($userLogin && Common::mb_strtolower($userLogin) !== Common::mb_strtolower($email) && $this->userExists($email)) { + if ($userLogin && mb_strtolower($userLogin) !== mb_strtolower($email) && $this->userExists($email)) { throw new Exception(Piwik::translate('UsersManager_ExceptionEmailExistsAsLogin', $email)); } @@ -937,7 +937,7 @@ class API extends \Piwik\Plugin\API $email = $userInfo['email']; } - $hasEmailChanged = Common::mb_strtolower($email) !== Common::mb_strtolower($userInfo['email']); + $hasEmailChanged = mb_strtolower($email) !== mb_strtolower($userInfo['email']); if ($hasEmailChanged) { $this->checkEmail($email, $userLogin); diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index 1475f93654..d7e61921ac 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -194,7 +194,7 @@ class UsersManager extends \Piwik\Plugin if (!self::isValidPasswordString($password)) { throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidPassword', array(self::PASSWORD_MIN_LENGTH))); } - if (Common::mb_strlen($password) > self::PASSWORD_MAX_LENGTH) { + if (mb_strlen($password) > self::PASSWORD_MAX_LENGTH) { throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidPasswordTooLong', array(self::PASSWORD_MAX_LENGTH))); } } diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index 436538b610..c8f5e68b47 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -928,6 +928,7 @@ class ReleaseCheckListTest extends \PHPUnit\Framework\TestCase || strpos($file, 'vendor/wikimedia/less.php/') !== false || strpos($file, 'node_modules/') !== false || strpos($file, 'vendor/mayflower/mo4-coding-standard/') !== false + || strpos($file, 'vendor/symfony/polyfill-iconv/') !== false || strpos($file, 'plugins/VisitorGenerator/vendor/fzaninotto/faker/src/Faker/Provider/') !== false) { continue; } |