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: check if get_current_screen() is set before accessing properties #4

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading