WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#11176 closed enhancement (fixed)

Convert strpos/strtolower to stripos

Reported by: nacin Owned by:
Milestone: 3.0 Priority: lowest
Severity: trivial Version: 2.9
Component: Performance Keywords: has-patch
Focuses: Cc:

Description

A quick grep shows the core using 18 instances of strpos and strto(low|upp)er in tandem. Most if not all can be converted to stripos.

Attachments (1)

11176.diff (3.9 KB) - added by nacin 6 years ago.

Download all attachments as: .zip

Change History (8)

@nacin6 years ago

comment:1 @nacin6 years ago

  • Keywords has-patch added
  • Milestone changed from Future Release to 3.0
  • Priority changed from normal to lowest
  • Severity changed from normal to trivial

comment:2 @Denis-de-Bernardy6 years ago

@nacin: haven't tested, but did you make sure that the compat functions were loaded in each of those files? if they're not, we'd break php 4 installs.

comment:3 @nacin6 years ago

  • Type changed from defect (bug) to enhancement

Yes, the ones patched should be good. Here are the files that use strpos + strtolower included in the patch:

admin-ajax.php
wp-admin/includes/media.php
wp-admin/includes/class-wp-filesystem-ftpext.php
wp-includes/general-template.php
wp-includes/vars.php

Omitted from patch:
wp-admin/load-scripts.php
wp-admin/load-styles.php
wp-includes/js/tinymce/wp-tinymce.php
wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php

comment:4 @hakre6 years ago

For the log: stripos is available since PHP 5. Most of the hosts will benefit from this change. Nice find.

comment:5 @Denis-de-Bernardy6 years ago

@hakre: stripos also is in compat.php

comment:6 @nacin6 years ago

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

(In [13132]) Use stripos() instead of strpos() with strtolower(). For PHP < 5 we have stripos() in compat.php. Fixes #11176

Note: See TracTickets for help on using tickets.