Skip to content

Commit

Permalink
fix: check if get_current_screen() is set before accessing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Aug 14, 2024
1 parent 6192a96 commit a1f86ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-cows-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wpengine/wp-graphql-content-blocks": patch
---

Fix: prevent fatal errors when get_current_screen() is unset.
6 changes: 3 additions & 3 deletions includes/updates/update-callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function custom_plugin_api_request( $api, $action, $args ) {
*/
function delegate_plugin_row_notice() {
$screen = get_current_screen();
if ( 'plugins' !== $screen->id ) {
if ( ! isset( $screen->id ) || 'plugins' !== $screen->id ) {
return;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ function display_plugin_row_notice() {
*/
function display_update_page_notice() {
$screen = get_current_screen();
if ( 'update-core' !== $screen->id ) {
if ( ! isset( $screen->id ) || 'update-core' !== $screen->id ) {
return;
}

Expand Down Expand Up @@ -176,4 +176,4 @@ function filter_semver_notice_text( $notice_text, $plugin_filename ) {
return $notice_text;
}
return '<br><br>' . __( '<b>THIS UPDATE MAY CONTAIN BREAKING CHANGES:</b> This plugin uses Semantic Versioning, and this new version is a major release. Please review the changelog before updating.', 'wp-graphql-content-blocks' );
}
}
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ parameters:
count: 1
path: includes/updates/update-callbacks.php

-
message: "#^Cannot access property \\$id on WP_Screen\\|null\\.$#"
count: 2
path: includes/updates/update-callbacks.php

-
message: "#^Function WPGraphQL\\\\ContentBlocks\\\\PluginUpdater\\\\custom_plugin_api_request\\(\\) has invalid return type WPGraphQL\\\\ContentBlocks\\\\PluginUpdater\\\\stdClass\\.$#"
count: 1
Expand Down

0 comments on commit a1f86ae

Please sign in to comment.