[wp-trac] [WordPress Trac] #59113: Call to undefined function str_contains() in wp-includes/load.php:1618

WordPress Trac noreply at wordpress.org
Tue Aug 15 19:01:04 UTC 2023


#59113: Call to undefined function str_contains() in wp-includes/load.php:1618
----------------------------+-----------------------------
 Reporter:  lernerconsult   |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Bootstrap/Load  |    Version:  6.3
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 WordPress 6.3 site with PHP 7.4

 PHP Fatal error:  Uncaught Error: Call to undefined function
 str_contains() in wp-includes/load.php:1618
 It seems to be because of using str_contains, a PHP 8.0 function, on a PHP
 7.4 site

 https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/compat.php#L423 defines str_contains for pre-PHP8 sites.

 "If" that PHP8 function is called before the "if ( ! function_exists(
 'str_contains' ) ) { " statement is executed, the function is undefined.

 https://www.php.net/manual/en/functions.user-defined.php "Functions need
 not be defined before they are referenced, except when a function is
 conditionally defined".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59113>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list