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.
Comments
Comment #2
joshf commentedComment #4
joshf commentedThis should fix the reported schema error.
Comment #5
joshf commentedComment #6
bburg+1, Would really like to skip link checking for local development.
Comment #7
solideogloria commentedYou could install Ultimate Cron, then disable the individual linkchecker cron task
Comment #8
eiriksmWould be great to have a simple test for this as well, before we commit it
Comment #9
jurgenhaasI've tested this just now and it works as expected. Not setting it to RTBC as for outstanding test coverage.
Comment #10
c-logemannI 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".
Comment #11
c-logemannIn any case it would be helpful if there is a merge request for this change.
Comment #13
solideogloria commentedAdded changes from #4 to a MR
Comment #14
solideogloria commentedComment #15
solideogloria commentedIt works. Just wondering, should a message be logged when cron link checking is skipped?
Comment #16
c-logemann> 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.
Comment #17
alexh commentedI 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.
Comment #18
vladimirausThanks for your contribution.
Can we update the it to the latest branch?
Comment #21
solideogloria commentedComment #22
solideogloria commentedAlso, 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
Comment #24
vladimiraushook_updatefor new config property?Comment #25
solideogloria commentedComment #26
jurgenhaasI've rebased the MR!75
Comment #27
vladimirausThanks @solideogloria. Looks like you did commit to old branch.
Outstanding tasks
Comment #28
solideogloria commentedRebased MR.
Comment #29
solideogloria commentedI 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.
Comment #30
solideogloria commentedI also added the missing update hook
Comment #31
jurgenhaasJust left a comment in the MR
Comment #32
jurgenhaasLooks like the changes in
LinkExtractorService.phpandLinkcheckerLinkPageEntityLabel.phpare unrelated to this issue and should be removed from the MR, I guess?Comment #34
jurgenhaasI've rebased MR !75 for 2.0.x and I've created MR !129 for 2.1.x
Comment #35
anybodyThanks, 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)
Comment #36
anybodyComment #37
solideogloria commentedIt also has Drush commands that run it, which could be run from CLI.
Comment #38
anybodyThanks @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)
Comment #40
ericgsmith commentedThis 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
Comment #41
anybodyThanks @ericgsmith. I think besides this #3581562: Add option to disable Linkchecker (esp. entity hooks) is (even more) important. Thanks for the test!
Comment #42
joelpittetI 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.
Comment #43
anybodyPosition 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 :)