Merge pull request #1320 from tractorcow/pulls/3.2/deprecated-reports

Restore deprecated reports
This commit is contained in:
Ingo Schommer 2015-11-10 17:43:33 +13:00
commit 995680f4bb
7 changed files with 260 additions and 195 deletions

View File

@ -16,16 +16,18 @@ class BrokenFilesReport extends SS_Report {
public function sourceRecords($params = null) { public function sourceRecords($params = null) {
// Get class names for page types that are not virtual pages or redirector pages // 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)."'"; $stage = isset($params['OnLive']) ? 'Live' : 'Stage';
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
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;
} }
public function columns() { 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();
}
}

View File

@ -29,14 +29,14 @@ class BrokenLinksReport extends SS_Report {
$sort = ''; $sort = '';
} }
} }
if (!isset($_REQUEST['CheckSite']) || $params['CheckSite'] == 'Published') { $brokenFilter = array(
$ret = Versioned::get_by_stage('SiteTree', 'Live', array(
'"SiteTree"."HasBrokenLink" = ? OR "SiteTree"."HasBrokenFile" = ?' => array(true, true) '"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 { } else {
$ret = DataObject::get('SiteTree', array( $ret = DataObject::get('SiteTree', $brokenFilter, $sort, $join, $limit);
'"SiteTree"."HasBrokenFile" = ? OR "SiteTree"."HasBrokenLink" = ?' => array(true, true)
), $sort, $join, $limit);
} }
$returnSet = new ArrayList(); $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();
}
}

View File

@ -15,11 +15,13 @@ class BrokenRedirectorPagesReport extends SS_Report {
} }
public function sourceRecords($params = null) { public function sourceRecords($params = null) {
$classNames = "'".join("','", ClassInfo::subclassesFor('RedirectorPage'))."'"; $classes = ClassInfo::subclassesFor('RedirectorPage');
$classParams = DB::placeholders($classes);
if (isset($_REQUEST['OnLive'])) $ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1"); $classFilter = array(
else $ret = DataObject::get('SiteTree', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1"); "\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
return $ret; );
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
} }
public function columns() { 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();
}
}

View File

@ -15,15 +15,13 @@ class BrokenVirtualPagesReport extends SS_Report {
} }
public function sourceRecords($params = null) { public function sourceRecords($params = null) {
$classNames = "'".join("','", ClassInfo::subclassesFor('VirtualPage'))."'"; $classes = ClassInfo::subclassesFor('VirtualPage');
$classParams = DB::placeholders($classes);
if (isset($_REQUEST['OnLive'])) { $classFilter = array(
$ret = Versioned::get_by_stage('SiteTree', 'Live', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1"); "\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
} else { );
$ret = DataObject::get('SiteTree', "\"ClassName\" IN ($classNames) AND \"HasBrokenLink\" = 1"); $stage = isset($params['OnLive']) ? 'Live' : 'Stage';
} return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
return $ret;
} }
public function columns() { 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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -37,15 +37,13 @@ class CmsReportsTest extends SapphireTest {
$class = get_class($report); $class = get_class($report);
// ASSERT that the "draft" report is returning the correct results. // ASSERT that the "draft" report is returning the correct results.
$parameters = array('CheckSite' => 'Draft');
$results = count($report->sourceRecords(array())) > 0; $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."); $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. // ASSERT that the "published" report is returning the correct results.
$parameters = array('CheckSite' => 'Published', 'OnLive' => 1);
$results = count($report->sourceRecords(array( $results = count($report->sourceRecords($parameters, null, null)) > 0;
'OnLive' => 1
))) > 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."); $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(); $reports = SS_Report::get_reports();
$brokenLinksReport = null; $brokenLinksReport = null;
foreach($reports as $report) { foreach($reports as $report) {
if($report instanceof SideReport_BrokenLinks) { if($report instanceof BrokenLinksReport) {
$brokenLinksReport = $report; $brokenLinksReport = $report;
break; break;
} }
} }
// Determine that the report exists, otherwise it has been excluded. // 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 "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. // 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); $this->isReportBroken($brokenLinksReport, false, false);
} }
}
/** /**
* Test the broken files side report. * Test the broken files side report.
@ -144,15 +143,17 @@ class CmsReportsTest extends SapphireTest {
$reports = SS_Report::get_reports(); $reports = SS_Report::get_reports();
$brokenFilesReport = null; $brokenFilesReport = null;
foreach($reports as $report) { foreach($reports as $report) {
if($report instanceof SideReport_BrokenFiles) { if($report instanceof BrokenFilesReport) {
$brokenFilesReport = $report; $brokenFilesReport = $report;
break; break;
} }
} }
// Determine that the report exists, otherwise it has been excluded. // 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 "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. // 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); $this->isReportBroken($brokenFilesReport, false, false);
} }
}
/** /**
* Test the broken virtual pages side report. * Test the broken virtual pages side report.
@ -209,15 +209,17 @@ class CmsReportsTest extends SapphireTest {
$reports = SS_Report::get_reports(); $reports = SS_Report::get_reports();
$brokenVirtualPagesReport = null; $brokenVirtualPagesReport = null;
foreach($reports as $report) { foreach($reports as $report) {
if($report instanceof SideReport_BrokenVirtualPages) { if($report instanceof BrokenVirtualPagesReport) {
$brokenVirtualPagesReport = $report; $brokenVirtualPagesReport = $report;
break; break;
} }
} }
// Determine that the report exists, otherwise it has been excluded. // 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 "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. // 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); $this->isReportBroken($brokenVirtualPagesReport, false, false);
} }
}
/** /**
* Test the broken redirector pages side report. * Test the broken redirector pages side report.
@ -276,15 +277,17 @@ class CmsReportsTest extends SapphireTest {
$reports = SS_Report::get_reports(); $reports = SS_Report::get_reports();
$brokenRedirectorPagesReport = null; $brokenRedirectorPagesReport = null;
foreach($reports as $report) { foreach($reports as $report) {
if($report instanceof SideReport_BrokenRedirectorPages) { if($report instanceof BrokenRedirectorPagesReport) {
$brokenRedirectorPagesReport = $report; $brokenRedirectorPagesReport = $report;
break; break;
} }
} }
// Determine that the report exists, otherwise it has been excluded. // 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 "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. // 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); $this->isReportBroken($brokenRedirectorPagesReport, false, false);
} }
}
} }