Skip to content
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

Merged
merged 4 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/classes/SiteAutomation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

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'] )?

Copy link
Contributor Author

@Sidsector9 Sidsector9 May 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
$data['retry'] = 0;
}
Expand Down
10 changes: 5 additions & 5 deletions includes/functions/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function setup() {
return __NAMESPACE__ . "\\$function";
};

add_filter( 'block_categories', $n( 'blocks_categories' ), 10, 2 );
add_filter( 'block_categories_all', $n( 'blocks_categories' ), 10, 2 );

register_blocks();
}
Expand All @@ -41,13 +41,13 @@ function register_blocks() {
/**
* Filters the registered block categories.
*
* @param array $categories Registered categories.
* @param object $post The post object.
* @param array $categories array Registered categories.
* @param object $block_editor_context WP_Block_Editor_Context The current block editor context.
*
* @return array Filtered categories.
*/
function blocks_categories( $categories, $post ) {
if ( ! in_array( $post->post_type, get_supported_post_types(), true ) ) {
function blocks_categories( $categories, $block_editor_context ) {
if ( ! in_array( $block_editor_context->post->post_type, get_supported_post_types(), true ) ) {
return $categories;
}

Expand Down