Skip to content

Commit

Permalink
Merge branch 'next_release' into inviteuserfix
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jul 8, 2022
2 parents bbb808f + 49adc21 commit 3dcbc92
Showing 1 changed file with 59 additions and 25 deletions.
84 changes: 59 additions & 25 deletions core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php

/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

namespace Piwik\Plugin;

use Piwik\Config as PiwikConfig;
use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Date;
use Piwik\Development;
use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuTop;
Expand Down Expand Up @@ -103,18 +106,18 @@ private static function notifyAnyInvalidPlugin()
return;
}

$pluginsLink = Url::getCurrentQueryStringWithParametersModified(array(
$pluginsLink = Url::getCurrentQueryStringWithParametersModified([
'module' => 'CorePluginsAdmin', 'action' => 'plugins'
));
]);

$invalidPluginsWarning = Piwik::translate('CoreAdminHome_InvalidPluginsWarning', array(
$invalidPluginsWarning = Piwik::translate('CoreAdminHome_InvalidPluginsWarning', [
self::getPiwikVersion(),
'<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>'))
'<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>'])
. "<br/>"
. Piwik::translate('CoreAdminHome_InvalidPluginsYouCanUninstall', array(
. Piwik::translate('CoreAdminHome_InvalidPluginsYouCanUninstall', [
'<a href="' . $pluginsLink . '"/>',
'</a>'
));
]);

$notification = new Notification($invalidPluginsWarning);
$notification->raw = true;
Expand Down Expand Up @@ -161,9 +164,10 @@ private static function notifyIfURLIsNotSecure()

$message .= " ";

$message .= Piwik::translate('General_ReadThisToLearnMore',
array('<a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/how-to/faq_91/">', '</a>')
);
$message .= Piwik::translate(
'General_ReadThisToLearnMore',
['<a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/how-to/faq_91/">', '</a>']
);

$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
Expand Down Expand Up @@ -219,10 +223,13 @@ private static function notifyIfEAcceleratorIsUsed()
if (empty($isEacceleratorUsed)) {
return;
}
$message = sprintf("You are using the PHP accelerator & optimizer eAccelerator which is known to be not compatible with Matomo.
$message = sprintf(
"You are using the PHP accelerator & optimizer eAccelerator which is known to be not compatible with Matomo.
We have disabled eAccelerator, which might affect the performance of Matomo.
Read the %srelated ticket%s for more information and how to fix this problem.",
'<a rel="noreferrer noopener" target="_blank" href="https://github.com/matomo-org/matomo/issues/4439">', '</a>');
'<a rel="noreferrer noopener" target="_blank" href="https://github.com/matomo-org/matomo/issues/4439">',
'</a>'
);

$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
Expand All @@ -241,7 +248,7 @@ private static function getNextRequiredMinimumPHP()

private static function isUsingPhpVersionCompatibleWithNextPiwik()
{
return version_compare( PHP_VERSION, self::getNextRequiredMinimumPHP(), '>=' );
return version_compare(PHP_VERSION, self::getNextRequiredMinimumPHP(), '>=');
}

private static function notifyWhenPhpVersionIsNotCompatibleWithNextMajorPiwik()
Expand Down Expand Up @@ -271,15 +278,23 @@ private static function notifyWhenPhpVersionIsEOL()
return;
}

$notifyPhpIsEOL = Piwik::hasUserSuperUserAccess() && ! self::isPhpVersionAtLeast71();
$notifyPhpIsEOL = Piwik::hasUserSuperUserAccess() && self::isPhpVersionEOL();
if (!$notifyPhpIsEOL) {
return;
}

$deprecatedMajorPhpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
$message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', array($deprecatedMajorPhpVersion, self::getNextRequiredMinimumPHP()))
. "<br/> "
. Piwik::translate('General_WarningPhpVersionXIsTooOld', $deprecatedMajorPhpVersion);

$message = '';

if (version_compare(PHP_VERSION, self::getNextRequiredMinimumPHP(), '<')) {
$message = Piwik::translate(
'General_WarningPiwikWillStopSupportingPHPVersion',
[$deprecatedMajorPhpVersion, self::getNextRequiredMinimumPHP()]
) . '<br/>';
}

$message .= Piwik::translate('General_WarningPhpVersionXIsTooOld', $deprecatedMajorPhpVersion);

$notification = new Notification($message);
$notification->raw = true;
Expand All @@ -288,18 +303,24 @@ private static function notifyWhenPhpVersionIsEOL()
$notification->context = Notification::CONTEXT_WARNING;
$notification->type = Notification::TYPE_TRANSIENT;
$notification->flags = Notification::FLAG_NO_CLEAR;
NotificationManager::notify('PHP71VersionCheck', $notification);
NotificationManager::notify('PHPVersionCheck', $notification);
}

private static function notifyWhenDebugOnDemandIsEnabled($trackerSetting)
{
if (!Development::isEnabled()
&& Piwik::hasUserSuperUserAccess() &&
TrackerConfig::getConfigValue($trackerSetting)) {

if (
!Development::isEnabled()
&& Piwik::hasUserSuperUserAccess()
&& TrackerConfig::getConfigValue($trackerSetting)
) {
$message = Piwik::translate('General_WarningDebugOnDemandEnabled');
$message = sprintf($message, '"' . $trackerSetting . '"', '"[Tracker] ' . $trackerSetting . '"', '"0"',
'"config/config.ini.php"');
$message = sprintf(
$message,
'"' . $trackerSetting . '"',
'"[Tracker] ' . $trackerSetting . '"',
'"0"',
'"config/config.ini.php"'
);
$notification = new Notification($message);
$notification->title = Piwik::translate('General_Warning');
$notification->priority = Notification::PRIORITY_LOW;
Expand Down Expand Up @@ -398,8 +419,21 @@ protected static function getPiwikVersion()
return "Matomo " . Version::VERSION;
}

private static function isPhpVersionAtLeast71()
private static function isPhpVersionEOL()
{
return version_compare(PHP_VERSION, '7.1', '>=');
$phpEOL = '7.3';

// End of security update for certain PHP versions as of https://www.php.net/supported-versions.php
if (Date::today()->isLater(Date::factory('2022-11-28'))) {
$phpEOL = '7.4';
}
if (Date::today()->isLater(Date::factory('2023-11-26'))) {
$phpEOL = '8.0';
}
if (Date::today()->isLater(Date::factory('2024-11-25'))) {
$phpEOL = '8.1';
}

return version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, $phpEOL, '<=');
}
}

0 comments on commit 3dcbc92

Please sign in to comment.