Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#20867 closed defect (bug) (fixed)

Notice: Array to string conversion

Reported by: arieputranto's profile arieputranto Owned by: nacin's profile 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 12 years ago.
20867.2.patch (541 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (12)

#1 @duck_
13 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.

#2 @SergeyBiryukov
13 years ago

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

#3 @arieputranto
12 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 12 years ago by SergeyBiryukov (previous) (diff)

#4 @SergeyBiryukov
12 years ago

  • Keywords has-patch removed

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

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

#5 @SergeyBiryukov
12 years ago

  • Keywords needs-patch added; reporter-feedback removed

#6 @duck_
12 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.

#7 @greenshady
12 years ago

  • Cc justin@… added

#8 @SergeyBiryukov
12 years ago

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

#9 @nacin
12 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.

#10 @scribu
12 years ago

Follow-up: #22956

Note: See TracTickets for help on using tickets.