[wp-trac] [WordPress Trac] #62342: wpdb->get_table_from_query: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

WordPress Trac noreply at wordpress.org
Mon Nov 4 08:40:03 UTC 2024


#62342: wpdb->get_table_from_query: preg_match(): Passing null to parameter #2
($subject) of type string is deprecated
--------------------------+-----------------------------
 Reporter:  kkmuffme      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 e.g. when calling `set_transient(` where the value is extremely long it
 will fail with a backtrack limit error

 Additionally, the regex has an unnecessary "s" flag and is technically
 incorrect since it's not matching balanced tags

 There are 2 options:
 - `/\((?!\s*select)[^()]+\)/i` which reduces backtracking by 65% and is
 also about 20% faster
 - `/\((?!\s*select)(?:[^()]+|(?R))*+\)/i` is the technically correct way
 to match - it's 30% less backtracking and on average as fast as before
 (slightly slower if no matches, slightly faster with matches)

 Additionally, the preg_replace result needs to be validated - if it
 returns null, I'd suggest to retry it with the first, since it's possible
 it won't fail with a backtracking error.

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


More information about the wp-trac mailing list