WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#29262 closed defect (bug) (invalid)

PHP warning on update check when plugins or translations arrays are empty

Reported by: yoavf Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

URL visited: /wp-admin/update-core.php?force-check=1

Request sent to api server:
URL: https://api.wordpress.org/plugins/update-check/1.1/
Request body:

array (
    'plugins' => '{"plugins":{"hello.php":{"Name":"Hello Dolly","PluginURI":"http:\\/\\/wordpress.org\\/plugins\\/hello-dolly\\/","Version":"1.6","Description":"This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly<\\/cite> in the upper right of your admin screen on every page.","Author":"Matt Mullenweg","AuthorURI":"http:\\/\\/ma.tt\\/","TextDomain":"","DomainPath":"","Network":false,"Title":"Hello Dolly","AuthorName":"Matt Mullenweg"}},"active":[]}',
    'translations' => '{"akismet":{"de_DE":{"POT-Creation-Date":"","PO-Revision-Date":"2014-04-16 09:59:39+0000","Project-Id-Version":"Development","X-Generator":"GlotPress\\/0.1"}},"wordpress-importer":{"he_IL":{"POT-Creation-Date":"","PO-Revision-Date":"2011-08-05 09:40:04+0000","Project-Id-Version":"Development (trunk)","X-Generator":"GlotPress\\/0.1"}}}',
    'locale' => '["he_IL"]',
    'all' => 'true',
  ),

Response body

'body' => '{"plugins":[],"translations":[]}',

PHP Warning

PHP Warning:  Invalid argument supplied for foreach() in /srv/www/wordpress-develop/src/wp-includes/update.php on line 312

Attachments (1)

update-warning-1.diff (914 bytes) - added by yoavf 7 years ago.
Casting to array in the foreach won't work because we're accessing the elements by ref

Download all attachments as: .zip

Change History (7)

@yoavf
7 years ago

Casting to array in the foreach won't work because we're accessing the elements by ref

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Upgrade/Install

#2 @SergeyBiryukov
7 years ago

I could not reproduce the warning. Both plugins and translations are correctly unserialized to empty arrays.

Looks like the warning was caused by a missing no_update element, but I could not reproduce that either.

#3 @markoheijnen
7 years ago

Unsure what version you did used since line 312 isn't a foreach loop. Seeing you response body it is because no_update wasn't send and then the foreach loop will throw this warning.

#4 @nacin
7 years ago

  • Keywords reporter-feedback added

#5 follow-up: @nacin
7 years ago

  • Milestone changed from 4.0 to Awaiting Review

yoavf, I wonder if this is because you are hitting an out-of-date copy of the API, sandboxed.

#6 in reply to: ↑ 5 @yoavf
7 years ago

  • Keywords has-patch reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to nacin:

yoavf, I wonder if this is because you are hitting an out-of-date copy of the API, sandboxed.

That was it - sorry about that!

Note: See TracTickets for help on using tickets.