Opened 12 months ago

Closed 8 months ago

Last modified 5 months ago

#20867 closed defect (bug) (fixed)

Notice: Array to string conversion

Reported by: arieputranto Owned by: nacin
Priority: normal Milestone: 3.5
Component: Post Types Version: 3.1
Severity: normal Keywords: has-patch
Cc: justin@…

Description

PHP Notice

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

Attachments (2)

20867.patch (442 bytes) - added by SergeyBiryukov 9 months ago.
20867.2.patch (541 bytes) - added by SergeyBiryukov 9 months ago.

Download all attachments as: .zip

Change History (12)

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.

  • Component changed from General to Post Types
  • Keywords reporter-feedback added
  • 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 11 months ago by SergeyBiryukov (previous) (diff)
  • Keywords has-patch removed

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

Array
(
    [0] => archive-Array.php
    [1] => archive.php
)
  • Keywords needs-patch added; reporter-feedback removed
  • 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.

  • Cc justin@… added
  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 3.5
  • 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.

Follow-up: #22956

Note: See TracTickets for help on using tickets.