diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 150f28b17..24d83863d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,7 +82,7 @@ These are the steps to take to release a new version of Query Monitor (for contr 1. Check [the milestone on GitHub](https://github.com/johnbillion/query-monitor/milestones) for open issues or PRs. Fix or reassign as necessary. 1. If this is a non-patch release, check issues and PRs assigned to the patch or minor milestones that will get skipped. Reassign as necessary. 1. Ensure you're on the `develop` branch and all the changes for this release have been merged in. -1. Ensure both `README.md` and `readme.txt` contain up to date descriptions, "Tested up to" versions, FAQs, screenshots, etc. +1. Ensure `phpstan.neon.dist`, `README.md`, `readme.txt` contain up to date "Tested up to" versions, descriptions, FAQs, screenshots, etc. - Query Monitor supports the last nine versions of WordPress (support for versions up to approximately three years old) 1. Ensure `.gitattributes` is up to date with all files that shouldn't be part of the build. - To do this, run `git archive --output=qm.zip HEAD` then check the contents for files that shouldn't be part of the package. diff --git a/README.md b/README.md index de2e34181..c8ea24467 100644 --- a/README.md +++ b/README.md @@ -247,9 +247,7 @@ Debugging is rarely done with just one tool. Along with Query Monitor you should * [Log HTTP Requests](https://wordpress.org/plugins/log-http-requests/) * [Rewrite Rules Inspector](https://wordpress.org/plugins/rewrite-rules-inspector/) * [Snitch](https://wordpress.org/plugins/snitch/) - * [Time Stack](https://github.com/joehoyle/Time-Stack) * [User Switching](https://wordpress.org/plugins/user-switching/) - * [Variable Inspector](https://wordpress.org/plugins/variable-inspector/) * [WP Crontrol](https://wordpress.org/plugins/wp-crontrol/) Query Monitor also has [several add-on plugins](https://querymonitor.com/help/add-on-plugins/) which extend its functionality, and transparently supports add-ons for the Debug Bar plugin (see the FAQ for more info). diff --git a/assets/_styles.scss b/assets/_styles.scss index 2067cf113..d347cd3df 100644 --- a/assets/_styles.scss +++ b/assets/_styles.scss @@ -1500,14 +1500,20 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover } li { - margin: 0 0 0.7em !important; - list-style: none !important; + margin: 0 0 0.7em 1em !important; } .qm-info { /* @TODO */ color: #666 !important; } + + a.qm-edit-link { + svg { + display: none; + } + } + } body#error-page { diff --git a/collectors/block_editor.php b/collectors/block_editor.php index 36af54da5..89ca2c148 100644 --- a/collectors/block_editor.php +++ b/collectors/block_editor.php @@ -135,7 +135,13 @@ public function process() { $content = $_wp_current_template_content; } elseif ( is_singular() ) { // Post editor: - $content = get_post( get_queried_object_id() )->post_content; + $post = get_post( get_queried_object_id() ); + + if ( ! $post ) { + return; + } + + $content = $post->post_content; } else { // Nada: return; diff --git a/collectors/languages.php b/collectors/languages.php index 87fc49f63..b14f0ad8e 100644 --- a/collectors/languages.php +++ b/collectors/languages.php @@ -177,8 +177,10 @@ public function log_mo_file_load( $file, $domain ) { * @phpstan-return T */ public function log_translation_file_load( $file, $domain, string $locale = null ) { + // @phpstan-ignore WPCompat.methodNotAvailable $i18n_controller = \WP_Translation_Controller::get_instance(); + // @phpstan-ignore WPCompat.methodNotAvailable $found = $i18n_controller->load_file( $file, $domain, $locale ?? determine_locale() ); return $this->log_file_load( $file, $domain, $found ); diff --git a/collectors/php_errors.php b/collectors/php_errors.php index 9aaf0149b..7c0dc3abe 100644 --- a/collectors/php_errors.php +++ b/collectors/php_errors.php @@ -359,9 +359,32 @@ protected function output_fatal( $error, array $e ) { continue; } + $args = array_map( function( $value ) { + $type = gettype( $value ); + + switch ( $type ) { + case 'object': + return get_class( $value ); + case 'boolean': + return $value ? 'true' : 'false'; + case 'integer': + case 'double': + return $value; + case 'string': + if ( strlen( $value ) > 50 ) { + return "'" . substr( $value, 0, 20 ) . '...' . substr( $value, -20 ) . "'"; + } + return "'" . $value . "'"; + } + + return $type; + }, $frame['args'] ?? array() ); + + $name = str_replace( '()', '(' . implode( ', ', $args ) . ')', $callback['name'] ); + printf( '
  • %s
  • ', - QM_Output_Html::output_filename( $callback['name'], $frame['file'], $frame['line'] ) + QM_Output_Html::output_filename( $name, $frame['file'], $frame['line'] ) ); // WPCS: XSS ok. } echo ''; diff --git a/composer.json b/composer.json index 81c1f1166..7ac66ffab 100644 --- a/composer.json +++ b/composer.json @@ -32,10 +32,12 @@ "codeception/util-universalframework": "^1.0", "dealerdirect/phpcodesniffer-composer-installer": "0.7.2", "johnbillion/plugin-infrastructure": "dev-trunk", + "johnbillion/wp-compat": "0.1.0", "lucatume/wp-browser": "3.2.1", "phpcompatibility/phpcompatibility-wp": "2.1.4", - "phpstan/phpstan": "1.10.39", - "phpstan/phpstan-phpunit": "1.3.15", + "phpstan/phpstan": "1.12.2", + "phpstan/phpstan-deprecation-rules": "1.2.0", + "phpstan/phpstan-phpunit": "1.4.0", "roots/wordpress-core-installer": "1.100.0", "roots/wordpress-full": "*", "squizlabs/php_codesniffer": "3.7.1", @@ -97,7 +99,7 @@ ], "test:phpstan": [ "codecept build", - "phpstan analyze --memory-limit=1024M" + "phpstan analyze -v --memory-limit=1024M" ], "test:start": [ "tests-start" diff --git a/docs/about.md b/docs/about.md index 41411e2f6..2b3828a7c 100644 --- a/docs/about.md +++ b/docs/about.md @@ -8,6 +8,6 @@ publish: false Query Monitor is maintained by [John Blackbourn](https://johnblackbourn.com/), one of the team of core committers to the WordPress open source project which he's been involved with for over fifteen years. -John works as a Principal Web Engineer at [Human Made](https://humanmade.com/), one of the world's leading WordPress specialist development agencies, where he leads large scale web publishing platform redevelopment projects for enterprise organisations. He has previously worked at [WordPress VIP](https://wpvip.com/) and [Code For The People](http://codeforthepeople.com/). +John works as Director of WordPress Security at [Human Made](https://humanmade.com/), one of the world's leading WordPress specialist development agencies. He has previously worked at [WordPress VIP](https://wpvip.com/) and [Code For The People](http://codeforthepeople.com/). John maintains [many other plugins, tools, and resources for WordPress developers](https://johnblackbourn.com/wordpress-developer-tools/). diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6c7026a2b..75c52c66c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,6 +2,8 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/szepeviktor/phpstan-wordpress/extension.neon - vendor/johnbillion/plugin-infrastructure/phpstan/extension.neon + - vendor/johnbillion/wp-compat/extension.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon parameters: level: 7 paths: @@ -34,3 +36,5 @@ parameters: # Passing ints and floats to these functions is fine - '#^Parameter \#1 \$text of function (esc_html|esc_attr) expects string, int\|string given#' - '#^Parameter \#1 \$text of function (esc_html|esc_attr) expects string, float\|int\|string given#' + WPCompat: + requiresAtLeast: '5.8' diff --git a/tests/integration/PluginTest.php b/tests/integration/PluginTest.php index a8d7d5bf3..7fa8e9e7f 100644 --- a/tests/integration/PluginTest.php +++ b/tests/integration/PluginTest.php @@ -41,7 +41,9 @@ private function get_readme() { $file_contents = implode( '', $file_contents ); - preg_match( '|Stable tag:(.*)|i', $file_contents, $_stable_tag ); + if ( preg_match( '|Stable tag:(.*)|i', $file_contents, $_stable_tag ) !== 1 ) { + return false; + } $this->readme_data = array( 'stable_tag' => trim( trim( $_stable_tag[1], '*' ) )