WordPress.org

Make WordPress Core

Opened 8 months ago

#46000 new defect (bug)

non empty post object in case of error 404

Reported by: petersplugins Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0.3
Component: Rewrite Rules Keywords:
Focuses: Cc:

Description

In case of an 404 error the Posts Object is not empty if permalink setting is something like

/blog/%postname%/

The attached plugin can be used to debug this issue.

How to reproduce the problem

Step 1

Change permalink setting to

/%postname%/

Request a non existing URL like example.com/non-existent.

Result: the Posts Object is empty

Step 2

Change permalink setting to

/blog/%year%/%monthnum%/%postname%/

Request a non existing URL like example.com/non-existent.

Result: the Posts Object is empty

Step 3

Change permalink setting to

/blog/%postname%/

Request a non existing URL like example.com/blog/non-existent.

Result: the Posts Object is empty

Step 4

permalink setting is still

/blog/%postname%/

Request a non existing URL like example.com/non-existent.

Result: the Posts Objec is NOT empty

Impact

Plugins that use the_posts filter may produce wrong results.

I've tested it with 5.0.3 but I'm pretty sure, previous versions are affected also.

Attachments (1)

test.zip (499 bytes) - added by petersplugins 8 months ago.
Test Plugin

Download all attachments as: .zip

Change History (1)

@petersplugins
8 months ago

Test Plugin

Note: See TracTickets for help on using tickets.