Open ArrayIterator opened 3 years ago
@ArrayIterator can you provide clear steps on how to reproduce your error from an empty installation? From your stacktrace it looks like the whole stack is within a hook call? Do you have a valid SEMRush account connected to your user?
@ArrayIterator can you provide clear steps on how to reproduce your error from an empty installation? From your stacktrace it looks like the whole stack is within a hook call? Do you have a valid SEMRush account connected to your user?
I'm sorry I don't know how to exactly produce an error how to make it thrown error. Cause it suddenly happen to my clients site after update the wpseo plugin.
I suspect the error started from a failure to save data, or conflict with other plugins. But when you want to produce error by code, I've already use this.
// fake options
WPSEO_Options::save_option('semrush_tokens', [
'access_token' => '', // do empty
'refresh_token' => 'random', // maybe random
'expires' => time()+100,
'has_expired' => false,
'created_at' => time(),
]);
On bugs report about unused validations
empty() event
that will be useless, cause constructor already thrown an error, and validation about empty token will be useless.
Auth / Connection about SEMRush already valid untill plugins update, but suddenly thrown an error.
[ABSPATH]/wp-content/plugins/wordpress-seo/src/generated/container.php(1703): Yoast\WP\SEO\Config\SEMrush_Client->__construct()
This is cause about generated container service direct call to the service.
Small line but affected to another methods / code. The error thrown on editor (and post list) page in dashboard.
Agreeement
Versions
Note
I've found that semrush feature still being faces, maybe this bug ( or maybe feature?) that need manually resolve and thrown error before.
Case
When user try to create/list/add/edit (on post-(new).php|edit.php) yoast thrown the error with WPSEO Premium
How can we reproduce this behavior?
Method:
https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/config/semrush-client.php#L175
[Trace] - Produced By
[Trace] - Constructor
https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/config/semrush-client.php#L75
Propose
1. NOTE
Adding try - catch on property set constructor, because there are of dependency uses
SEMrush_Client
. eg:SEMrush_Client
( also called on generated container / dependency injection services )[Trace] - Login Action
https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/actions/semrush/semrush-login-action.php#L25
Called by metabox or
WPSEO Premium
container services on Route Registration and Metabox[Trace] - Login Action
The classes that required
SEMRush_Client
have method that check of loggedin.https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/actions/semrush/semrush-login-action.php#L53
[Trace] - Validation
https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/config/semrush-client.php#L145
or
https://github.com/Yoast/wordpress-seo/blob/813bf2e50575b69b47175e5d153748100595c520/src/config/semrush-client.php#L156
validations of
empty( $this->token )
will be useless, because constructor already thrown an error.2. Code Proposal
Thanks