Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 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:

Description

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

Attachments (2)

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

Download all attachments as: .zip

Change History (12)

@duck_
14 years ago

potentially replace with intersect_assoc

#1 @duck_
14 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
14 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:
http://www.php.net/manual/en/function.array-intersect-key.php

What's proposed:
http://www.php.net/manual/en/function.array-intersect-assoc.php

Another possible alternative is array_intersect:
http://www.php.net/manual/en/function.array-intersect.php

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

#3 @nacin
14 years ago

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

#4 @Otto42
14 years ago

There are several different 4.0 compatible implementations of array_intersect_key on http://www.php.net/manual/en/function.array-intersect-key.php . Suggest just picking one of them that works and putting it in compat.php. Won't matter as of 3.2 anyway.

#5 @sivel
14 years ago

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

http://svn.php.net/repository/pear/packages/PHP_Compat/trunk/Compat/Function/array_intersect_key.php

@johnjamesjacoby
14 years ago

Add array_intersect_key to compat.php

#6 @johnjamesjacoby
14 years ago

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

#7 @ryan
14 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
14 years ago

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

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

#9 @nacin
14 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
14 years ago

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

Note: See TracTickets for help on using tickets.