diff --git a/README.md b/README.md index 7a5ad1a..054460f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,17 @@ The external links module is a task and ModelAdmin to track and to report on bro 4. Place this directory in your sites root directory. This is the one with framework and cms in it. 5. Run in your browser - `/dev/build` to rebuild the database. 6. You should see a new menu called *Broken Ext. Links* + 7. Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* + +## Dev task ## + +Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* to check your site for external +broken links. +If you have the queuedjobs module installed you can set the task to be run every so ofter +Add the following code to the mysite config to run the job every 24 hours (86400 seconds) + +`Config::inst()->update('CheckExternalLinks', 'QueuedJob', 86400);` + ## Disable the Broken external link menu diff --git a/tasks/CheckExternalLinks.php b/tasks/CheckExternalLinks.php index 440c3e6..a6a8ff2 100644 --- a/tasks/CheckExternalLinks.php +++ b/tasks/CheckExternalLinks.php @@ -63,11 +63,12 @@ class CheckExternalLinks extends BuildTask { } } - // run this again in 24 hours if queued jobs exists - if (class_exists('QueuedJobService')) { + // run this again if queued jobs exists and is a valid int + $queuedJob = Config::inst()->get('CheckExternalLinks', 'QueuedJob'); + if (isset($queuedJob) && is_int($queuedJob) && class_exists('QueuedJobService')) { $checkLinks = new CheckExternalLinksJob(); singleton('QueuedJobService') - ->queueJob($checkLinks, date('Y-m-d H:i:s', time() + 86400)); + ->queueJob($checkLinks, date('Y-m-d H:i:s', time() + $queuedJob)); } }