Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21716 closed defect (bug) (fixed)

PHP 5.4 warning when updating plugins

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

Description

When updating plugins from either /wp-admin/network/update-core.php (Multisite) or from /wp-admin/update-core.php (Single site) I get this error logged (many times), using PHP 5.4:

PHP Warning:  Creating default object from empty value in /mysite/wp-admin/includes/update.php on line 90

update-core.php:89 reads

	if ( ! isset( $cur->current ) )
		$cur->current = '';

I'm not sure what is the best approach to avoid this. Both the bad (?)

		@$cur->current = '';

and the better (?)

	if ( ! is_object( $cur ) )
		$cur = new stdClass;
	if ( ! isset( $cur->current ) )
		$cur->current = '';

will avoid the warning, and seems to work.

Attachments (1)

21716.patch (449 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (6)

#1 @knutsp
12 years ago

  • Cc knut@… added
  • Keywords needs-patch removed

#2 @SergeyBiryukov
12 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.5

#3 @SergeyBiryukov
12 years ago

  • Component changed from Plugins to Warnings/Notices

#4 @SergeyBiryukov
12 years ago

Closed #21838 as a duplicate.

#5 @ryan
12 years ago

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

In [21815]:

Avoid 'Creating default object from empty value' warning in PHP 5.4. Props SergeyBiryukov, knutsp. fixes #21716

Note: See TracTickets for help on using tickets.