Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#7610 closed enhancement (fixed)

Use strpos() instead of preg_match()

Reported by: johnbillion Owned by: westi
Milestone: 2.7 Priority: low
Severity: minor Version: 2.6.1
Component: Optimization Keywords: has-patch
Focuses: Cc:


There's a preg_match() in wp-includes/query.php where strpos() could be used instead, as it's only checking if one string occurs inside another (specifically, if <!--nextpage--> is found within the post content).

Let's replace it with strpos() for some hot optimisation action. Patch coming up.

Attachments (2)

7610.diff (458 bytes) - added by johnbillion 7 years ago.
7610-2.diff (655 bytes) - added by johnbillion 7 years ago.

Download all attachments as: .zip

Change History (6)

@johnbillion7 years ago

comment:1 @johnbillion7 years ago

  • Keywords has-patch added


Note that there's no need to check for equality like the PHP manual recommends when using strpos(), as in our case <!--nextpage--> will not be occuring at the beginning of the post content.

@johnbillion7 years ago

comment:2 @johnbillion7 years ago

  • Summary changed from query.php - Use strpos() instead of preg_match() to Use strpos() instead of preg_match()

Additional patch. Looks like we can do it in wp-mail.php too.

comment:3 @westi7 years ago

  • Milestone set to 2.7
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

comment:4 @westi7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8754]) Performance improvements using strpos. Fixes #7611 and #7610 props johnbillion.

Note: See TracTickets for help on using tickets.