Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#16378 closed defect (bug) (fixed)

Use of array_intersect_key() breaks PHP4 compat

Reported by: ryan's profile ryan Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Warnings/Notices Keywords: has-patch
Focuses: Cc:


Introduced in [17297], use of this function breaks PHP4 compatibility.

Attachments (2)

16378.diff (683 bytes) - added by duck_ 12 years ago.
potentially replace with intersect_assoc
16378.compat.diff (1.1 KB) - added by johnjamesjacoby 12 years ago.
Add array_intersect_key to compat.php

Download all attachments as: .zip

Change History (12)

12 years ago

potentially replace with intersect_assoc

#1 @duck_
12 years ago

  • Keywords has-patch added

The difference caused by changing to array_intersect_assoc is that you couldn't change the title of the action via the filter, if this is tried then that action is also removed from the dropdown.

#2 @johnjamesjacoby
12 years ago

The only difference between 'array_intersect_key' and 'array_intersect_assoc' is when an array item is not 'key => value' but is instead only 'value'.

What's in core now:

What's proposed:

Another possible alternative is array_intersect:

Array intersect seems like it could work too, since the _actions should match exactly if the intent is to potentially remove them.

#3 @nacin
12 years ago

I deliberately chose array_intersect_key to allow modifying the labels. That could be done through gettext though.

#4 @Otto42
12 years ago

There are several different 4.0 compatible implementations of array_intersect_key on . Suggest just picking one of them that works and putting it in compat.php. Won't matter as of 3.2 anyway.

#5 @sivel
12 years ago

I'd suggest that any time we need a compat function we check out the PHP_Compat pear package:

12 years ago

Add array_intersect_key to compat.php

#6 @johnjamesjacoby
12 years ago

Attached diff takes Sivel's suggestion and puts it into compat.php like Otto suggests.

#7 @ryan
12 years ago

Leaning toward assoc. We're going to be dropping the no_new_actions thing once we clean up list tables in 3.2 anyway.

#8 @nacin
12 years ago

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

(In [17369]) Use array_intersec_assoc. props duck_, fixes #16378.

#9 @nacin
12 years ago

I see no reason to create a wrapper for array_intersect_key simply to keep my own cleverness. If anyone wanted to use the filter to modify the strings, they can use gettext instead. As Ryan said, this is gone in 3.2 anyway. Thanks for the efforts though.

#10 @nacin
12 years ago

Props JJJ too per original conversation in IRC. :-)

Note: See TracTickets for help on using tickets.