You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Behavior:
I tried some scheduled tasks via wp-cli, and the following notice appeared Notice: Undefined property: Freemius_Api::$_sandbox in /path/to/freemius/php-sdk/freemius/Freemius.php on line 69
Cause
The affected line contains the following code: return ($this->_sandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS) . $pCanonizedPath;
Property $this->_sandbox is not declared as part of the Freemius_Api class, it's a dynamic property. Due to that, it doesn't exist until something sets its value:
// This throws a notice
echo $this->_sandbox;
// This creates and initialises the property
$this->_sandbox = 'value';
// This works as expected
echo $this->_sandbox;
Solution
Declaring the Freemius_Api::$_sandbox property will fix the issue. This will become necessary anyway, because dynamic properties will be deprecated in PHP 8.2 and completely removed in PHP 9.0
lob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L160
Versions: (*)
Freemius PHP SDK Version:dev-master, from Packagist.
WordPress Version: 5.8
PHP Version: 7.4.x or newer.
The text was updated successfully, but these errors were encountered:
daigo75
pushed a commit
to aelia-co/freemius-php-sdk
that referenced
this issue
Aug 10, 2022
🐞 bug report
Behavior:
I tried some scheduled tasks via
wp-cli
, and the following notice appearedNotice: Undefined property: Freemius_Api::$_sandbox in /path/to/freemius/php-sdk/freemius/Freemius.php on line 69
Affected line
https://github.com/Freemius/freemius-php-sdk/blob/master/freemius/Freemius.php#L69
Cause
The affected line contains the following code:
return ($this->_sandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS) . $pCanonizedPath;
Property
$this->_sandbox
is not declared as part of theFreemius_Api
class, it's a dynamic property. Due to that, it doesn't exist until something sets its value:Solution
Declaring the
Freemius_Api::$_sandbox
property will fix the issue. This will become necessary anyway, because dynamic properties will be deprecated in PHP 8.2 and completely removed in PHP 9.0lob/84a9be4717effd7697a217e0d931f48ae0d2ecc6/config.php#L160
Versions: (*)
Freemius PHP SDK Version:
dev-master
, from Packagist.WordPress Version:
5.8PHP Version:
7.4.x or newer.The text was updated successfully, but these errors were encountered: