Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#62593 new defect (bug)

Condition for doing_it_wrong for conditional tags is too generic

Reported by: kkmuffme's profile kkmuffme Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The condition for doing it wrong on conditionals is too generic, causing it to not trigger in many cases, e.g. is_search(),...
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/query.php#L861

e.g. define WP_DEBUG true and add this to an (mu-)plugin and open a 404 or search page and you'll see that you won't get an error from _doing_it_wrong

<?php
function test_conditionals() {
        if ( is_404() ) {
                wp_die( '404' );
        }

        if ( is_search() ) {
                wp_die( 'search' );
        }
}
add_action( 'setup_theme', 'test_conditionals' );

Change History (2)

This ticket was mentioned in PR #7905 on WordPress/wordpress-develop by @kkmuffme.


2 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @kkmuffme
2 months ago

The PR is a first suggestion for discussion.

There are tons of issues from gutenberg block "register_block_" (e.g. register_block_core_post_featured_image) that calls is_feed() way too early before it's populated.
Could someone from the gutenberg contributors take a look at that?

Note: See TracTickets for help on using tickets.