pull request 49 causes duplicate calls to preg_match() to scan URLs #57

Open
opened 2016-08-03 22:16:41 +01:00 by diablodale · 0 comments
diablodale commented 2016-08-03 22:16:41 +01:00 (Migrated from github.com)

The recent merge of pull request https://github.com/petermolnar/wp-ffpc/pull/49 (related to not caching woocommerce pages) now causes duplicate code to be run in wp-ffpc-acache.php.

wp-ffpc-acache.php,
lines 72-80 ee76a2a9d8 (diff-73d3104eaa45e805aba460e1f5059991R72)
and 105-112 ee76a2a9d8 (diff-73d3104eaa45e805aba460e1f5059991R105)
are basically the same.

  1. they look if there is a regex pattern on an URL to exclude from cache
  2. they call preg_match()
  3. return false if match found

This results is two calls to preg_match() when only one is needed.
I get that someone wants to have an easy way to write the regex expressions. That's the only benefit this provides. I suggest that such a benefit is provided in another way and then the regex values are send into a single preg_match() call.

Ideas like:

  1. with a "help" tab or section in the plugin, if someone has woocommerce installed, put static text of a regex which someone can copy-paste into the primary (only) exclude from cache by URLs field
  2. capture the woocommerce specific regex, save it, then merge it into the main regex, then send that combined regex into a single preg_match() call
The recent merge of pull request https://github.com/petermolnar/wp-ffpc/pull/49 (related to not caching woocommerce pages) now causes duplicate code to be run in wp-ffpc-acache.php. wp-ffpc-acache.php, lines 72-80 https://github.com/petermolnar/wp-ffpc/pull/49/commits/ee76a2a9d8634a62afdeade0ac84d00f8576660c#diff-73d3104eaa45e805aba460e1f5059991R72 and 105-112 https://github.com/petermolnar/wp-ffpc/pull/49/commits/ee76a2a9d8634a62afdeade0ac84d00f8576660c#diff-73d3104eaa45e805aba460e1f5059991R105 are basically the same. 1) they look if there is a regex pattern on an URL to exclude from cache 2) they call preg_match() 3) return false if match found This results is two calls to preg_match() when only one is needed. I get that someone wants to have an easy way to write the regex expressions. That's the only benefit this provides. I suggest that such a benefit is provided in another way and then the regex values are send into a single preg_match() call. Ideas like: 1) with a "help" tab or section in the plugin, if someone has woocommerce installed, put static text of a regex which someone can copy-paste into the primary (only) exclude from cache by URLs field 2) capture the woocommerce specific regex, save it, then merge it into the main regex, then send that combined regex into a single preg_match() call
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: petermolnar/wp-ffpc#57
No description provided.