From 2c08b349a6d8e7c659505da27808e832838b3ff8 Mon Sep 17 00:00:00 2001 From: Delphine Lepers Date: Mon, 29 Jul 2019 08:12:44 +0000 Subject: [PATCH 1/2] NEPT-2332: Remove "check scope" button. --- README.md | 4 ++-- nexteuropa_varnish.rules.admin.inc | 34 ------------------------------ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b658e0f..12c9148 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,6 @@ Therefore, if you entered a rule in a previous version and this rule does not ma in place, a warning will appear : ``` Please check your varnish rules , the regex ^an-already-inserted/rule you are trying to flush is not valid. -We suggest you review and save your regex rules again using the documentation available and the -"Check Scope" button. In case of doubt, please contact your site administrator or the devops team. +We suggest you review and save your regex rules again using the documentation available. +In case of doubt, please contact your site administrator or the devops team. ``` diff --git a/nexteuropa_varnish.rules.admin.inc b/nexteuropa_varnish.rules.admin.inc index f833c00..088612a 100644 --- a/nexteuropa_varnish.rules.admin.inc +++ b/nexteuropa_varnish.rules.admin.inc @@ -68,12 +68,6 @@ function nexteuropa_varnish_cache_purge_rule_form($form, &$form_state, $purge_ru '#required' => TRUE, '#description' => _nexteuropa_varnish_paths_description(), ); - $form['specifics']['actions']['check_scope'] = array( - '#type' => 'submit', - '#value' => t('Check scope'), - '#submit' => array('_nexteuropa_varnish_check_scope'), - '#weight' => 41, - ); $form['#validate'][] = '_nexteuropa_varnish_regex_validate'; } @@ -104,33 +98,6 @@ function _nexteuropa_varnish_regex_validate($form, &$form_state) { } } -/** - * Custom function checks which site URLs match the regex pattern. - */ -function _nexteuropa_varnish_check_scope(&$form, &$form_state) { - $output = ''; - $regex = _nexteuropa_varnish_gather_expressions($form_state['values']['paths']); - $query = db_select('url_alias', 'u') - ->fields('u'); - $or = db_or(); - $or->condition('alias', $regex, 'REGEXP'); - $query->condition($or); - $query = $query->extend('PagerDefault')->limit(100); - $results = $query->execute(); - - $headers = array('URL alias'); - $rows = array(); - foreach ($results as $u) { - $rows[] = array($u->alias); - } - if (!empty($rows)) { - $output = theme('table', array('header' => $headers, 'rows' => $rows)) . theme('pager'); - } - - $form_state['rebuild'] = TRUE; - $form_state['scope'] = $output; -} - /** * Custom function that gather the regex entered into one single expression. */ @@ -156,7 +123,6 @@ function nexteuropa_varnish_cache_purge_rule_type_selection($form, $form_state) function _nexteuropa_varnish_paths_description() { $regex_descriptions = array( t('Add ^ at the begining of each path, unless you want to match using part of the path.
Example : ^content\/article\/(how-to-.*|faqs\/.*) will match content/article/how-to-use-regex and content/article/faqs/using-regex but not my-content/article/how-to-use-regex'), - t('You can test your site URLs matching the regex by clicking the Check scope button.'), t('Regex validation is done at save. For example, if you try saving * alone, you will get an error.'), ); From 8f6585596cc410e38f0f127cd9adaa7298ab8860 Mon Sep 17 00:00:00 2001 From: Delphine Lepers Date: Wed, 31 Jul 2019 08:49:55 +0000 Subject: [PATCH 2/2] NEPT-2332: Remove more references to scope button. --- README.md | 2 -- nexteuropa_varnish.module | 2 +- nexteuropa_varnish.rules.admin.inc | 9 --------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index 12c9148..839a8f8 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,6 @@ The option **`A specific list of regex`** allows defining a set of regex matchi The field description provides hints for testing validity of the regex you entered in the field. -The `Check scope` button allows evaluating if the regex is built to return the paths you would expect to clear. - After setting up a rule you need to submit it by clicking the **'Save'** button. If the regular expression you entered is not valid, the following warning will be shown ``` diff --git a/nexteuropa_varnish.module b/nexteuropa_varnish.module index 6b6bba4..f3f8526 100644 --- a/nexteuropa_varnish.module +++ b/nexteuropa_varnish.module @@ -452,7 +452,7 @@ function _nexteuropa_varnish_purge_paths($paths) { else { drupal_set_message( t( - 'Please !check_config, the regex %regex you are trying to flush is not valid. We suggest you review and save your regex rules again using the documentation available and the "Check Scope" button. In case of doubt, please contact your site administrator or the devops team.', + 'Please !check_config, the regex %regex you are trying to flush is not valid. We suggest you review and save your regex rules again using the documentation available. In case of doubt, please contact your site administrator or the devops team.', array( '!check_config' => l( t('check your varnish rules'), diff --git a/nexteuropa_varnish.rules.admin.inc b/nexteuropa_varnish.rules.admin.inc index 088612a..c4ace07 100644 --- a/nexteuropa_varnish.rules.admin.inc +++ b/nexteuropa_varnish.rules.admin.inc @@ -43,15 +43,6 @@ function nexteuropa_varnish_cache_purge_rule_form($form, &$form_state, $purge_ru '#prefix' => '
', '#suffix' => '
', ); - // Code here to populate the scope container. - // @TODO views paths? - if (isset($form_state['scope'])) { - $warning = '

Here is the 100 first results matching your regex

'; - $warning .= '

Your rule was not saved, to save it click "Save" button

'; - $form['scope']['#prefix'] = '
'; - $form['scope']['#suffix'] = '
'; - $form['scope']['#markup'] = $warning . $form_state['scope']; - } $current_rule_type = isset($form_state['values']['rule_type']) ? $form_state['values']['rule_type'] : $type_default_value;