Make WordPress Core


Ignore:
Timestamp:
06/24/2023 01:00:15 PM (12 months ago)
Author:
SergeyBiryukov
Message:

General: Replace substr_compare() usage in the str_ends_with() polyfill.

This avoids a warning on PHP < 7.2.18 if haystack is an empty string:

Warning: substr_compare(): The start position cannot exceed initial string length

Follow-up to [52040], [55158], [55990], [56014].

See #58220.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/compat.php

    r55726 r56015  
    489489        $len = strlen( $needle );
    490490
    491         return 0 === substr_compare( $haystack, $needle, -$len, $len );
     491        return $needle === substr( $haystack, -$len, $len );
    492492    }
    493493}
Note: See TracChangeset for help on using the changeset viewer.