Skip to content

Commit

Permalink
Cleanup legacy PHP version references (#16359)
Browse files Browse the repository at this point in the history
* Remove PHP version specific fixes lower than the current minimum supported PHP version (7.2.5).

* Check for the correct current minimum supported PHP version (7.2.5)
  • Loading branch information
JoshuaLuckers authored Jan 26, 2023
1 parent 8b4b8b3 commit 5a90dc5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 49 deletions.
6 changes: 3 additions & 3 deletions core/src/Revolution/Processors/System/ConfigCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public function checkRemoteAccess()

public function checkSystem()
{
$require = $this->modx->getOption('configcheck_min_phpversion', null, '5.6');
$require = $this->modx->getOption('configcheck_min_phpversion', null, '7.2.5');

$compare = version_compare(PHP_VERSION, $require);
if ($compare === -1) {
$compare = version_compare(PHP_VERSION, $require, '>=');
if (!$compare) {
$this->warnings[$this->modx->lexicon('configcheck_phpversion')] = $this->modx->lexicon('configcheck_phpversion_msg',
[
'phpversion' => PHP_VERSION,
Expand Down
5 changes: 0 additions & 5 deletions core/src/Revolution/modPhpThumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public function __construct(modX &$modx, array $config = [])
$this->modx =& $modx;
$this->config = $config;

if (version_compare(PHP_VERSION, '7.0.10', '<')) {
// The constant IMG_WEBP is available as of PHP 7.0.10, respectively.
define('IMG_WEBP', 32);
}

parent::__construct();
}

Expand Down
52 changes: 14 additions & 38 deletions core/src/Revolution/modX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1681,11 +1681,7 @@ public function invokeEvent($eventName, array $params= []) {
foreach ($this->eventMap[$eventName] as $pluginId => $pluginPropset) {
/** @var modPlugin $plugin */
$plugin= null;
if (!version_compare(PHP_VERSION, '5.4', '>=')) {
$this->Event = & $this->event;
} else {
$this->Event = clone $this->event;
}
$this->Event = clone $this->event;
$this->event->resetEventObject();
$this->event->name= $eventName;
if (isset ($this->pluginCache[$pluginId])) {
Expand Down Expand Up @@ -2791,27 +2787,19 @@ protected function _initSession($options = null) {
}
$site_sessionname = $this->getOption('session_name', $options, '');
if (!empty($site_sessionname)) session_name($site_sessionname);
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params(
$cookieLifetime,
$cookiePath,
$cookieDomain,
$cookieSecure,
$cookieHttpOnly
);
} else {
$cookie_params = [
'lifetime' => $cookieLifetime,
'path' => $cookiePath,
'domain' => $cookieDomain,
'secure' => $cookieSecure,
'httponly' => $cookieHttpOnly
];
if ($cookieSamesite !== '') {
$cookie_params['samesite'] = $cookieSamesite;
}
session_set_cookie_params($cookie_params);

$cookie_params = [
'lifetime' => $cookieLifetime,
'path' => $cookiePath,
'domain' => $cookieDomain,
'secure' => $cookieSecure,
'httponly' => $cookieHttpOnly
];
if ($cookieSamesite !== '') {
$cookie_params['samesite'] = $cookieSamesite;
}
session_set_cookie_params($cookie_params);

if ($this->getOption('anonymous_sessions', $options, true) || isset($_COOKIE[session_name()])) {
if (!$this->startSession()) {
$this->log(modX::LOG_LEVEL_ERROR, 'Unable to initialize a session', '', __METHOD__, __FILE__, __LINE__);
Expand All @@ -2836,19 +2824,7 @@ protected function _initSession($options = null) {
if ($cookieSamesite !== '') {
$cookie_settings['samesite'] = $cookieSamesite;
}
if (PHP_VERSION_ID < 70300) {
setcookie(
session_name(),
session_id(),
$cookieExpiration,
$cookiePath,
$cookieDomain,
$cookieSecure,
$cookieHttpOnly
);
} else {
setcookie(session_name(), session_id(), $cookie_settings);
}
setcookie(session_name(), session_id(), $cookie_settings);
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions manager/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
}

/* check for correct version of php */
$php_ver_comp = version_compare(phpversion(),'7.0');
if ($php_ver_comp < 0) {
die('Wrong php version! You\'re using PHP version "'.phpversion().'", and MODX Revolution only works on 7.0 or higher.');
$php_ver_comp = version_compare(PHP_VERSION,'7.2.5', '>=');
if (!$php_ver_comp) {
die('Wrong php version! You\'re using PHP version "'.PHP_VERSION.'", and MODX Revolution only works on 7.2.5 or higher.');
}

/* set the document_root */
Expand Down

0 comments on commit 5a90dc5

Please sign in to comment.