Skip to content

Commit ad81554

Browse files
authored
Support PHP 8.5 (#5454)
PHP 8.4: - Change implicit nullable type declaration to explicit - Only set `session.sid_bits_per_character` for PHP < 8.4 PHP 8.5: - Remove no-op `ReflectionProperty::setAccessible()` calls - Replace backtick operator with `shell_exec()` - Avoid passing `null` as key in `array_key_exists()` - Avoid passing `null` to non-nullable parameters in built-in functions - Use `Pdo\Mysql` driver-specific constants Other compatibility fixes: - Avoid passing `null` as `ipl\Html` form element `$name` - Use latest PHPUnit version
2 parents bc2d4a5 + 9bd53ac commit ad81554

File tree

81 files changed

+22691
-27886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+22691
-27886
lines changed

.github/workflows/php.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
with:
1818
databases: true
1919
php-extensions: ldap
20-
phpunit-version: 9.6
2120
dependencies: |
2221
{
2322
"./icinga-php/ipl" : "https://github.com/Icinga/icinga-php-library.git#snapshot/nightly",

application/clicommands/WebCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function stopAction()
6767
{
6868
// TODO: No, that's NOT what we want
6969
$prog = readlink('/proc/self/exe');
70-
`killall $prog`;
70+
shell_exec("killall $prog");
7171
}
7272

7373
protected function forkAndExit()

application/forms/Config/Resource/DbResourceForm.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Icinga\Application\Platform;
77
use Icinga\Web\Form;
8+
use Pdo\Mysql;
89

910
/**
1011
* Form class for adding/modifying database resources
@@ -177,7 +178,7 @@ public function createElements(array $formData)
177178
)
178179
);
179180
if (isset($formData['use_ssl']) && $formData['use_ssl']) {
180-
if (defined('\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT')) {
181+
if (defined(Mysql::class . '::ATTR_SSL_VERIFY_SERVER_CERT')) {
181182
$this->addElement(
182183
'checkbox',
183184
'ssl_do_not_verify_server_cert',

application/forms/RepositoryForm.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public function shouldDelete()
145145
/**
146146
* Add a new entry
147147
*
148-
* @param array $data The defaults to use, if any
148+
* @param ?array $data The defaults to use, if any
149149
*
150-
* @return $this
150+
* @return $this
151151
*/
152-
public function add(array $data = null)
152+
public function add(?array $data = null)
153153
{
154154
$this->mode = static::MODE_INSERT;
155155
$this->data = $data;
@@ -159,12 +159,12 @@ public function add(array $data = null)
159159
/**
160160
* Edit an entry
161161
*
162-
* @param string $name The entry's name
163-
* @param array $data The entry's current data
162+
* @param string $name The entry's name
163+
* @param ?array $data The entry's current data
164164
*
165-
* @return $this
165+
* @return $this
166166
*/
167-
public function edit($name, array $data = null)
167+
public function edit($name, ?array $data = null)
168168
{
169169
$this->mode = static::MODE_UPDATE;
170170
$this->identifier = $name;

application/views/scripts/error/error.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $modReason = [];
2323

2424
if (isset($requiredVendor, $requiredProject) && $requiredVendor && $requiredProject) {
2525
// TODO: I don't like this, can we define requirements somewhere else?
26-
$coreDeps = ['icinga-php-library' => '>= 0.14.2', 'icinga-php-thirdparty' => '>= 0.12'];
26+
$coreDeps = ['icinga-php-library' => '>= 0.19.0', 'icinga-php-thirdparty' => '>= 0.12'];
2727

2828
foreach ($coreDeps as $libraryName => $requiredVersion) {
2929
if (! $libraries->has($libraryName)) {

doc/02-Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ You will need to install certain dependencies depending on your setup:
399399
monitor your infrastructure
400400
* A web server, e.g. Apache or Nginx
401401
* PHP version ≥ 8.2
402-
* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (≥ 0.14.2)
402+
* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (≥ 0.19.0)
403403
* [Icinga PHP Thirdparty](https://github.com/Icinga/icinga-php-thirdparty) (≥ 0.12)
404404
* The following PHP modules must be installed: cURL, json, gettext, fileinfo, intl, dom, OpenSSL and xml
405405
* The [pdfexport](https://github.com/Icinga/icingaweb2-module-pdfexport) module (≥0.10) is required for the

library/Icinga/Application/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class Config implements Countable, Iterator, Selectable
6868
/**
6969
* Create a new config
7070
*
71-
* @param ConfigObject $config The config object to handle
71+
* @param ?ConfigObject $config The config object to handle
7272
*/
73-
public function __construct(ConfigObject $config = null)
73+
public function __construct(?ConfigObject $config = null)
7474
{
7575
$this->config = $config !== null ? $config : new ConfigObject();
7676
}

library/Icinga/Application/Hook/AuditHook.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ abstract class AuditHook
1616
*
1717
* Propagates the given message details to all known hook implementations.
1818
*
19-
* @param string $type An arbitrary name identifying the type of activity
20-
* @param string $message A detailed description possibly referencing parameters in $data
21-
* @param array $data Additional information (How this is stored or used is up to each implementation)
22-
* @param string $identity An arbitrary name identifying the responsible subject, defaults to the current user
23-
* @param int $time A timestamp defining when the activity occurred, defaults to now
19+
* @param string $type An arbitrary name identifying the type of activity
20+
* @param string $message A detailed description possibly referencing parameters in $data
21+
* @param ?array $data Additional information (How this is stored or used is up to each implementation)
22+
* @param string $identity An arbitrary name identifying the responsible subject,
23+
* defaults to the current user
24+
* @param int $time A timestamp defining when the activity occurred, defaults to now
2425
*/
25-
public static function logActivity($type, $message, array $data = null, $identity = null, $time = null)
26+
public static function logActivity($type, $message, ?array $data = null, $identity = null, $time = null)
2627
{
2728
if (! Hook::has('audit')) {
2829
return;
@@ -60,13 +61,13 @@ public static function logActivity($type, $message, array $data = null, $identit
6061
/**
6162
* Log a message to the audit log
6263
*
63-
* @param int $time A timestamp defining when the activity occurred
64-
* @param string $identity An arbitrary name identifying the responsible subject
65-
* @param string $type An arbitrary name identifying the type of activity
66-
* @param string $message A detailed description of the activity
67-
* @param array $data Additional activity information
64+
* @param int $time A timestamp defining when the activity occurred
65+
* @param string $identity An arbitrary name identifying the responsible subject
66+
* @param string $type An arbitrary name identifying the type of activity
67+
* @param string $message A detailed description of the activity
68+
* @param ?array $data Additional activity information
6869
*/
69-
abstract public function logMessage($time, $identity, $type, $message, array $data = null);
70+
abstract public function logMessage($time, $identity, $type, $message, ?array $data = null);
7071

7172
/**
7273
* Substitute the given message with its accompanying data

library/Icinga/Application/Hook/DbMigrationHook.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ public function getLatestMigrations(int $limit): array
196196
* Apply all pending migrations of this hook
197197
*
198198
* @param ?Connection $conn Use the provided database connection to apply the migrations.
199-
* Is only used to elevate database users with insufficient privileges.
199+
* Is only used to elevate database users with insufficient privileges.
200200
*
201201
* @return bool Whether the migration(s) have been successfully applied
202202
*/
203-
final public function run(Connection $conn = null): bool
203+
final public function run(?Connection $conn = null): bool
204204
{
205205
if (! $conn) {
206206
$conn = $this->getDb();

library/Icinga/Application/Hook/Ticket/TicketPattern.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function offsetExists($offset): bool
4141

4242
public function offsetGet($offset): ?string
4343
{
44+
$offset = $offset ?? '';
4445
return array_key_exists($offset, $this->match) ? $this->match[$offset] : null;
4546
}
4647

0 commit comments

Comments
 (0)