diff --git a/patches/d10-3.json b/patches/d10-3.json index 3aa70307e689e0605f631a62166d8237729e5e5a..f37823c02148b9001c8eff75ba6210496fc0f69a 100644 --- a/patches/d10-3.json +++ b/patches/d10-3.json @@ -145,7 +145,7 @@ }, "drupal/linkchecker": { "#3376854 Base path": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3376854.diff", - "#3313343 Disable cron": "https://www.drupal.org/files/issues/2022-10-03/support_disabling_cron-3313343-2.patch" + "#3313343 Disable cron": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3313343-3.diff" }, "drupal/linkit": { "#3442127 Deprecate Drupal.EditorFeature": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442127.diff" diff --git a/patches/d10-4.json b/patches/d10-4.json index 1862be3975feb77c517315dd89c2c35886630a78..e453976391a5672371ee71bc29a1baef070067ce 100644 --- a/patches/d10-4.json +++ b/patches/d10-4.json @@ -145,7 +145,7 @@ }, "drupal/linkchecker": { "#3376854 Base path": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3376854.diff", - "#3313343 Disable cron": "https://www.drupal.org/files/issues/2022-10-03/support_disabling_cron-3313343-2.patch" + "#3313343 Disable cron": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3313343-3.diff" }, "drupal/linkit": { "#3442127 Deprecate Drupal.EditorFeature": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442127.diff" diff --git a/patches/d10/3313343-3.diff b/patches/d10/3313343-3.diff new file mode 100644 index 0000000000000000000000000000000000000000..0b9408581eaab8f60ad187b39bda90b84e23baf8 --- /dev/null +++ b/patches/d10/3313343-3.diff @@ -0,0 +1,100 @@ +diff --git a/config/install/linkchecker.settings.yml b/config/install/linkchecker.settings.yml +index f3311437c5beb3072a353b5047d769850442f95b..649a0131a1681b1ac2c01fda257dd5b34b61b5f5 100644 +--- a/config/install/linkchecker.settings.yml ++++ b/config/install/linkchecker.settings.yml +@@ -26,6 +26,7 @@ check: + library: core + interval: 2419200 + useragent: 'Drupal (+http://drupal.org/)' ++ disable_cron: false + error: + action_status_code_301: 0 + action_status_code_404: 0 +diff --git a/config/schema/linkchecker.schema.yml b/config/schema/linkchecker.schema.yml +index ef877deae66f38e145048b9d4a14104479107e56..357ec2eeed64da1dab200f64199fc8a6e8a7f0ad 100644 +--- a/config/schema/linkchecker.schema.yml ++++ b/config/schema/linkchecker.schema.yml +@@ -72,6 +72,9 @@ linkchecker.settings: + useragent: + type: string + label: 'User-Agent' ++ disable_cron: ++ type: boolean ++ label: 'Disable cron processing and queueing' + error: + type: mapping + label: 'Error handling' +diff --git a/linkchecker.module b/linkchecker.module +index 7b305e40e472338cd2b6a8ee2a354843d4c149dc..e2b7b88da60cb4809298342cec0fdc0716673de7 100644 +--- a/linkchecker.module ++++ b/linkchecker.module +@@ -148,6 +148,9 @@ function linkchecker_form_field_config_form_builder($entity_type, FieldConfigInt + * Implements hook_cron(). + */ + function linkchecker_cron() { ++ if (\Drupal::config('linkchecker.settings')->get('check.disable_cron')) { ++ return; ++ } + \Drupal::service('linkchecker.extractor_batch')->processEntities(); + \Drupal::service('linkchecker.checker')->queueLinks(); + } +diff --git a/src/Form/LinkCheckerAdminSettingsForm.php b/src/Form/LinkCheckerAdminSettingsForm.php +index f17e6667a482b57ddfaba34ec9d87cb51aec6d95..247bd82ad256719c62495750d1af8e5aba5d7d2d 100644 +--- a/src/Form/LinkCheckerAdminSettingsForm.php ++++ b/src/Form/LinkCheckerAdminSettingsForm.php +@@ -74,6 +74,11 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase { + */ + protected $linkCheckerResponseCodes; + ++ /** ++ * The module handler. ++ */ ++ protected ModuleHandlerInterface $moduleHandler; ++ + /** + * The current user. + * +@@ -357,6 +362,12 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase { + RfcLogLevel::ERROR => $this->t('Errors only'), + ], + ]; ++ $form['check']['linkchecker_check_disable_cron'] = [ ++ '#default_value' => $config->get('check.disable_cron'), ++ '#type' => 'checkbox', ++ '#title' => $this->t('Disable cron processing and queueing'), ++ '#description' => $this->t('Check this box if you will be queueing and processing links via Drush or some other method. <strong>Enabling this will completely disable automatic link queueing and processing.</strong>'), ++ ]; + + $form['error'] = [ + '#type' => 'details', +@@ -364,11 +375,12 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase { + '#description' => $this->t('Defines error handling and custom actions to be executed if specific HTTP requests are failing.'), + '#open' => TRUE, + ]; ++ /** @var \Drupal\user\UserInterface|null $linkchecker_default_impersonate_account */ + $linkchecker_default_impersonate_account = $this->userStorage->load(1); + $form['error']['linkchecker_impersonate_account'] = [ + '#type' => 'textfield', + '#title' => $this->t('Impersonate user account'), +- '#description' => $this->t('If below error handling actions are executed they can be impersonated with a custom user account. By default this is user %name, but you are able to assign a custom user to allow easier identification of these automatic revision updates. Make sure you select a user with <em>full</em> permissions on your site or the user may not able to access and save all content.', ['%name' => $linkchecker_default_impersonate_account->getAccountName()]), ++ '#description' => $this->t('If below error handling actions are executed they can be impersonated with a custom user account. By default this is user %name, but you are able to assign a custom user to allow easier identification of these automatic revision updates. Make sure you select a user with <em>full</em> permissions on your site or the user may not able to access and save all content.', ['%name' => $linkchecker_default_impersonate_account?->getAccountName() ?? '[UID 1 not found]']), + '#size' => 30, + '#maxlength' => 60, + '#autocomplete_path' => 'user/autocomplete', +@@ -388,7 +400,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase { + ], + ]; + if ($this->moduleHandler->moduleExists('dblog') && $this->currentUser->hasPermission('access site reports')) { +- $form['error']['#description'] = $this->t('If enabled, outdated links in content providing a status ++ $form['error']['#description'] = $this->t('If enabled, outdated links in content providing a status + <em>Moved Permanently</em> (status code 301) are automatically updated to the most recent URL. If used, + it is recommended to use a value of <em>three</em> to make sure this is not only a temporarily change. + This feature trust sites to provide a valid permanent redirect. +@@ -506,6 +518,7 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase { + ->set('check.library', $form_state->getValue('linkchecker_check_library')) + ->set('check.interval', $form_state->getValue('linkchecker_check_interval')) + ->set('check.useragent', $form_state->getValue('linkchecker_check_useragent')) ++ ->set('check.disable_cron', $form_state->getValue('linkchecker_check_disable_cron')) + ->set('search_published_contents_only', $form_state->getValue('search_published_contents_only')) + ->set('error.action_status_code_301', $form_state->getValue('linkchecker_action_status_code_301')) + ->set('error.action_status_code_404', $form_state->getValue('linkchecker_action_status_code_404')) diff --git a/patches/d11.json b/patches/d11.json index 51c3089313803808c1657c7b9fef93d4d57fb558..b170065b7662b86900a2ebd28f7458188d69f3e7 100644 --- a/patches/d11.json +++ b/patches/d11.json @@ -141,7 +141,7 @@ }, "drupal/linkchecker": { "#3376854 Base path": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3376854.diff", - "#3313343 Disable cron": "https://www.drupal.org/files/issues/2022-10-03/support_disabling_cron-3313343-2.patch" + "#3313343 Disable cron": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3313343-3.diff" }, "drupal/linkit": { "#3442127 Deprecate Drupal.EditorFeature": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442127.diff"