[ticket/17176] Use different call to cause a notice

The previous call was upgraded to cause a warning in PHP 8.3

PHPBB3-17176
This commit is contained in:
Marc Alexander 2023-09-09 14:31:48 +02:00 committed by rxu
parent 303f8f55cb
commit a9b5dcd954
No known key found for this signature in database
GPG key ID: 955F0567380E586A

View file

@ -53,15 +53,14 @@ class phpbb_error_collector_test extends phpbb_test_case
// Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+ // Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+
version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__; version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__;
// Cause a "Notice: unserialize(): Error at offset 0 of 27 bytes in ..." // Cause a "Notice: date_default_timezone_set(): Timezone ID 'ThisTimeZoneDoesNotExist' is invalid"
// "Undefined array index" used earlier was promoted to warning in PHP 8.0, // https://github.com/php/php-src/blob/880faa39e8c648bdc3aad7aeca170755c6557831/ext/date/php_date.c#L5205
// see https://github.com/php/php-src/commit/c48b745f0090c944e77c1fbcfb6c4df3b54356ad date_default_timezone_set('ThisTimeZoneDoesNotExist'); $line2 = __LINE__;
unserialize("obvious non-serialized data"); $line2 = __LINE__;
$collector->uninstall(); $collector->uninstall();
// The notice should not be collected // The notice should not be collected
$this->assertFalse(isset($collector->errors[1])); $this->assertFalse(isset($collector->errors[1]), 'Notice should not be added to errors');
$this->assertEquals(count($collector->errors), 1); $this->assertEquals(count($collector->errors), 1);
list($errno, $msg_text, $errfile, $errline) = $collector->errors[0]; list($errno, $msg_text, $errfile, $errline) = $collector->errors[0];