WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#20867 closed defect (bug) (fixed)

Notice: Array to string conversion

Reported by: arieputranto Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

PHP Notice

Array to string conversion on \wp-includes\template.php on line 67

Attachments (2)

20867.patch (442 bytes) - added by SergeyBiryukov 3 years ago.
20867.2.patch (541 bytes) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 @duck_3 years ago

Could you give the query that's producing this? Quick testing with a multi-post type query and I can't get the archive template to be loaded.

Also, it's likely this can be triggered since 3.1.

comment:2 @SergeyBiryukov3 years ago

  • Component changed from General to Post Types
  • Keywords reporter-feedback added

comment:3 @arieputranto3 years ago

  • Keywords has-patch added

It happened when the post_format archive is being loaded e.g.: http://localhost/type/media

I fixed mine by adding a line on line: 65 of wp-includes/template.php:

$post_type = $post_type[0];

$wp_query->query['post_format'] and $wp_query->query_vars['post_format']

are indeed an array.

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

comment:4 @SergeyBiryukov3 years ago

  • Keywords has-patch removed

Confirmed. $templates in get_archive_template() ends up being this:

Array
(
    [0] => archive-Array.php
    [1] => archive.php
)

comment:5 @SergeyBiryukov3 years ago

  • Keywords needs-patch added; reporter-feedback removed

comment:6 @duck_3 years ago

  • Version changed from 3.4 to 3.1

Caused by the post_type query variable being set to an array by _post_format_request(), see [17249] for #16149.

Similar #18475.

comment:7 @greenshady3 years ago

  • Cc justin@… added

comment:8 @SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 3.5

@SergeyBiryukov3 years ago

@SergeyBiryukov3 years ago

comment:9 @nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21861]:

Expect a possible array of post types in get_archive_template(). props SergeyBiryukov. fixes #20867.

comment:10 @scribu2 years ago

Follow-up: #22956

Note: See TracTickets for help on using tickets.