Problem/Motivation

We have a large site with over 100k links indexed. We would like more granular control over when and how many links are scanned, and want to decouple link scanning from cron. Fortunately it's easy to set up our own ad hoc schedule using the drush commands (thank you!) but there's not an option to disable the cron check.

Proposed resolution

Add a "Disable cron" option to the "Check settings" part of the config form. Do not run during cron if this is checked.

Remaining tasks

I guess a test would be good.

User interface changes

Adding a checkbox to the config form.

API changes

None.

Data model changes

Adding a config setting to the schema.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joshf created an issue. See original summary.

joshf’s picture

Assigned: joshf » Unassigned
Status: Active » Needs review
StatusFileSize
new2.98 KB

Status: Needs review » Needs work

The last submitted patch, 2: support_disabling_cron-3313343-1.patch, failed testing. View results

joshf’s picture

StatusFileSize
new2.99 KB

This should fix the reported schema error.

joshf’s picture

Status: Needs work » Needs review
bburg’s picture

+1, Would really like to skip link checking for local development.

solideogloria’s picture

You could install Ultimate Cron, then disable the individual linkchecker cron task

eiriksm’s picture

Issue tags: +Needs tests

Would be great to have a simple test for this as well, before we commit it

jurgenhaas’s picture

I've tested this just now and it works as expected. Not setting it to RTBC as for outstanding test coverage.

c-logemann’s picture

I agree that we should increase test coverage. But in this case I think we don't need an extra test: "if disabled it's truly not running at cron".

c-logemann’s picture

In any case it would be helpful if there is a merge request for this change.

solideogloria’s picture

Added changes from #4 to a MR

solideogloria’s picture

Title: D8: Add option to disable cron activity » Add option to disable cron activity
solideogloria’s picture

It works. Just wondering, should a message be logged when cron link checking is skipped?

c-logemann’s picture

> should a message be logged when cron link checking is skipped?

I don't think so. Especially on functionality like linkchecker I like to control this directly with own cron jobs without extra modules. So this logging if someone like to add should also get an own config to disable.

alexh’s picture

I can confirm that the patch is working.
On the other hand, I can also recommend to install Ultimate Cron module, which provides an easy UI to schedule each module's cron run differently, e.g. linkchecker only once or several times in the night. No patch needed in that scenario.

vladimiraus’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

Thanks for your contribution.
Can we update the it to the latest branch?

solideogloria changed the visibility of the branch 2.0.x to hidden.

solideogloria’s picture

Status: Needs work » Needs review
solideogloria’s picture

Also, the settings form in 2.x had an error, so I fixed that here as well.

https://git.drupalcode.org/project/linkchecker/-/merge_requests/75/diffs...

If you want to merge it earlier than this issue, you can fix it here:

#3463362: Linkchecker settings form error

VladimirAus changed the visibility of the branch 3313343-disable-cron to hidden.

vladimiraus’s picture

Status: Needs review » Needs work

hook_update for new config property?

solideogloria’s picture

Status: Needs work » Needs review
jurgenhaas’s picture

I've rebased the MR!75

vladimiraus’s picture

Status: Needs review » Needs work

Thanks @solideogloria. Looks like you did commit to old branch.
Outstanding tasks

  • MR 75 need hook_update from MR 49
  • Remove gitignore
solideogloria’s picture

Rebased MR.

solideogloria’s picture

Status: Needs work » Needs review

I still think .gitignore should be added, as Drupal recommends DDEV for contributing, and DDEV adds all those files. It's helpful to ensure they don't get accidentally added to the project. I removed it as you requested.

solideogloria’s picture

I also added the missing update hook

jurgenhaas’s picture

Just left a comment in the MR

jurgenhaas’s picture

Looks like the changes in LinkExtracto‎rService.php‎ and LinkcheckerLinkPa‎geEntityLabel.php‎ are unrelated to this issue and should be removed from the MR, I guess?

jurgenhaas’s picture

Version: 2.0.x-dev » 2.1.x-dev

I've rebased MR !75 for 2.0.x and I've created MR !129 for 2.1.x

anybody’s picture

Status: Needs review » Needs work

Thanks, I just ran into the same issue and tried MR !129. LGTM and works like a charm.

Still this has "Needs tests", so if that's still valid, this needs (final) work. Just to be totally sure: besides Cron, linkchecker currently can only be run manually, right? There's nothing else hidden (like check on node save, etc.) that could cause it to run? Otherwise we should also add a setting for that.

As Drupal 8+ has no way to "disable" modules, just uninstalling it, this option totally makes sense!

Edit:
The answer is NO, it has further effects! See #3581562: Add option to disable Linkchecker (esp. entity hooks)

anybody’s picture

solideogloria’s picture

It also has Drush commands that run it, which could be run from CLI.

anybody’s picture

Thanks @solideogloria yes, but that's at least triggered manually. More risky is the hidden hook functionality, see #35 and the issue description in #3581562: Add option to disable Linkchecker (esp. entity hooks)

ericgsmith made their first commit to this issue’s fork.

ericgsmith’s picture

Status: Needs work » Needs review

This is exactly what I'm after

I don't think states is needed to hide anything - disable cron still allows us to use drush so we want all items visible - not sure it is important enough to elevate, I think people will find it if they are looking for it.

Adding a minimal test - test only job just shows schema errors so not very useful, but everything else is green

anybody’s picture

Issue tags: -Needs tests

Thanks @ericgsmith. I think besides this #3581562: Add option to disable Linkchecker (esp. entity hooks) is (even more) important. Thanks for the test!

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

I scanned through the code changes and the comment @anybody left about the UI. I think the UI and states thing doesn't need to hold this up and would recommend @anybody or anybody to create a follow-up if they feel strongly about the position of the field.

The code looks clean, no notes, let's merge and move forward.

anybody’s picture

Position is fine for me, if it's fine for you and the maintainers. Don't think worth a follow-up. If anyone likes to, move it :)