Skip to content

Commit

Permalink
Merge pull request #4 from rtCamp/fix/screen-on-null
Browse files Browse the repository at this point in the history
fix: check if `get_current_screen()` is set before accessing properties
  • Loading branch information
justlevine authored Sep 11, 2024
2 parents f7a49c1 + 6ced628 commit cbc4433
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 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.
4 changes: 2 additions & 2 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
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,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 cbc4433

Please sign in to comment.