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

Front end Fatal error rendering tag cloud for unregistered taxonomy #7

Open
bobbingwide opened this issue Mar 24, 2021 · 2 comments
Open
Assignees
Labels
bug Something isn't working Gutenberg A bug / enhancement to Gutenberg

Comments

@bobbingwide
Copy link
Owner

While attempting to check that oik.css wasn't inadvertently affecting the style changes noticed when using Gutenberg-source ( latest trunk) I deactivated oik. This prevented the custom taxonomies from being registered which produced a Fatal error trying to display the tag cloud.

Warning: Attempt to read property "labels" on bool in C:\apache\htdocs\bigram\wp-includes\taxonomy.php on line 582

Fatal error: Uncaught Error: Attempt to assign property "labels" on bool in C:\apache\htdocs\bigram\wp-includes\taxonomy.php:582
Stack trace:

#0 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\build\block-library\blocks\tag-cloud.php(24): get_taxonomy_labels(false) 
#1 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\compat.php(136): gutenberg_render_block_core_tag_cloud(Array, '', Object(WP_Block)) 
#2 C:\apache\htdocs\bigram\wp-includes\class-wp-block.php(221): {closure}(Array, '', Object(WP_Block)) 
#3 C:\apache\htdocs\bigram\wp-includes\class-wp-block.php(211): WP_Block->render() 
#4 C:\apache\htdocs\bigram\wp-includes\class-wp-block.php(211): WP_Block->render() 
#5 C:\apache\htdocs\bigram\wp-includes\class-wp-block.php(211): WP_Block->render() 
#6 C:\apache\htdocs\bigram\wp-includes\blocks.php(799): WP_Block->render() 
#7 C:\apache\htdocs\bigram\wp-includes\blocks.php(837): render_block(Array) 
#8 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\build\block-library\blocks\template-part.php(100): do_blocks('<!-- wp:group {...') 
#9 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\compat.php(136): gutenberg_render_block_core_template_part(Array, '', Object(WP_Block)) 
#10 C:\apache\htdocs\bigram\wp-includes\class-wp-block.php(221): {closure}(Array, '', Object(WP_Block)) 
#11 C:\apache\htdocs\bigram\wp-includes\blocks.php(799): WP_Block->render() 
#12 C:\apache\htdocs\bigram\wp-includes\blocks.php(837): render_block(Array) 
#13 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\full-site-editing\template-loader.php(182): do_blocks('<!-- wp:templat...') 
#14 C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\template-canvas.php(12): gutenberg_get_the_template_html() 
#15 C:\apache\htdocs\bigram\wp-includes\template-loader.php(106): include('C:\\apache\\htdoc...') 
#16 C:\apache\htdocs\bigram\wp-blog-header.php(19): require_once('C:\\apache\\htdoc...') 
#17 C:\apache\htdocs\bigram\index.php(17): require('C:\\apache\\htdoc...') 
#18 {main} thrown in C:\apache\htdocs\bigram\wp-includes\taxonomy.php on line 582
@bobbingwide
Copy link
Owner Author

This wasn't a problem on s.b/bigram but it is a problem on s.b/wp55/sb where I'm testing the template file only version of the theme.

bobbingwide added a commit that referenced this issue Mar 26, 2021
… parts. Issue #7: cater for unregistered taxonomies
@bobbingwide
Copy link
Owner Author

bobbingwide commented May 12, 2022

The problem still occurs when the taxonomy is not registered and the tag-cloud override is not enabled.
This state of affairs occurs can be created by deactivating the oik plugin.


Warning: Attempt to read property "labels" on bool in C:\apache\htdocs\wp55\wp-includes\taxonomy.php on line 652

Fatal error: Uncaught Error: Attempt to assign property "labels" on bool in C:\apache\htdocs\wp55\wp-includes\taxonomy.php:652 Stack trace:
#0 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\build\block-library\blocks\tag-cloud.php(25): get_taxonomy_labels(false)
#1 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat.php(132): gutenberg_render_block_core_tag_cloud(Array, '', Object(WP_Block))
#2 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(255): {closure}(Array, '', Object(WP_Block))
#3 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(241): WP_Block-&gt;render()
#4 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(241): WP_Block-&gt;render()
#5 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(241): WP_Block-&gt;render()
#6 C:\apache\htdocs\wp55\wp-includes\blocks.php(883): WP_Block-&gt;render()
#7 C:\apache\htdocs\wp55\wp-includes\blocks.php(921): render_block(Array)
#8 C:\apache\htdocs\wordpress\wp-content\themes\sb\includes\template-part.php(107): do_blocks('&lt;!-- wp:group {...')
#9 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat.php(132): sb_render_block_core_template_part(Array, '&lt;!-- wp:group {...', Object(WP_Block))
#10 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(255): {closure}(Array, '', Object(WP_Block))
#11 C:\apache\htdocs\wp55\wp-includes\blocks.php(883): WP_Block-&gt;render()
#12 C:\apache\htdocs\wp55\wp-includes\blocks.php(921): render_block(Array)
#13 C:\apache\htdocs\wp55\wp-includes\block-template.php(240): do_blocks('&lt;!-- wp:oik-sb/...')
#14 C:\apache\htdocs\wp55\wp-includes\template-canvas.php(12): get_the_block_template_html()
#15 C:\apache\htdocs\wp55\wp-includes\template-loader.php(106): include('C:\\apache\\htdoc...')
#16 C:\apache\htdocs\wp55\wp-blog-header.php(19): require_once('C:\\apache\\htdoc...')
#17 C:\apache\htdocs\wp55\index.php(17): require('C:\\apache\\htdoc...')
#18 {main}
  thrown in <b>C:\apache\htdocs\wp55\wp-includes\taxonomy.php</b> on line <b>652</b><br />

It's a bug in Gutenberg which has now made its way into core.
This confirms that the tag-cloud override is still necessary; it implements logic to check if the taxonomy is registered.
This bug is a follow on to PR 16098 which was the fix to WordPress/gutenberg#13932

if ( ! $tag_cloud ) {
        $taxonomy = get_taxonomy($attributes['taxonomy']);
        if ($taxonomy) {
            $labels = get_taxonomy_labels(get_taxonomy($attributes['taxonomy']));
            $tag_cloud = esc_html(
                sprintf(
                /* translators: %s: taxonomy name */
                    __('Your site doesn&#8217;t have any %s, so there&#8217;s nothing to display here at the moment.'),
                    strtolower($labels->name)
                )
            );
        } else {
            $tag_cloud = esc_html(
                sprintf(
                /* translators: %s: taxonomy name */
                    __('Tag cloud not displayed. Taxonomy %s is not registered.'), $attributes['taxonomy']

                )
            );
        }

    }

@bobbingwide bobbingwide self-assigned this May 12, 2022
@bobbingwide bobbingwide added bug Something isn't working Gutenberg A bug / enhancement to Gutenberg labels May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Gutenberg A bug / enhancement to Gutenberg
Projects
None yet
Development

No branches or pull requests

1 participant