Skip to content

Enhanced Pagination throws notices if Query ID is not defined. #55719

@peterwilsoncc

Description

@peterwilsoncc

Description

Enhanced pagination of the query block throws notices if the query ID is not defined.

Notice: Undefined index: queryId in .../gutenberg/build/block-library/blocks/query.php on line 150
Notice: Undefined index: queryId in .../gutenberg/build/block-library/blocks/query.php on line 25
Notice: Undefined index: queryId in .../gutenberg/build/block-library/blocks/query.php on line 170

In the Site Editor, it appears this is prevented from happening, so the issue only occurs if the incorrect markup is used in the files of a distributed theme.

I think if the queryId is not defined, then enhanced pagination can be prevented. Generating a queryId could work but may lead to collisions if there are two queries on the page and one of them has the value defined.

Step-by-step reproduction instructions

  1. Enabled debug mode in your wp-config file:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', true );
  2. Download and activate peters-sample-theme.zip which contains bad markup in templates/index.html
  3. Visit the theme on the front end of the site.
  4. Observe the notices thrown

Screenshots, screen recording, code snippet

Stack trace attached, it's quite a lot because it's generated with xdebug enabled.

debug.log

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

Labels

[Block] Query LoopAffects the Query Loop Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions