Make WordPress Core

Opened 4 months ago

Last modified 2 months ago

#63656 new defect (bug)

get_page_by_path $post_type supports string and array but the check in the loop is checking by string

Reported by: salimali's profile salimali Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.8
Component: Posts, Post Types Keywords: has-patch needs-testing reporter-feedback
Focuses: Cc:

Description

In the get_page_by_path function, $post_type supports string and array, but the check in the loop is checking by string https://github.com/WordPress/wordpress-develop/blob/6.8.1/src/wp-includes/post.php#L6135, which throws PHP Warning: Array to string conversion in /var/www/html/wp-includes/post.php on line 6135. Example below:

<?php
$page = get_page_by_path('/parent/child/', OBJECT, array('page'));

Change History (9)

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


4 months ago
#1

  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.


4 months ago

#3 @oglekler
4 months ago

  • Keywords needs-testing added
  • Version 6.8 deleted

#4 @dilip2615
4 months ago

  • Keywords needs-testing removed
  • Version set to 6.8

Patch Testing

Description

Tested the patch for Ticket #63656: Twenty Seventeen theme should use the_excerpt() instead of the_content() on search and archive pages.

Environment

  • WordPress: 6.8.1
  • PHP: 8.2.23
  • Server: nginx/1.26.1
  • Database: mysqli (Server: 8.0.16 / Client: mysqlnd 8.2.23)
  • Browser: Chrome 138.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Seventeen 3.9
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Steps to Reproduce

  1. Create a post with content and an excerpt.
  2. View search results or archive page.
  3. See the full content appearing.
  4. Apply the patch from the ticket.
  5. View again → now only the excerpt appears.

Expected Results

✅ Excerpt should be shown on archive/search pages.

Actual Results

✅ Excerpt is shown. Patch works as expected.

Additional Notes

No layout/design issues. Works well with existing posts.

Last edited 4 months ago by dilip2615 (previous) (diff)

#5 follow-up: @mindctrl
4 months ago

  • Keywords needs-testing added

@dilip2615 your test report appears to be for a different ticket?

#6 in reply to: ↑ 5 @dilip2615
4 months ago

Replying to mindctrl:No testing for this current ticket.

@dilip2615 your test report appears to be for a different ticket?

#7 follow-up: @mindctrl
4 months ago

@dilip2615 your test report refers to "Twenty Seventeen theme should use the_excerpt() instead of the_content() on search and archive pages.", but that is not what this ticket is about.

This ticket is about get_page_by_path throwing PHP warnings.

#8 in reply to: ↑ 7 @dilip2615
4 months ago

Replying to mindctrl:

Okay Thanks for the information sorry about my conversation I will check more.

#9 @mindctrl
2 months ago

  • Keywords reporter-feedback added

@salimali thanks for the report. Can you provide steps on how you encountered the PHP notices? The attached PR looks correct, but I'd like to understand how the error is/was triggered in WP.

Note: See TracTickets for help on using tickets.