Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years 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
Priority: normal Milestone: 4.9
Component: General Version:
Severity: normal Keywords: has-patch has-unit-tests dev-reviewed commit
Cc: Focuses:

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 9 years ago.
Check is_array() before calling count()
42498.2.patch​ (519 bytes ) - added by pross 9 years ago.
Use empty()
42498.3.diff​ (2.3 KB ) - added by westonruter 9 years ago.

Download all attachments as: .zip

Change History (10)

@pross
9 years ago

Check is_array() before calling count()

#1 @pross
9 years ago

  • Keywords has-patch added

#2 @johnbillion
9 years ago

  • Keywords needs-testing added
  • Milestone Awaiting Review → 4.9
  • Version trunk

Moving to 4.9 for visibility.

#3 @dd32
9 years ago

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

@pross
9 years ago

Use empty()

#4 @ayeshrajans
9 years ago

  • Summary PHP7.2 Countable → 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

#5 @westonruter
9 years ago

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

#6 @westonruter
9 years ago

  • Resolution → fixed
  • Status accepted → 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
9 years 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.