Merge pull request #4013 from Icinga/feature/support-for-php-7.4-4009

Support for PHP 7.4
This commit is contained in:
Johannes Meyer 2019-12-04 11:35:04 +01:00 committed by GitHub
commit 3900929a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 94 additions and 100 deletions

View File

@ -1,13 +1,13 @@
language: php language: php
dist: trusty dist: xenial
sudo: false sudo: false
php: php:
- '5.6' - '5.6'
- '7.0'
- '7.1' - '7.1'
- '7.2' - '7.2'
- '7.3' - '7.3'
- '7.4'
- nightly - nightly
env: env:
@ -15,18 +15,26 @@ env:
matrix: matrix:
include: include:
- env: CHECK=phpcs
php: '7.4'
- env: CHECK=phpcs - env: CHECK=phpcs
php: '7.3' php: '7.3'
- env: CHECK=phpcs - env: CHECK=phpcs
php: '7.0' php: '7.2'
- env: CHECK=phpcs
php: '7.1'
- env: CHECK=phpcs - env: CHECK=phpcs
php: '5.6' php: '5.6'
- env: CHECK=syntax - env: CHECK=syntax
php: 'nightly' php: 'nightly'
- env: CHECK=syntax
php: '7.4'
- env: CHECK=syntax - env: CHECK=syntax
php: '7.3' php: '7.3'
- env: CHECK=syntax - env: CHECK=syntax
php: '7.0' php: '7.2'
- env: CHECK=syntax
php: '7.1'
- env: CHECK=syntax - env: CHECK=syntax
php: '5.6' php: '5.6'
allow_failures: allow_failures:

View File

@ -297,7 +297,9 @@ class Donut
'r' => sprintf('%F', $this->radius), 'r' => sprintf('%F', $this->radius),
'fill' => 'transparent', 'fill' => 'transparent',
'stroke-width' => $this->getThickness(), 'stroke-width' => $this->getThickness(),
'stroke-dasharray' => sprintf('%F', $slice[0]) . ' ' . sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap) 'stroke-dasharray' => sprintf('%F', $slice[0])
. ' '
. sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap)
'stroke-dashoffset' => sprintf('%F', $offset) 'stroke-dashoffset' => sprintf('%F', $offset)
) )
); );

View File

@ -889,13 +889,17 @@ class LdapConnection implements Selectable, Inspectable
} }
} }
$legacyControlHandling = version_compare(PHP_VERSION, '7.3.0') < 0;
$count = 0; $count = 0;
$cookie = ''; $cookie = '';
$entries = array(); $entries = array();
do { do {
if ($legacyControlHandling) {
// Do not request the pagination control as a critical extension, as we want the // Do not request the pagination control as a critical extension, as we want the
// server to return results even if the paged search request cannot be satisfied // server to return results even if the paged search request cannot be satisfied
ldap_control_paged_result($ds, $pageSize, false, $cookie); ldap_control_paged_result($ds, $pageSize, false, $cookie);
}
if ($serverSorting && $query->hasOrder()) { if ($serverSorting && $query->hasOrder()) {
ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array( ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array(
@ -910,7 +914,10 @@ class LdapConnection implements Selectable, Inspectable
$query, $query,
array_values($fields), array_values($fields),
0, 0,
($serverSorting || ! $query->hasOrder()) && $limit ? $offset + $limit : 0 ($serverSorting || ! $query->hasOrder()) && $limit ? $offset + $limit : 0,
0,
LDAP_DEREF_NEVER,
$legacyControlHandling ? null : $pageSize
); );
if ($results === false) { if ($results === false) {
if (ldap_errno($ds) === self::LDAP_NO_SUCH_OBJECT) { if (ldap_errno($ds) === self::LDAP_NO_SUCH_OBJECT) {
@ -976,7 +983,7 @@ class LdapConnection implements Selectable, Inspectable
&& ($entry = ldap_next_entry($ds, $entry)) && ($entry = ldap_next_entry($ds, $entry))
); );
if (false === @ldap_control_paged_result_response($ds, $results, $cookie)) { if ($legacyControlHandling && false === @ldap_control_paged_result_response($ds, $results, $cookie)) {
// If the page size is greater than or equal to the sizeLimit value, the server should ignore the // If the page size is greater than or equal to the sizeLimit value, the server should ignore the
// control as the request can be satisfied in a single page: https://www.ietf.org/rfc/rfc2696.txt // control as the request can be satisfied in a single page: https://www.ietf.org/rfc/rfc2696.txt
// This applies no matter whether paged search requests are permitted or not. You're done once you // This applies no matter whether paged search requests are permitted or not. You're done once you
@ -993,7 +1000,7 @@ class LdapConnection implements Selectable, Inspectable
ldap_free_result($results); ldap_free_result($results);
} while ($cookie && (! $serverSorting || $limit === 0 || count($entries) < $limit)); } while ($cookie && (! $serverSorting || $limit === 0 || count($entries) < $limit));
if ($cookie) { if ($legacyControlHandling && $cookie) {
// A sequence of paged search requests is abandoned by the client sending a search request containing a // A sequence of paged search requests is abandoned by the client sending a search request containing a
// pagedResultsControl with the size set to zero (0) and the cookie set to the last cookie returned by // pagedResultsControl with the size set to zero (0) and the cookie set to the last cookie returned by
// the server: https://www.ietf.org/rfc/rfc2696.txt // the server: https://www.ietf.org/rfc/rfc2696.txt
@ -1219,6 +1226,7 @@ class LdapConnection implements Selectable, Inspectable
* @param int $sizelimit Enables you to limit the count of entries fetched * @param int $sizelimit Enables you to limit the count of entries fetched
* @param int $timelimit Sets the number of seconds how long is spend on the search * @param int $timelimit Sets the number of seconds how long is spend on the search
* @param int $deref * @param int $deref
* @param int $pageSize The page size to request (Only supported with PHP v7.3+)
* *
* @return resource|bool A search result identifier or false on error * @return resource|bool A search result identifier or false on error
* *
@ -1230,7 +1238,8 @@ class LdapConnection implements Selectable, Inspectable
$attrsonly = 0, $attrsonly = 0,
$sizelimit = 0, $sizelimit = 0,
$timelimit = 0, $timelimit = 0,
$deref = LDAP_DEREF_NEVER $deref = LDAP_DEREF_NEVER,
$pageSize = null
) { ) {
$queryString = (string) $query; $queryString = (string) $query;
$baseDn = $query->getBase() ?: $this->getDn(); $baseDn = $query->getBase() ?: $this->getDn();
@ -1285,6 +1294,20 @@ class LdapConnection implements Selectable, Inspectable
throw new LogicException('LDAP scope %s not supported by ldapSearch', $scope); throw new LogicException('LDAP scope %s not supported by ldapSearch', $scope);
} }
$serverctrls = [];
if ($pageSize !== null) {
$serverctrls[] = [
'oid' => LDAP_CONTROL_PAGEDRESULTS,
// Do not request the pagination control as a critical extension, as we want the
// server to return results even if the paged search request cannot be satisfied
'iscritical' => false,
'value' => [
'size' => $pageSize,
'cookie' => ''
]
];
}
return @$function( return @$function(
$this->getConnection(), $this->getConnection(),
$baseDn, $baseDn,
@ -1293,7 +1316,8 @@ class LdapConnection implements Selectable, Inspectable
$attrsonly, $attrsonly,
$sizelimit, $sizelimit,
$timelimit, $timelimit,
$deref $deref,
$serverctrls
); );
} }

View File

@ -59,13 +59,6 @@ class View extends Zend_View_Abstract
*/ */
const CHARSET = 'UTF-8'; const CHARSET = 'UTF-8';
/**
* Flag to register stream wrapper
*
* @var bool
*/
private $useViewStream = false;
/** /**
* Registered helper functions * Registered helper functions
*/ */
@ -86,13 +79,6 @@ class View extends Zend_View_Abstract
*/ */
public function __construct($config = array()) public function __construct($config = array())
{ {
$this->useViewStream = (bool) ini_get('short_open_tag') ? false : true;
if ($this->useViewStream) {
if (!in_array('zend.view', stream_get_wrappers())) {
stream_wrapper_register('zend.view', '\Icinga\Web\ViewStream');
}
}
$config['helperPath']['Icinga\\Web\\View\\Helper\\'] = Icinga::app()->getLibraryDir('Icinga/Web/View/Helper'); $config['helperPath']['Icinga\\Web\\View\\Helper\\'] = Icinga::app()->getLibraryDir('Icinga/Web/View/Helper');
parent::__construct($config); parent::__construct($config);
@ -258,12 +244,9 @@ class View extends Zend_View_Abstract
// Exporting global variables to view scripts: // Exporting global variables to view scripts:
$$k = $v; $$k = $v;
} }
if ($this->useViewStream) {
include 'zend.view://' . func_get_arg(0);
} else {
include func_get_arg(0); include func_get_arg(0);
} }
}
/** /**
* Accesses a helper object from within a script * Accesses a helper object from within a script

View File

@ -1,13 +0,0 @@
<?php
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
namespace Icinga\Web;
use Zend_View_Stream;
/**
* Is used in Icinga\Web\View to imitate PHP's short_open_tag
*/
class ViewStream extends Zend_View_Stream
{
}

View File

@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex() protected function _compileRegex()
{ {
$raw = str_replace(' ', '', $this->dtd_regex); $raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') { if ($raw[0] != '(') {
$raw = "($raw)"; $raw = "($raw)";
} }
$el = '[#a-zA-Z0-9_.-]+'; $el = '[#a-zA-Z0-9_.-]+';

View File

@ -159,7 +159,7 @@ class HTMLPurifier_Encoder
$len = strlen($str); $len = strlen($str);
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
$in = ord($str{$i}); $in = ord($str[$i]);
$char .= $str[$i]; // append byte to char $char .= $str[$i]; // append byte to char
if (0 == $mState) { if (0 == $mState) {
// When mState is zero we expect either a US-ASCII character // When mState is zero we expect either a US-ASCII character

View File

@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) { if (isset($attr['size'])) {
// normalize large numbers // normalize large numbers
if ($attr['size'] !== '') { if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size']; $size = (int)$attr['size'];
if ($size < -2) { if ($size < -2) {
$attr['size'] = '-2'; $attr['size'] = '-2';

View File

@ -227,7 +227,7 @@ class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract
for ($i = 0; $i < $zip->numFiles; $i++) { for ($i = 0; $i < $zip->numFiles; $i++) {
$statIndex = $zip->statIndex($i); $statIndex = $zip->statIndex($i);
$currName = $statIndex['name']; $currName = $statIndex['name'];
if (($currName{0} == '/') || if (($currName[0] == '/') ||
(substr($currName, 0, 2) == '..') || (substr($currName, 0, 2) == '..') ||
(substr($currName, 0, 4) == './..') (substr($currName, 0, 4) == './..')
) )

View File

@ -317,7 +317,7 @@ class Zend_Json_Decoder
$i = $this->_offset; $i = $this->_offset;
$start = $i; $start = $i;
switch ($str{$i}) { switch ($str[$i]) {
case '{': case '{':
$this->_token = self::LBRACE; $this->_token = self::LBRACE;
break; break;
@ -344,14 +344,14 @@ class Zend_Json_Decoder
break; break;
} }
$chr = $str{$i}; $chr = $str[$i];
if ($chr == '\\') { if ($chr == '\\') {
$i++; $i++;
if ($i >= $str_length) { if ($i >= $str_length) {
break; break;
} }
$chr = $str{$i}; $chr = $str[$i];
switch ($chr) { switch ($chr) {
case '"' : case '"' :
$result .= '"'; $result .= '"';
@ -423,7 +423,7 @@ class Zend_Json_Decoder
return($this->_token); return($this->_token);
} }
$chr = $str{$i}; $chr = $str[$i];
if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) { if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) {
if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s', if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s',
$str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) { $str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) {
@ -483,7 +483,7 @@ class Zend_Json_Decoder
$i += 5; $i += 5;
break; break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$i}; $utf8 .= $chrs[$i];
break; break;
case ($ord_chrs_c & 0xE0) == 0xC0: case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX // characters U-00000080 - U-000007FF, mask 110XXXXX
@ -541,7 +541,7 @@ class Zend_Json_Decoder
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
} }
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch (true) { switch (true) {
case ((0x7F & $bytes) == $bytes): case ((0x7F & $bytes) == $bytes):

View File

@ -556,17 +556,17 @@ class Zend_Json_Encoder
case 2: case 2:
// return a UTF-16 character from a 2-byte UTF-8 char // return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2)) return chr(0x07 & (ord($utf8[0]) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6)) . chr((0xC0 & (ord($utf8[0]) << 6))
| (0x3F & ord($utf8{1}))); | (0x3F & ord($utf8[1])));
case 3: case 3:
// return a UTF-16 character from a 3-byte UTF-8 char // return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4)) return chr((0xF0 & (ord($utf8[0]) << 4))
| (0x0F & (ord($utf8{1}) >> 2))) | (0x0F & (ord($utf8[1]) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6)) . chr((0xC0 & (ord($utf8[1]) << 6))
| (0x7F & ord($utf8{2}))); | (0x7F & ord($utf8[2])));
} }
// ignoring UTF-32 for now, sorry // ignoring UTF-32 for now, sorry

View File

@ -189,16 +189,4 @@ class Zend_Registry extends ArrayObject
{ {
parent::__construct($array, $flags); parent::__construct($array, $flags);
} }
/**
* @param string $index
* @returns mixed
*
* Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
*/
public function offsetExists($index)
{
return array_key_exists($index, $this);
}
} }

View File

@ -165,7 +165,7 @@ class Zend_Validate_Isbn extends Zend_Validate_Abstract
$isbn10 = str_replace($this->_separator, '', $value); $isbn10 = str_replace($this->_separator, '', $value);
$sum = 0; $sum = 0;
for ($i = 0; $i < 9; $i++) { for ($i = 0; $i < 9; $i++) {
$sum += (10 - $i) * $isbn10{$i}; $sum += (10 - $i) * $isbn10[$i];
} }
// checksum // checksum
@ -183,9 +183,9 @@ class Zend_Validate_Isbn extends Zend_Validate_Abstract
$sum = 0; $sum = 0;
for ($i = 0; $i < 12; $i++) { for ($i = 0; $i < 12; $i++) {
if ($i % 2 == 0) { if ($i % 2 == 0) {
$sum += $isbn13{$i}; $sum += $isbn13[$i];
} else { } else {
$sum += 3 * $isbn13{$i}; $sum += 3 * $isbn13[$i];
} }
} }
// checksum // checksum

View File

@ -662,7 +662,7 @@ class lessc {
// check for a rest // check for a rest
$last = end($args); $last = end($args);
if ($last[0] == "rest") { if (is_array($last) && $last[0] == "rest") {
$rest = array_slice($orderedValues, count($args) - 1); $rest = array_slice($orderedValues, count($args) - 1);
$this->set($last[1], $this->reduce(array("list", " ", $rest))); $this->set($last[1], $this->reduce(array("list", " ", $rest)));
} }
@ -746,7 +746,7 @@ class lessc {
if ($suffix !== null && if ($suffix !== null &&
$subProp[0] == "assign" && $subProp[0] == "assign" &&
is_string($subProp[1]) && is_string($subProp[1]) &&
$subProp[1]{0} != $this->vPrefix) $subProp[1][0] != $this->vPrefix)
{ {
$subProp[2] = array( $subProp[2] = array(
'list', ' ', 'list', ' ',
@ -1857,7 +1857,7 @@ class lessc {
$this->pushEnv(); $this->pushEnv();
$parser = new lessc_parser($this, __METHOD__); $parser = new lessc_parser($this, __METHOD__);
foreach ($args as $name => $strValue) { foreach ($args as $name => $strValue) {
if ($name{0} != '@') $name = '@'.$name; if ($name[0] != '@') $name = '@'.$name;
$parser->count = 0; $parser->count = 0;
$parser->buffer = (string)$strValue; $parser->buffer = (string)$strValue;
if (!$parser->propertyValue($value)) { if (!$parser->propertyValue($value)) {
@ -2516,7 +2516,7 @@ class lessc_parser {
$hidden = true; $hidden = true;
if (!isset($block->args)) { if (!isset($block->args)) {
foreach ($block->tags as $tag) { foreach ($block->tags as $tag) {
if (!is_string($tag) || $tag{0} != $this->lessc->mPrefix) { if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) {
$hidden = false; $hidden = false;
break; break;
} }
@ -2570,7 +2570,7 @@ class lessc_parser {
protected function fixTags($tags) { protected function fixTags($tags) {
// move @ tags out of variable namespace // move @ tags out of variable namespace
foreach ($tags as &$tag) { foreach ($tags as &$tag) {
if ($tag{0} == $this->lessc->vPrefix) if ($tag[0] == $this->lessc->vPrefix)
$tag[0] = $this->lessc->mPrefix; $tag[0] = $this->lessc->mPrefix;
} }
return $tags; return $tags;

View File

@ -140,7 +140,10 @@ class MonitoringWizard extends Wizard implements SetupWizard
$setup->addStep( $setup->addStep(
new BackendStep(array( new BackendStep(array(
'backendConfig' => $pageData['setup_monitoring_backend'], 'backendConfig' => $pageData['setup_monitoring_backend'],
'resourceConfig' => array_diff_key($pageData['setup_monitoring_ido'], array('skip_validation' => null)) //TODO: Prefer a new backend once implemented. 'resourceConfig' => array_diff_key(
$pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented.
array('skip_validation' => null)
)
)) ))
); );

View File

@ -127,8 +127,7 @@ class ArrayToTextTableHelper
$this->printHeading(); $this->printHeading();
$rc = count($this->rows); $rc = count($this->rows);
for ($i = 0; $i < $rc; for ($i = 0; $i < $rc; $i++) {
$i++) {
$this->printRow($i); $this->printRow($i);
} }

View File

@ -3,7 +3,7 @@
set -ex set -ex
ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f "$(dirname "$0")")")"} ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f "$(dirname "$0")")")"}
PHPCS_VERSION=${PHPCS_VERSION:=3.3.2} PHPCS_VERSION=${PHPCS_VERSION:=3.5.3}
MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9} MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9}
HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0} HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0}
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7} PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}