-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/270: undefined array offset #292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sidsector9 thank you for the fix. Loogs good, just a concern about the better approach to test array offset
@@ -176,7 +176,7 @@ private function set_status( $data ) { | |||
); | |||
|
|||
if ( empty( $data['success'] ) ) { | |||
$data['retry'] = $this->status['retry'] + 1; | |||
$data['retry'] = is_array( $this->status ) ? $this->status['retry'] + 1 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the fact that checking $this->status is array will resolve the issue, but it still a potential warning if retry offset doesn't exist in the array. Could we check for isset( $this->status['retry'] )
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cadic I had similar thoughts, but checking the code I found $this->status
is either set to a boolean or it is set to an array that always contains the retry
key.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description of the Change
This PR checks if the value returned by transient is an array before accessing an offset.
Also replaces the deprecated filter
block_categories
withblock_categories_all
Closes #270
Verification Process
WP_DEBUG
andWP_DEBUG_LOG
to truedevelop
, open a page that uses the Sophi Automation Blockwp transient delete --all
) and reload the pagefix/270
and repeat (3)Checklist:
Changelog Entry
Fixed: replace deprecated
block_categories
filter withblock_categories_all
.Fixed: fix warning shown due to access of undefined array
Credits
Props @Sidsector9