Closed htmgarcia closed 3 years ago
@contactashish13 when editing a Content Display block, if you choose a CPT, filter by taxonomies and choose to display some of them. Then select a different content type (like WC Products). This causes a warning or a blank result in frontend. Please check the 2 cases below.
Result: The block is not displayed in frontend.
The attributes marked with red doesn't belong to the postType attribute: If you manually remove these attributes and save changes, the issue is solved.
Result: PHP Warning: Invalid argument supplied for foreach() in wp-content/plugins/advanced-gutenberg/assets/blocks/recent-posts/block.php on line 897
If you don't see the warning in frontend, please check the error logs from your site.
The attribute marked with red doesn't belong to the postType attribute: If you manually remove this attribute and save changes, the issue is solved.
@htmgarcia can you mention how number 2 will happen? I'm not very sure how to test this scenario
@contactashish13 number 2 suggestion complement number 1. The problems that solves are Case scenario 1 and Case scenario 2.
If you have a different solution in mind for Case scenario 1 and Case scenario 2, please be my guest.
@htmgarcia your fix indeed solves for both scenarios but how will the below happen? How will an existing block be broken is what I don't understand? Can you please share a scenario for me to test?
Reset the attributes "taxonomies" and "showCustomTaxList" if doesn't match with "postType" attribute when loading in editor (for existing broken instances of the block).
@contactashish13 Case scenario 2 can happen to users who already created an instance of Content Display block with 2.7.0 version. A solution for that case scenario is kind of a deprecation (without being technically one).
While using version 2.7.0, follow the steps from Case scenario 2. Are you able you reproduce the warning? If so, do you see it on the frontend or only in the error logs.
@htmgarcia yes I see the warning in the error.log and have addressed that. I was wondering how to address the number 2 issue so thanks for clarifying... I may be able to do that now.
@htmgarcia I wasn't able to reproduce the error. These are the steps:
I guess this is because your changes for resetting "taxonomies" and "showCustomTaxList" works properly and no matter what I did, I was unable to break the block.
@contactashish13 I made a screencast reproducing the issue https://youtu.be/wa5a95sN61s
@contactashish13 the PR #559 fixed the warning. Thanks!
PHP Warning: Invalid argument supplied for foreach() in wp-content/plugins/advanced-gutenberg/assets/blocks/recent-posts/block.php on line 897
advgbGetAdditionalTaxInfo() wp-includes/rest-api/endpoints/class-wp-rest-controller.php:433
advgbGetAdditionalTaxInfo() wp-includes/rest-api/endpoints/class-wp-rest-controller.php:433
advgbGetTaxonomyTerms() wp-content/plugins/advanced-gutenberg/assets/blocks/recent-posts/block.php:880