mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 17:05:44 +02:00
API Rename IgnoreCodes configuration property to ignore_codes
This commit is contained in:
parent
789ce91e1c
commit
e58190a9b3
28
README.md
28
README.md
@ -30,7 +30,7 @@ The external links module is a task and ModelAdmin to track and to report on bro
|
|||||||
3. Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* to check for
|
3. Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* to check for
|
||||||
broken external links
|
broken external links
|
||||||
|
|
||||||
## Report ##
|
## Report
|
||||||
|
|
||||||
A new report is added called 'External Broken links report'. When viewing this report, a user may press
|
A new report is added called 'External Broken links report'. When viewing this report, a user may press
|
||||||
the "Create new report" button which will trigger an ajax request to initiate a report run.
|
the "Create new report" button which will trigger an ajax request to initiate a report run.
|
||||||
@ -56,24 +56,30 @@ with the status. The user may leave this page and return to it later to view the
|
|||||||
|
|
||||||
Any subsequent report may not be generated until a prior report has completed.
|
Any subsequent report may not be generated until a prior report has completed.
|
||||||
|
|
||||||
## Dev task ##
|
## Dev task
|
||||||
|
|
||||||
Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* to check your site for external
|
Run the following task *http://path.to.silverstripe/dev/tasks/CheckExternalLinks* to check your site for external
|
||||||
broken links.
|
broken links.
|
||||||
|
|
||||||
## Queued job ##
|
## Queued job
|
||||||
|
|
||||||
If you have the queuedjobs module installed you can set the task to be run every so often.
|
If you have the queuedjobs module installed you can set the task to be run every so often.
|
||||||
|
|
||||||
## Whitelisting codes ##
|
## Whitelisting codes
|
||||||
|
|
||||||
If you want to ignore or whitelist certain http codes this can be setup via IgnoreCodes in the config.yml
|
If you want to ignore or whitelist certain HTTP codes this can be setup via `ignore_codes` in the config.yml
|
||||||
file in `mysite/_config`
|
file in `mysite/_config`:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
SilverStripe\ExternalLinks\Tasks\CheckExternalLinksTask:
|
SilverStripe\ExternalLinks\Tasks\CheckExternalLinksTask:
|
||||||
IgnoreCodes:
|
ignore_codes:
|
||||||
- 401
|
- 401
|
||||||
- 403
|
- 403
|
||||||
- 501
|
- 501
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Upgrading from 1.x to 2.x
|
||||||
|
|
||||||
|
When upgrading from 1.x to 2.x (SilverStripe 3.x to 4.x) you will need to be aware of the following API changes:
|
||||||
|
|
||||||
|
* Configuration property `CheckExternalLinksTask.IgnoreCodes` renamed to `CheckExternalLinksTask.ignore_codes`
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
namespace SilverStripe\ExternalLinks\Model;
|
namespace SilverStripe\ExternalLinks\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Control\HTTPResponse;
|
||||||
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrack;
|
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrack;
|
||||||
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus;
|
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus;
|
||||||
use SilverStripe\Security\Member;
|
|
||||||
use SilverStripe\Security\Permission;
|
|
||||||
use SilverStripe\Core\Config\Config;
|
|
||||||
use SilverStripe\Control\HTTPResponse;
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single link checked for a single run that is broken
|
* Represents a single link checked for a single run that is broken
|
||||||
@ -56,7 +55,7 @@ class BrokenExternalLink extends DataObject
|
|||||||
|
|
||||||
public function canView($member = false)
|
public function canView($member = false)
|
||||||
{
|
{
|
||||||
$member = $member ? $member : Member::currentUser();
|
$member = $member ? $member : Security::getCurrentUser();
|
||||||
$codes = array('content-authors', 'administrators');
|
$codes = array('content-authors', 'administrators');
|
||||||
return Permission::checkMember($member, $codes);
|
return Permission::checkMember($member, $codes);
|
||||||
}
|
}
|
||||||
|
@ -2,26 +2,36 @@
|
|||||||
|
|
||||||
namespace SilverStripe\ExternalLinks\Tasks;
|
namespace SilverStripe\ExternalLinks\Tasks;
|
||||||
|
|
||||||
|
use DOMNode;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
use SilverStripe\Dev\BuildTask;
|
||||||
|
use SilverStripe\Dev\Debug;
|
||||||
use SilverStripe\ExternalLinks\Model\BrokenExternalLink;
|
use SilverStripe\ExternalLinks\Model\BrokenExternalLink;
|
||||||
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrack;
|
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrack;
|
||||||
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus;
|
use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus;
|
||||||
use SilverStripe\Dev\BuildTask;
|
use SilverStripe\ExternalLinks\Tasks\LinkChecker;
|
||||||
use SilverStripe\Core\Config\Config;
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\Dev\Debug;
|
|
||||||
use DOMNode;
|
|
||||||
use SilverStripe\Core\Injector\Injector;
|
|
||||||
use SilverStripe\ExternalLinks\Tasks\LinkChecker;
|
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
|
||||||
|
|
||||||
class CheckExternalLinksTask extends BuildTask
|
class CheckExternalLinksTask extends BuildTask
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $dependencies = [
|
private static $dependencies = [
|
||||||
'LinkChecker' => '%$' . LinkChecker::class
|
'LinkChecker' => '%$' . LinkChecker::class
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private static $segment = 'CheckExternalLinksTask';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a list of HTTP response codes that should not be treated as "broken", where they usually
|
||||||
|
* might be.
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $ignore_codes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@ -135,7 +145,7 @@ class CheckExternalLinksTask extends BuildTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do we have any whitelisted codes
|
// do we have any whitelisted codes
|
||||||
$ignoreCodes = $this->config()->get('IgnoreCodes');
|
$ignoreCodes = $this->config()->get('ignore_codes');
|
||||||
if (is_array($ignoreCodes) && in_array($httpCode, $ignoreCodes)) {
|
if (is_array($ignoreCodes) && in_array($httpCode, $ignoreCodes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user