Prevent errors in admin bar filters from non-array arguments#4207
Prevent errors in admin bar filters from non-array arguments#4207westonruter merged 3 commits intodevelopfrom
Conversation
Props @westonruter for the fix Prevents running in_array() if the deps are not an array.
|
Hi @westonruter, Thanks, Weston! |
| public function test_filter_admin_bar_style_loader_tag_non_array() { | ||
| wp_enqueue_style( 'admin-bar' ); | ||
| $GLOBALS['wp_styles']->registered['admin-bar']->deps = null; | ||
| $tag = 'foo'; |
There was a problem hiding this comment.
This should be an actual link tag as normally passed in. Otherwise the test is possibly failing silently.
| public function test_filter_admin_bar_script_loader_tag_non_array() { | ||
| wp_enqueue_script( 'admin-bar' ); | ||
| $GLOBALS['wp_scripts']->registered['admin-bar']->deps = null; | ||
| $tag = 'example-tag'; |
There was a problem hiding this comment.
Same as above. This should be an actual script tag as is normally passed into the method.
There was a problem hiding this comment.
Sure, applied in the same commit, 68964a4
…anged As Weston mentioned, this ensures the test doesn't give false results.
| wp_enqueue_script( 'admin-bar' ); | ||
| $GLOBALS['wp_scripts']->registered['admin-bar']->deps = null; | ||
| $tag = '<script src="https://example.com/wp-includes/js/admin-bar.js?ver=5.3.2"></script>'; | ||
| $this->assertEquals( $tag, AMP_Theme_Support::filter_admin_bar_script_loader_tag( $tag, 'example' ) ); |
There was a problem hiding this comment.
I suppose in reality the assertion here serves the purpose of preventing the test from being flagged for having no assertions. Since there is no style registered with the handle of baz, neither of the conditions self::is_exclusively_dependent( wp_scripts(), $handle, 'admin-bar' ) nor self::has_dependency( wp_scripts(), $handle, 'admin-bar' ) will ever be true.
Commit Weston's fix for the in_array() error, add small tests Prevents running in_array() if the deps are not an array.
…nt/4070-validate-props * 'develop' of github.com:ampproject/amp-wp: (108 commits) Update dependency semver to v7.1.2 (#4206) Update dependency @babel/core to v7.8.4 (#4199) Prevent errors in admin bar filters from non-array arguments (#4207) Discontinue preserving original style[amp-custom] Update dependency terser-webpack-plugin to v2.3.4 (#4189) Update dependency @babel/cli to v7.8.4 (#4198) Update dependency browserslist to v4.8.6 (#4196) Update dependency dealerdirect/phpcodesniffer-composer-installer to v0.6.2 (#4186) Split Reader mode style template part stylesheet from action-supplied styles Remove needless $xmlns_value_to_strip variable Fix PHPCS error Commit Weston's suggestion to use documentElement Use $html->hasAttributes to possibly exit early. If the html[lang] is "", overwrite it with the xml:lang Conditionally remove html[xmlns], and convert html[xml:lang] to html[lang] If head[profile=], strip profile, but don't create a new link Revert 7f60c5c (If there's already a link[rel=profile], don't create another Fix phpcs issues in failed Travis build If there's already a link[rel=profile], don't create another Convert head[profile] attribute to a link[rel=profile] ...
* tag '1.4.3': (22 commits) Update readme and screenshots for Stories removal (#4259) Open story export instructions in a new window (#4258) Bump version to 1.4.3-RC1 Hide Stories options and add deprecation notice (#4219) Fix malformed conversion of relative action URLs for forms (#4250) Limit Stories experience to WP 5.3 & Gutenberg 7.1.0 (#4217) Prevent errors in admin bar filters from non-array arguments (#4207) Update @wordpress/e2e-test-utils dependency Revert update of mustache/mustache dependency Update composer.lock Update WP CLI to 2.4.0 For WordPress.tv embed, Use an oembed filter instead of block filter (#4164) Update readme to add FAQs section (#4159) Apply workaround to fix test__multiple_valid_image_files (#4034) Ignore Story editor tests (#4043) Update amp-video embed regex pattern to include other Vimeo URL formats (#4051) Update amp-instagram embed regex (#4053) Update wp-dev-lib package (#4029) Fix conversion of forms with relative action URLs (#4003) Improve release instructions (#3995) ...
Summary
in_array()if the->depsare not an arrayFixes #4145
Checklist