Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#46848 closed defect (bug) (fixed)

translate_level_to_role may return void in wp-admin/includes/upgrade.php

Reported by: diddledani's profile diddledani Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 2.0
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

The function translate_level_to_role() is defined and used in wp-admin/includes/upgrade.php in the function upgrade_160. The usage requires that the function return a string or numeric to be used in a subsequent array key. The function may return void which cannot be used as a key. For correctness the function should always return a value. Patch attached adds a default selector to the switch statement to achieve this.

Attachments (1)

46848.diff (710 bytes) - added by diddledani 6 years ago.
patch to fix potentially returning void in translate_level_to_role() in upgrade.php

Download all attachments as: .zip

Change History (3)

@diddledani
6 years ago

patch to fix potentially returning void in translate_level_to_role() in upgrade.php

#1 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 5.3

#2 @SergeyBiryukov
5 years ago

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

In 45747:

Upgrade/Install: Make sure translate_level_to_role() always returns a value.

Props diddledan.
Fixes #46848.

Note: See TracTickets for help on using tickets.