WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#42498 closed defect (bug) (fixed)

Replace count() call with empty() in get_settings_errors() to prevent PHP 7.2 warnings

Reported by: pross Owned by: westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests dev-reviewed commit
Focuses: Cc:

Description

Related #40109

In latest PHP7.1 RC6 any settings page throws a warning Warning: count(): Parameter must be an array or an object that implements Countable in /****/public_html/wp-admin/includes/template.php on line 1460

Attachments (3)

42498.patch (558 bytes) - added by pross 7 months ago.
Check is_array() before calling count()
42498.2.patch (519 bytes) - added by pross 7 months ago.
Use empty()
42498.3.diff (2.3 KB) - added by westonruter 7 months ago.

Download all attachments as: .zip

Change History (10)

@pross
7 months ago

Check is_array() before calling count()

#1 @pross
7 months ago

  • Keywords has-patch added

#2 @johnbillion
7 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to 4.9
  • Version trunk deleted

Moving to 4.9 for visibility.

#3 @dd32
7 months ago

In this case It'd probably be better to change it to if ( empty( $wp_settings_errors ) ) return array();

@pross
7 months ago

Use empty()

#4 @ayeshrajans
7 months ago

  • Summary changed from PHP7.2 Countable to Replace count() call with empty() in get_settings_errors() to prevent PHP 7.2 warnings

Updated the issue title to convey more information at glance. 👍 42498.2.patch

@westonruter
7 months ago

#5 @westonruter
7 months ago

  • Keywords has-unit-tests dev-reviewed commit added; needs-testing removed
  • Owner set to westonruter
  • Status changed from new to accepted

#6 @westonruter
7 months ago

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

In 42146:

Settings: Replace count() call with empty() in get_settings_errors() to prevent PHP 7.2 warnings when $wp_settings_errors is null.

Props pross, dd32, westonruter.
See #40109.
Fixes #42498 for trunk.

#7 @westonruter
7 months ago

In 42147:

Settings: Replace count() call with empty() in get_settings_errors() to prevent PHP 7.2 warnings when $wp_settings_errors is null.

Props pross, dd32, westonruter.
See #40109.
Fixes #42498 for 4.9.

Note: See TracTickets for help on using tickets.