Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#18049 closed defect (bug) (fixed)

PHP 5.4 compatibility warnings on creating default object from empty value

Reported by: eko-fr's profile eko-fr Owned by: nacin's profile nacin
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.2
Component: Warnings/Notices Keywords: has-patch
Focuses: Cc:

Description

After installing PHP 5.4 alpha2-dev on my debian server, I had the following warnings:

Warning: Creating default object from empty value in /var/www/blog/wp-includes/user.php on line 660

Warning: Creating default object from empty value in /var/www/blog/wp-includes/class-wp-admin-bar.php on line 167

I made a little diff patch to correct the problem (attached). It's also available here: https://gist.github.com/1073475

Attachments (2)

diff (1.4 KB) - added by eko-fr 13 years ago.
18049.patch (544 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (13)

@eko-fr
13 years ago

#1 follow-up: @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

It's premature to worry about warnings in a development version of PHP.

Feel free to reopen when PHP 5.4 final is released.

#2 @dd32
13 years ago

  • Milestone set to Awaiting Review
  • Resolution maybelater deleted
  • Status changed from closed to reopened

the current theme one has been mentioned elsewhere, however, These do need at least a new stdClass; added in.

These are not just a php 5.4 thing either.. the error level has just changed for the notice i believe.

#3 @ramoonus
13 years ago

from php.net

Please note that some legacy features have been removed, including: 
■Removed: break/continue $var syntax
■Removed: register_globals, allow_call_time_pass_reference, and register_long_arrays ini options
■Removed: session_is_registered(), session_registered(), and session_unregister()

#4 @nacin
13 years ago

In [18560]:

Instantiate some MS variables as objects before using them. Spaces not tabs for vertical alignment. Remove unnecessary conditional piece. props PeteMall, see #18049.

#5 in reply to: ↑ 1 @ramoonus
13 years ago

Replying to scribu:

It's premature to worry about warnings in a development version of PHP.

Feel free to reopen when PHP 5.4 final is released.

it sounds more usefull to me to reopen when the beta or RC comes out
so if people switch to 5.4.0 final ... there won`t be a problem

Last edited 13 years ago by ramoonus (previous) (diff)

#6 @ramoonus
13 years ago

is this planned for 3.3 or 3.2.x?

#7 @scribu
13 years ago

  • Milestone changed from Awaiting Review to 3.3

#8 @elyobo
13 years ago

I'm in favour; the same problems all occur in 5.3 with E_STRICT enabled, which is a pain for testing if you want to make your own code E_STRICT compatible.

#9 @nacin
13 years ago

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

In [18563]:

Some more class instantiations. props eko-fr, fixes #18049.

#10 @tech163
12 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

In /wp-admin/edit.php on the bottom, you will see

Warning: Creating default object from empty value in /home/wordpress/www/wp-admin/includes/post.php on line 428

I'm not sure how to create a .patch file for it, but adding the following line to line 427/428 fixes it:

		$post = new StdClass();

#11 @nacin
12 years ago

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

In [18847]:

Initialize the post object in get_default_post_to_edit(). props tech163. fixes #18049.

Note: See TracTickets for help on using tickets.