Closed michael-sumner closed 5 months ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
admin-functions.php | 0 | 8 | 0.0% | ||
<!-- | Total: | 0 | 8 | 0.0% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
admin-functions.php | 2 | 0.0% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 8307438743: | -0.08% |
Covered Lines: | 1237 |
Relevant Lines: | 2467 |
Thanks @michael-sumner! I added some more related fixes that I wasn't able to push before
Context
Cloning a post can cause a critical error due to the type of
get_option( 'duplicate_post_taxonomies_blacklist' )
which can be aNULL
value.Related Issues:
duplicate_post_taxonomies_blacklist
option causing cloning errors due to inconsistent output type (array, empty string, null)Summary
This PR can be summarized in the following changelog entry:
duplicate_post_taxonomies_blacklist
option. Props to @michael-sumner.Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
It's a bit tricky to reproduce the problem because it looks like it can be caused by caching, or by pathological situations where the option value has been stored in the wrong way. We'll need to use filters to emulate those cases.
Reproduce the issue with NULL value
duplicate_post_*
rows inwp_options
)functions.php
and add this snippet:add_filter( 'option_duplicate_post_taxonomies_blacklist', '__return_null' );
Fatal error: Uncaught Error: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 149
functions.php
functions.php
Fatal error: Uncaught Error: array_diff(): Argument #2 must be of type array, null given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 303
functions.php
before proceedingReproduce the issue with a string value
duplicate_post_*
rows inwp_options
)functions.php
and add this snippet:add_filter( 'option_duplicate_post_taxonomies_blacklist', function(){ return 'foo'; } );
Fatal error: Uncaught Error: in_array(): Argument #2 ($haystack) must be of type array, string given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 149
functions.php
functions.php
Fatal error: Uncaught Error: array_diff(): Argument #2 must be of type array, string given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 303
functions.php
before proceedingtest the fix with NULL value
duplicate_post_*
rows inwp_options
)functions.php
and add this snippet:add_filter( 'option_duplicate_post_taxonomies_blacklist', '__return_null' );
Fatal error: Uncaught Error: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 149
Fatal error: Uncaught Error: array_diff(): Argument #2 must be of type array, null given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 303
functions.php
before proceedingtest the fix with with a string value
duplicate_post_*
rows inwp_options
)functions.php
and add this snippet:add_filter( 'option_duplicate_post_taxonomies_blacklist', function(){ return 'foo'; } );
Fatal error: Uncaught Error: in_array(): Argument #2 ($haystack) must be of type array, string given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 149
Fatal error: Uncaught Error: array_diff(): Argument #2 must be of type array, string given in /home/lopo/src/Yoast/plugin-development-docker/plugins/duplicate-post/admin-functions.php on line 303
Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
UI changes
Documentation
Quality assurance
Innovation
innovation
label and noted the work hours.Fixes #263