WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#14160 closed defect (bug) (fixed)

PHP 4.4+ and PHP 5.0.5 fails on return/pass by reference

Reported by: nacin Owned by:
Milestone: 3.0.1 Priority: normal
Severity: major Version:
Component: Warnings/Notices Keywords:
Focuses: Cc:

Description (last modified by nacin)

This code does not work in PHP 5.0.5:

$post = get_post( wp_insert_post( ... ) );

You get: Fatal error: Only variables can be passed by reference in wp-admin/includes/post.php on line 379

According to the PHP 5 changelog, this was fixed in 5.1.0: "Allowed return by reference from internal functions. (Marcus, Andi, Dmitry)". Related (per my search; not referenced in the changelog): http://bugs.php.net/bug.php?id=34468, http://bugs.php.net/bug.php?id=34424.

I have not tested this on 4.4 but I have not been able to find a mention that this was fixed later in the 4.4 branch. Generally our PHP 4 testing is on 4.3, hence why this was missed.

This was discovered as Earthlink uses 5.0.5 (release date 05-Sep-2005). Committing the fix, assigning first to a local variable as we do elsewhere, for 3.0.1, and recommending to Earthlink they upgrade to at least 5.2.

Related, #13757.

Change History (11)

comment:1 nacin4 years ago

  • Description modified (diff)

comment:2 nacin4 years ago

(In [15358]) Curses on PHP 5.0.5. see #14160 for trunk.

comment:3 nacin4 years ago

(In [15359]) Curses on PHP 5.0.5. see #14160 for 3.0.1

comment:4 hakre4 years ago

Related: [15265]

comment:5 nacin4 years ago

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

comment:6 nacin4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 nacin4 years ago

Found two more:

./wp-admin/includes/nav-menu.php:327:					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( get_the_ID() ) ) ), 0, (object) $args );
./wp-includes/query.php:2741:			$this->queried_object = & get_page(get_option('page_for_posts'));

Interestingly, while the latter just came up in the Earthlink thread, http://wordpress.org/support/topic/411708, it's actually four years and five days old -- [4023].

I'm going to get access to an install on PHP 5.0.5 to confirm whether #13757 also breaks anything.

comment:8 nacin4 years ago

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

(In [15470]) More curses on PHP 5.0.5. see #13757, fixes #14160. for 3.0.1.

comment:9 nacin4 years ago

(In [15471]) More curses on PHP 5.0.5. see #13757, fixes #14160. for trunk.

comment:16 nacin3 years ago

In [18110]:

Take that, PHP 5.0.5. Good riddens. see #14160.

Note: See TracTickets for help on using tickets.