Drop PHP 5.3 support

This commit is contained in:
Alexander A. Klimov 2017-12-15 11:17:07 +01:00 committed by Eric Lippmann
parent 4b7dc0c350
commit fc1f6e13ab
13 changed files with 63 additions and 127 deletions

View File

@ -9,16 +9,6 @@ php:
- '7.0' - '7.0'
- '7.1' - '7.1'
matrix:
include:
- php: '5.3'
dist: precise
sudo: required
env:
- PHPCS_VERSION=2.9.1
- LOCALE_GEN=1
- ENABLE_LDAP=1
services: services:
- mysql - mysql
- postgresql - postgresql

View File

@ -30,15 +30,6 @@ class WebCommand extends Command
*/ */
public function serveAction() public function serveAction()
{ {
$minVersion = '5.4.0';
if (version_compare(PHP_VERSION, $minVersion) < 0) {
throw new IcingaException(
'You are running PHP %s, internal webserver requires %s.',
PHP_VERSION,
$minVersion
);
}
$fork = $this->params->get('daemonize'); $fork = $this->params->get('daemonize');
$listen = $this->params->get('listen'); $listen = $this->params->get('listen');
$port = $this->params->get('port'); $port = $this->params->get('port');

View File

@ -46,7 +46,6 @@ class DbResourceForm extends Form
$dbChoices['oci'] = 'Oracle (OCI8)'; $dbChoices['oci'] = 'Oracle (OCI8)';
} }
$offerSsl = false;
$offerPostgres = false; $offerPostgres = false;
$offerIbm = false; $offerIbm = false;
$offerMysql = false; $offerMysql = false;
@ -55,9 +54,6 @@ class DbResourceForm extends Form
$offerPostgres = true; $offerPostgres = true;
} elseif ($dbChoice === 'mysql') { } elseif ($dbChoice === 'mysql') {
$offerMysql = true; $offerMysql = true;
if (version_compare(Platform::getPhpVersion(), '5.4.0', '>=')) {
$offerSsl = true;
}
} elseif ($dbChoice === 'ibm') { } elseif ($dbChoice === 'ibm') {
$offerIbm = true; $offerIbm = true;
} }
@ -161,62 +157,60 @@ class DbResourceForm extends Form
'label' => $this->translate('Persistent') 'label' => $this->translate('Persistent')
) )
); );
if ($offerSsl) { $this->addElement(
'checkbox',
'use_ssl',
array(
'autosubmit' => true,
'label' => $this->translate('Use SSL'),
'description' => $this->translate(
'Whether to encrypt the connection or to authenticate using certificates'
)
)
);
if (isset($formData['use_ssl']) && $formData['use_ssl']) {
$this->addElement( $this->addElement(
'checkbox', 'text',
'use_ssl', 'ssl_key',
array( array(
'autosubmit' => true, 'label' => $this->translate('SSL Key'),
'label' => $this->translate('Use SSL'), 'description' => $this->translate('The client key file path')
'description' => $this->translate( )
'Whether to encrypt the connection or to authenticate using certificates' );
$this->addElement(
'text',
'ssl_cert',
array(
'label' => $this->translate('SSL Certificate'),
'description' => $this->translate('The certificate file path')
)
);
$this->addElement(
'text',
'ssl_ca',
array(
'label' => $this->translate('SSL CA'),
'description' => $this->translate('The CA certificate file path')
)
);
$this->addElement(
'text',
'ssl_capath',
array(
'label' => $this->translate('SSL CA Path'),
'description' => $this->translate(
'The trusted CA certificates in PEM format directory path'
) )
) )
); );
if (isset($formData['use_ssl']) && $formData['use_ssl']) { $this->addElement(
$this->addElement( 'text',
'text', 'ssl_cipher',
'ssl_key', array(
array( 'label' => $this->translate('SSL Cipher'),
'label' => $this->translate('SSL Key'), 'description' => $this->translate('The list of permissible ciphers')
'description' => $this->translate('The client key file path') )
) );
);
$this->addElement(
'text',
'ssl_cert',
array(
'label' => $this->translate('SSL Certificate'),
'description' => $this->translate('The certificate file path')
)
);
$this->addElement(
'text',
'ssl_ca',
array(
'label' => $this->translate('SSL CA'),
'description' => $this->translate('The CA certificate file path')
)
);
$this->addElement(
'text',
'ssl_capath',
array(
'label' => $this->translate('SSL CA Path'),
'description' => $this->translate(
'The trusted CA certificates in PEM format directory path'
)
)
);
$this->addElement(
'text',
'ssl_cipher',
array(
'label' => $this->translate('SSL Cipher'),
'description' => $this->translate('The list of permissible ciphers')
)
);
}
} }
return $this; return $this;

View File

@ -374,13 +374,7 @@ class Donut
protected function encode($content) protected function encode($content)
{ {
if (version_compare(PHP_VERSION, '5.4.0') >= 0) { return htmlspecialchars($content, ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8', true);
$replaceFlags = ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5;
} else {
$replaceFlags = ENT_COMPAT | ENT_IGNORE;
}
return htmlspecialchars($content, $replaceFlags, 'UTF-8', true);
} }
protected function renderAttributes(array $attributes) protected function renderAttributes(array $attributes)

View File

@ -98,7 +98,7 @@ abstract class Filter
} }
} }
krsort($operators, version_compare(PHP_VERSION, '5.4.0') >= 0 ? SORT_NATURAL : SORT_REGULAR); krsort($operators, SORT_NATURAL);
foreach ($operators as $id => $operator) { foreach ($operators as $id => $operator) {
$f = $filter->getById($id); $f = $filter->getById($id);
if ($f->getOperatorName() !== $operator) { if ($f->getOperatorName() !== $operator) {

View File

@ -427,10 +427,7 @@ class LdapConnection implements Selectable, Inspectable
{ {
$this->bind(); $this->bind();
if ($query->getUsePagedResults() if ($query->getUsePagedResults() && $this->getCapabilities()->hasPagedResult()) {
&& version_compare(PHP_VERSION, '5.4.0') >= 0
&& $this->getCapabilities()->hasPagedResult()
) {
return $this->runPagedQuery($query, $fields); return $this->runPagedQuery($query, $fields);
} else { } else {
return $this->runQuery($query, $fields); return $this->runQuery($query, $fields);
@ -1156,11 +1153,7 @@ class LdapConnection implements Selectable, Inspectable
$sequenceOf = '30' . str_pad(dechex($sequenceOfOctets), 2, '0', STR_PAD_LEFT) . $sequenceOf; $sequenceOf = '30' . str_pad(dechex($sequenceOfOctets), 2, '0', STR_PAD_LEFT) . $sequenceOf;
} }
if (version_compare(PHP_VERSION, '5.4.0') >= 0) { return hex2bin($sequenceOf);
return hex2bin($sequenceOf);
} else {
return pack('H*', $sequenceOf);
}
} }
/** /**

View File

@ -23,9 +23,7 @@ class Json
*/ */
public static function encode($value, $options = 0, $depth = 512) public static function encode($value, $options = 0, $depth = 512)
{ {
if (version_compare(phpversion(), '5.4.0', '<')) { if (version_compare(phpversion(), '5.5.0', '<')) {
$encoded = json_encode($value);
} elseif (version_compare(phpversion(), '5.5.0', '<')) {
$encoded = json_encode($value, $options); $encoded = json_encode($value, $options);
} else { } else {
$encoded = json_encode($value, $options, $depth); $encoded = json_encode($value, $options, $depth);
@ -49,11 +47,7 @@ class Json
*/ */
public static function decode($json, $assoc = false, $depth = 512, $options = 0) public static function decode($json, $assoc = false, $depth = 512, $options = 0)
{ {
if (version_compare(phpversion(), '5.4.0', '<')) { $decoded = json_decode($json, $assoc, $depth, $options);
$decoded = json_decode($json, $assoc, $depth);
} else {
$decoded = json_decode($json, $assoc, $depth, $options);
}
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true)); throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true));

View File

@ -80,10 +80,6 @@ class StyleSheet
*/ */
public function __construct() public function __construct()
{ {
// PHP had a rather conservative PCRE backtrack limit unless 5.3.7
if (version_compare(PHP_VERSION, '5.3.7') <= 0) {
ini_set('pcre.backtrack_limit', 1000000);
}
$app = Icinga::app(); $app = Icinga::app();
$this->app = $app; $this->app = $app;
$this->lessCompiler = new LessCompiler(); $this->lessCompiler = new LessCompiler();

View File

@ -58,11 +58,6 @@ class View extends Zend_View_Abstract
*/ */
const CHARSET = 'UTF-8'; const CHARSET = 'UTF-8';
/**
* The flags we use for htmlspecialchars depend on our PHP version
*/
private $replaceFlags;
/** /**
* Flag to register stream wrapper * Flag to register stream wrapper
* *
@ -97,12 +92,6 @@ class View extends Zend_View_Abstract
} }
} }
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$this->replaceFlags = ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5;
} else {
$this->replaceFlags = ENT_COMPAT | ENT_IGNORE;
}
parent::__construct($config); parent::__construct($config);
} }
@ -124,7 +113,7 @@ class View extends Zend_View_Abstract
*/ */
public function escape($value) public function escape($value)
{ {
return htmlspecialchars($value, $this->replaceFlags, self::CHARSET, true); return htmlspecialchars($value, ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5, self::CHARSET, true);
} }
/** /**

View File

@ -668,7 +668,7 @@ class FilterEditor extends AbstractWidget
} }
} }
krsort($operators, version_compare(PHP_VERSION, '5.4.0') >= 0 ? SORT_NATURAL : SORT_REGULAR); krsort($operators, SORT_NATURAL);
foreach ($operators as $id => $operator) { foreach ($operators as $id => $operator) {
$f = $filter->getById($id); $f = $filter->getById($id);
if ($f->getOperatorName() !== $operator) { if ($f->getOperatorName() !== $operator) {

View File

@ -884,11 +884,9 @@ msgstr "Root DN"
#: ../../../../modules/setup/library/Setup/WebWizard.php:556 #: ../../../../modules/setup/library/Setup/WebWizard.php:556
msgid "" msgid ""
"Running Icinga Web 2 requires PHP version 5.3.2. Advanced features like the " "Running Icinga Web 2 requires PHP version 5.4."
"built-in web server require PHP version 5.4."
msgstr "" msgstr ""
"Der Betrieb von Icinga Web 2 erfordert die PHP-Version 5.3.2. Anspruchsvolle " "Der Betrieb von Icinga Web 2 erfordert die PHP-Version 5.4."
"Funktionalitäten wie der eingebaute Webserver erfordern die PHP-Version 5.4."
#: ../../../../modules/setup/library/Setup/Steps/ResourceStep.php:104 #: ../../../../modules/setup/library/Setup/Steps/ResourceStep.php:104
msgid "SSL Cert" msgid "SSL Cert"

View File

@ -862,11 +862,9 @@ msgstr "Root DN"
#: /usr/share/icingaweb2/modules/setup/library/Setup/WebWizard.php:552 #: /usr/share/icingaweb2/modules/setup/library/Setup/WebWizard.php:552
msgid "" msgid ""
"Running Icinga Web 2 requires PHP version 5.3.2. Advanced features like the " "Running Icinga Web 2 requires PHP version 5.4."
"built-in web server require PHP version 5.4."
msgstr "" msgstr ""
"Icinga Web 2 richiede PHP 5.3.2. Funzionalità avanzate come il web server " "Icinga Web 2 richiede PHP 5.4."
"integrato richiedono PHP 5.4."
#: /usr/share/icingaweb2/modules/setup/library/Setup/WebWizard.php:356 #: /usr/share/icingaweb2/modules/setup/library/Setup/WebWizard.php:356
msgid "Setup Icinga Web 2" msgid "Setup Icinga Web 2"

View File

@ -568,11 +568,10 @@ class WebWizard extends Wizard implements SetupWizard
$set = new RequirementSet(); $set = new RequirementSet();
$set->add(new PhpVersionRequirement(array( $set->add(new PhpVersionRequirement(array(
'condition' => array('>=', '5.3.2'), 'condition' => array('>=', '5.4'),
'description' => mt( 'description' => mt(
'setup', 'setup',
'Running Icinga Web 2 requires PHP version 5.3.2. Advanced features' 'Running Icinga Web 2 requires PHP version 5.4.'
. ' like the built-in web server require PHP version 5.4.'
) )
))); )));