[wp-trac] [WordPress Trac] #44168: Add is_countable() check to wp-admin/includes/ajax-actions.php

WordPress Trac noreply at wordpress.org
Fri Jun 1 19:39:12 UTC 2018


#44168: Add is_countable() check to wp-admin/includes/ajax-actions.php
-----------------------------+------------------------------
 Reporter:  thrijith         |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |     Focuses:  administration
-----------------------------+------------------------------
Changes (by desrosj):

 * keywords:  has-patch reporter-feedback => has-patch close
 * focuses:   => administration
 * version:  trunk =>


Comment:

 Thanks for your work on this, @thrijith!

 I do not think that `is_countable()` is needed for any of these instances
 of `count()`, though. `is_countable()` should only be used before counting
 a value where it's valid for either a countable or non-countable value to
 be passed (see [ticket 44123#comment:11).

 - While it is possible for the `get_ancestors()` function to return an
 uncountable value if a plugin or theme incorrectly uses the
 `get_ancestors` filter, this would be a bug.
 - `$wp_list_table->items` could also not be countable. But this also
 indicates a bug in the list table class being used.
 - The third example is already preceded by a `! is_array()` check and
 would never be reached if the `$exporters` variable is not countable.
 - If a plugin or theme is incorrectly using the
 `wp_privacy_personal_data_erasers` filter, this is a bug and the warning
 should not be suppressed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44168#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list