mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1320 from tractorcow/pulls/3.2/deprecated-reports
Restore deprecated reports
This commit is contained in:
commit
995680f4bb
@ -16,16 +16,18 @@ class BrokenFilesReport extends SS_Report {
|
||||
|
||||
public function sourceRecords($params = null) {
|
||||
// Get class names for page types that are not virtual pages or redirector pages
|
||||
$classes = array_diff(ClassInfo::subclassesFor('SiteTree'), ClassInfo::subclassesFor('VirtualPage'), ClassInfo::subclassesFor('RedirectorPage'));
|
||||
$classes = array_diff(
|
||||
ClassInfo::subclassesFor('SiteTree'),
|
||||
ClassInfo::subclassesFor('VirtualPage'),
|
||||
ClassInfo::subclassesFor('RedirectorPage')
|
||||
);
|
||||
$classParams = DB::placeholders($classes);
|
||||
$classFilter = array(
|
||||
"\"ClassName\" IN ($classParams) AND \"HasBrokenFile\" = 1" => $classes
|
||||
);
|
||||
|
||||
$classNames = "'".join("','", $classes)."'";
|
||||
|
||||
if (isset($_REQUEST['OnLive'])) {
|
||||
$ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ($classNames) AND \"HasBrokenFile\" = 1");
|
||||
} else {
|
||||
$ret = DataObject::get('SiteTree', "\"ClassName\" IN ($classNames) AND \"HasBrokenFile\" = 1");
|
||||
}
|
||||
return $ret;
|
||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
||||
}
|
||||
|
||||
public function columns() {
|
||||
@ -43,3 +45,13 @@ class BrokenFilesReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_BrokenFiles extends BrokenFilesReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use BrokenFilesReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ class BrokenLinksReport extends SS_Report {
|
||||
$sort = '';
|
||||
}
|
||||
}
|
||||
if (!isset($_REQUEST['CheckSite']) || $params['CheckSite'] == 'Published') {
|
||||
$ret = Versioned::get_by_stage('SiteTree', 'Live', array(
|
||||
$brokenFilter = array(
|
||||
'"SiteTree"."HasBrokenLink" = ? OR "SiteTree"."HasBrokenFile" = ?' => array(true, true)
|
||||
), $sort, $join, $limit);
|
||||
);
|
||||
$isLive = !isset($params['CheckSite']) || $params['CheckSite'] == 'Published';
|
||||
if ($isLive) {
|
||||
$ret = Versioned::get_by_stage('SiteTree', 'Live', $brokenFilter, $sort, $join, $limit);
|
||||
} else {
|
||||
$ret = DataObject::get('SiteTree', array(
|
||||
'"SiteTree"."HasBrokenFile" = ? OR "SiteTree"."HasBrokenLink" = ?' => array(true, true)
|
||||
), $sort, $join, $limit);
|
||||
$ret = DataObject::get('SiteTree', $brokenFilter, $sort, $join, $limit);
|
||||
}
|
||||
|
||||
$returnSet = new ArrayList();
|
||||
@ -141,3 +141,14 @@ class BrokenLinksReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_BrokenLinks extends BrokenLinksReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use BrokenLinksReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -15,11 +15,13 @@ class BrokenRedirectorPagesReport extends SS_Report {
|
||||
}
|
||||
|
||||
public function sourceRecords($params = null) {
|
||||
$classNames = "'".join("','", ClassInfo::subclassesFor('RedirectorPage'))."'";
|
||||
|
||||
if (isset($_REQUEST['OnLive'])) $ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1");
|
||||
else $ret = DataObject::get('SiteTree', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1");
|
||||
return $ret;
|
||||
$classes = ClassInfo::subclassesFor('RedirectorPage');
|
||||
$classParams = DB::placeholders($classes);
|
||||
$classFilter = array(
|
||||
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
||||
);
|
||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
||||
}
|
||||
|
||||
public function columns() {
|
||||
@ -37,3 +39,13 @@ class BrokenRedirectorPagesReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_BrokenRedirectorPages extends BrokenRedirectorPagesReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use BrokenRedirectorPagesReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -15,15 +15,13 @@ class BrokenVirtualPagesReport extends SS_Report {
|
||||
}
|
||||
|
||||
public function sourceRecords($params = null) {
|
||||
$classNames = "'".join("','", ClassInfo::subclassesFor('VirtualPage'))."'";
|
||||
|
||||
if (isset($_REQUEST['OnLive'])) {
|
||||
$ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1");
|
||||
} else {
|
||||
$ret = DataObject::get('SiteTree', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1");
|
||||
}
|
||||
|
||||
return $ret;
|
||||
$classes = ClassInfo::subclassesFor('VirtualPage');
|
||||
$classParams = DB::placeholders($classes);
|
||||
$classFilter = array(
|
||||
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
||||
);
|
||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
||||
}
|
||||
|
||||
public function columns() {
|
||||
@ -41,3 +39,13 @@ class BrokenVirtualPagesReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_BrokenVirtualPages extends BrokenVirtualPagesReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use BrokenVirtualPagesReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -33,3 +33,13 @@ class EmptyPagesReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_EmptyPages extends EmptyPagesReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use EmptyPagesReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -32,3 +32,13 @@ class RecentlyEditedReport extends SS_Report {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.2..4.0
|
||||
*/
|
||||
class SideReport_RecentlyEdited extends RecentlyEditedReport {
|
||||
public function __construct() {
|
||||
Deprecation::notice('4.0', 'Use RecentlyEditedReport instead');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -37,15 +37,13 @@ class CmsReportsTest extends SapphireTest {
|
||||
$class = get_class($report);
|
||||
|
||||
// ASSERT that the "draft" report is returning the correct results.
|
||||
|
||||
$results = count($report->sourceRecords(array())) > 0;
|
||||
$parameters = array('CheckSite' => 'Draft');
|
||||
$results = count($report->sourceRecords($parameters, null, null)) > 0;
|
||||
$isDraftBroken ? $this->assertTrue($results, "{$class} has NOT returned the correct DRAFT results, as NO pages were found.") : $this->assertFalse($results, "{$class} has NOT returned the correct DRAFT results, as pages were found.");
|
||||
|
||||
// ASSERT that the "published" report is returning the correct results.
|
||||
|
||||
$results = count($report->sourceRecords(array(
|
||||
'OnLive' => 1
|
||||
))) > 0;
|
||||
$parameters = array('CheckSite' => 'Published', 'OnLive' => 1);
|
||||
$results = count($report->sourceRecords($parameters, null, null)) > 0;
|
||||
$isPublishedBroken ? $this->assertTrue($results, "{$class} has NOT returned the correct PUBLISHED results, as NO pages were found.") : $this->assertFalse($results, "{$class} has NOT returned the correct PUBLISHED results, as pages were found.");
|
||||
}
|
||||
|
||||
@ -82,15 +80,17 @@ class CmsReportsTest extends SapphireTest {
|
||||
$reports = SS_Report::get_reports();
|
||||
$brokenLinksReport = null;
|
||||
foreach($reports as $report) {
|
||||
if($report instanceof SideReport_BrokenLinks) {
|
||||
if($report instanceof BrokenLinksReport) {
|
||||
$brokenLinksReport = $report;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine that the report exists, otherwise it has been excluded.
|
||||
|
||||
if($brokenLinksReport) {
|
||||
if(!$brokenLinksReport){
|
||||
$this->markTestSkipped('BrokenLinksReport is not an available report');
|
||||
return;
|
||||
}
|
||||
|
||||
// ASSERT that the "draft" report has detected the page having a broken link.
|
||||
// ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet.
|
||||
@ -125,7 +125,6 @@ class CmsReportsTest extends SapphireTest {
|
||||
|
||||
$this->isReportBroken($brokenLinksReport, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the broken files side report.
|
||||
@ -144,15 +143,17 @@ class CmsReportsTest extends SapphireTest {
|
||||
$reports = SS_Report::get_reports();
|
||||
$brokenFilesReport = null;
|
||||
foreach($reports as $report) {
|
||||
if($report instanceof SideReport_BrokenFiles) {
|
||||
if($report instanceof BrokenFilesReport) {
|
||||
$brokenFilesReport = $report;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine that the report exists, otherwise it has been excluded.
|
||||
|
||||
if($brokenFilesReport) {
|
||||
if(!$brokenFilesReport){
|
||||
$this->markTestSkipped('BrokenFilesReport is not an available report');
|
||||
return;
|
||||
}
|
||||
|
||||
// ASSERT that the "draft" report has detected the page having a broken file.
|
||||
// ASSERT that the "published" report has NOT detected the page having a broken file, as the page has not been "published" yet.
|
||||
@ -190,7 +191,6 @@ class CmsReportsTest extends SapphireTest {
|
||||
|
||||
$this->isReportBroken($brokenFilesReport, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the broken virtual pages side report.
|
||||
@ -209,15 +209,17 @@ class CmsReportsTest extends SapphireTest {
|
||||
$reports = SS_Report::get_reports();
|
||||
$brokenVirtualPagesReport = null;
|
||||
foreach($reports as $report) {
|
||||
if($report instanceof SideReport_BrokenVirtualPages) {
|
||||
if($report instanceof BrokenVirtualPagesReport) {
|
||||
$brokenVirtualPagesReport = $report;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine that the report exists, otherwise it has been excluded.
|
||||
|
||||
if($brokenVirtualPagesReport) {
|
||||
if(!$brokenVirtualPagesReport){
|
||||
$this->markTestSkipped('BrokenFilesReport is not an available report');
|
||||
return;
|
||||
}
|
||||
|
||||
// ASSERT that the "draft" report has detected the page having a broken link.
|
||||
// ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet.
|
||||
@ -256,7 +258,6 @@ class CmsReportsTest extends SapphireTest {
|
||||
|
||||
$this->isReportBroken($brokenVirtualPagesReport, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the broken redirector pages side report.
|
||||
@ -276,15 +277,17 @@ class CmsReportsTest extends SapphireTest {
|
||||
$reports = SS_Report::get_reports();
|
||||
$brokenRedirectorPagesReport = null;
|
||||
foreach($reports as $report) {
|
||||
if($report instanceof SideReport_BrokenRedirectorPages) {
|
||||
if($report instanceof BrokenRedirectorPagesReport) {
|
||||
$brokenRedirectorPagesReport = $report;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine that the report exists, otherwise it has been excluded.
|
||||
|
||||
if($brokenRedirectorPagesReport) {
|
||||
if(!$brokenRedirectorPagesReport){
|
||||
$this->markTestSkipped('BrokenRedirectorPagesReport is not an available report');
|
||||
return;
|
||||
}
|
||||
|
||||
// ASSERT that the "draft" report has detected the page having a broken link.
|
||||
// ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet.
|
||||
@ -323,6 +326,5 @@ class CmsReportsTest extends SapphireTest {
|
||||
|
||||
$this->isReportBroken($brokenRedirectorPagesReport, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user