WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 6 weeks ago

#46848 closed defect (bug) (fixed)

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

Reported by: diddledan Owned by: 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 diddledan 5 months ago.
patch to fix potentially returning void in translate_level_to_role() in upgrade.php

Download all attachments as: .zip

Change History (3)

@diddledan
5 months ago

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

#1 @SergeyBiryukov
5 months ago

  • Milestone changed from Awaiting Review to 5.3

#2 @SergeyBiryukov
6 weeks 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.