1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Issue #5443 - PHP 8.4 deprecation error removal.

This commit is contained in:
camer0n
2025-04-29 10:03:49 -07:00
parent 85a65281b2
commit e7fec78550
2 changed files with 37 additions and 25 deletions

View File

@@ -6164,6 +6164,15 @@ class e107
*/ */
public function __get($name) public function __get($name)
{ {
// Use a static cache to store instances
static $instances = [];
if(isset($instances[$name]))
{
return $instances[$name];
}
switch($name) switch($name)
{ {
case 'tp': case 'tp':
@@ -6220,11 +6229,14 @@ class e107
default: default:
trigger_error('$e107->$' . $name . ' not defined', E_USER_WARNING); trigger_error('$e107->$' . $name . ' not defined', E_USER_WARNING);
return null; return null;
break; break;
} }
$this->$name = $ret; // Store the result in the static cache
$instances[$name] = $ret;
return $ret; return $ret;
} }

View File

@@ -17,7 +17,7 @@
catch(Exception $e) catch(Exception $e)
{ {
$this->assertTrue(false, $e->getMessage()); $this::fail($e->getMessage());
} }
} }
@@ -39,13 +39,13 @@
'most_enabled' => true 'most_enabled' => true
); );
$result = $this->ad->ReadArray($string); $result = e107::unserialize($string);
$this->assertSame($expected, $result); $this::assertSame($expected, $result);
// legacy Prefs test. // legacy Prefs test.
$string = 'a:4:{s:19:"most_members_online";i:10;s:18:"most_guests_online";i:20;s:21:"most_online_datestamp";i:1534279911;s:12:"most_enabled";b:1;}'; $string = 'a:4:{s:19:"most_members_online";i:10;s:18:"most_guests_online";i:20;s:21:"most_online_datestamp";i:1534279911;s:12:"most_enabled";b:1;}';
$actual = $this->ad->ReadArray($string); $actual = e107::unserialize($string);
$this->assertSame($expected, $actual); $this::assertSame($expected, $actual);
} }
@@ -54,12 +54,12 @@
{ {
// Test with addslashes enabled. // Test with addslashes enabled.
$input = array('one'=>'two', 'three'=>true); $input = array('one'=>'two', 'three'=>true);
$result = $this->ad->WriteArray($input); $result = e107::serialize($input,true);
$expected = 'array ( $expected = 'array (
\\\'one\\\' => \\\'two\\\', \\\'one\\\' => \\\'two\\\',
\\\'three\\\' => true, \\\'three\\\' => true,
)'; )';
$this->assertSame($expected, $result); $this::assertSame($expected, $result);
// Test with addslashes disabled. // Test with addslashes disabled.