Making WordPress.org


Ignore:
Timestamp:
01/07/2021 05:50:27 AM (6 years ago)
Author:
dd32
Message:

Events API: Avoid a PHP Warning when invalid UTF8 character sequences are encountered.

Fixes PHP warnings such as count(): Parameter must be an array or an object that implements Countable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/index.php

    r10554 r10555  
    324324         */
    325325        $location_name_parts = preg_split( '/[,\s]+/u', $location_name );
     326        if ( ! $location_name_parts ) {
     327                // Invalid/Unsupported UTF8 characters encountered.
     328                $location_name_parts = array( $location_name );
     329        }
    326330        $location_word_count = count( $location_name_parts );
    327331
    … …  
    698702        $country             = get_country_from_name( $location_name );
    699703        $location_name_parts = preg_split( '/\s+/u', $location_name );
     704        if ( ! $location_name_parts ) {
     705                // Invalid/Unsupported UTF8 characters encountered.
     706                $location_name_parts = array( $location_name );
     707        }
    700708        $location_word_count = count( $location_name_parts );
    701709
Note: See TracChangeset for help on using the changeset viewer.