Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#10047 closed defect (bug) (fixed)

[Code Review] An array should not be directly put into a string

Reported by: kamiyeye Owned by:
Milestone: 2.8 Priority: high
Severity: blocker Version: 2.8
Component: Template Keywords: has-patch
Focuses: Cc:



In latest wordpress 2.8 nightly build, file wp-includes/link-template.php, function get_boundary_post, from line 1037 to 1041

$categories = array_merge($cat_array, $excluded_categories);

$order = $start ? 'ASC' : 'DESC';

return get_posts("numberposts=1&order=$order&orderby=ID&category=$categories");

As you see, $categories is an array, it should not be used in this way, which will cause a string "Array" in php, am i right?


I noticed these codes are part of 2.8 new feature "display adjacent relational links in the head" - Ticket #8703, thus determine Severity to be major. If it doesn't meet your bug evaluation principle, feel free to point it.

Attachments (1)

10047.diff (978 bytes) - added by dd32 5 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added
  • Severity changed from major to blocker

comment:2 dd325 years ago

Core shouldn't be using the string notation anyway.. It should be passing an array for this exact reason.

I'll make up a patch in an hour if no-one else is making one.

dd325 years ago

comment:3 dd325 years ago

  • Keywords has-patch added; needs-patch removed

attachment 10047.diff added

  • Changes the code mentioned to use array notation
  • Changes a XMLRPC call to array notation as well (Changed it earlier.. not because it was buggy though)

For anyone elses reference, Heres a quick regex to pull up the locations where the string notation is used:


comment:4 ryan5 years ago

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

(In [11528]) Use array instead of query string notation. Prop dd32, kamiyeye. fixes #10047

Note: See TracTickets for help on using tickets.