Freemius / wordpress-sdk

https://freemius.com
GNU General Public License v3.0
267 stars 77 forks source link

Notice: Undefined property: stdClass::$newest in file start.php on line 284 #505

Open daigo75 opened 3 years ago

daigo75 commented 3 years ago

Behavior: I ran some tests with several plugins that rely on this SDK and the following notice appears in the backend: Notice: Undefined property: stdClass::$newest in /path/to//vendor/freemius/wordpress-sdk/start.php on line 284

All the plugins use the same framework version (2.4.2) and load the Freemius initialisation code the same way. Of course, the arguments passed to it would be different, but that's about it, the rest is an almost verbatim copy of the initialisation code.

It looks like, in some cases, $fs_active_plugins->newest is not initialised. I haven't been able to debug this in detail, though, due to other commitments.

Versions: (*)

Plugin / Theme: (*)

daigo75 commented 3 years ago

Further information The issue seems to occur when one of the plugins that loads the Freemius SDK is installed via a symbolic link. The full path to the SDK doesn't match the one generated by function fs_fallback_to_newest_active_sdk() and that causes the logic not to "see" the plugin that loaded the SDK.

The affected line is the following: $is_sdk_exists = file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $sdk_relative_path . '/start.php' ) );

If the $sdk_relative_path resolves to a path outside WP_PLUGIN_DIR, due to the presence of as symbolic link, the call to file_exists() fails.