[BUGFIX] SQL error if a task is run on a disabled page
authorPhilipp Gampe <forge.typo3.org@philippgampe.info>
Wed, 5 Oct 2011 22:59:22 +0000 (00:59 +0200)
committerOliver Hader <oliver@typo3.org>
Mon, 10 Oct 2011 19:40:08 +0000 (21:40 +0200)
This happens because the init() method is not always called.

Switching the logic to first get the list of page IDs and only
checking the links of the list is not empty.

Change-Id: Idc18dba6c8503b73e0daf936e96aa7c784345466
Fixes: #30593
Releases: 4.5, 4.6

typo3/sysext/linkvalidator/classes/tasks/class.tx_linkvalidator_tasks_validator.php

index 6cf8275..d0e2970 100644 (file)
@@ -280,6 +280,9 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
        protected function checkPageLinks($page) {
                $page = intval($page);
                $pageSections = '';
+               $pageIds = '';
+               $oldLinkCounts = array();
+
                $modTS = $this->loadModTSconfig($page);
                $searchFields = $this->getSearchField($modTS);
                $linkTypes = $this->getLinkTypes($modTS);
@@ -297,23 +300,28 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
                if (!$rootLineHidden || $modTS['checkhidden'] == 1) {
                        $pageIds = $processor->extGetTreeList($page, $this->depth, 0, '1=1', $modTS['checkhidden']);
                        if ($pageRow['hidden'] == 0 || $modTS['checkhidden'] == 1) {
+                                       // tx_linkvalidator_Processor::extGetTreeList always adds trailing comma:
                                $pageIds .= $page;
                        }
+               }
 
+               if (!empty($pageIds)) {
                        $processor->init($searchFields, $pageIds);
+
                        if (!empty($this->email)) {
                                $oldLinkCounts = $processor->getLinkCounts($page);
                                $this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];
                        }
-               }
 
-               $processor->getLinkStatistics($linkTypes, $modTS['checkhidden']);
+                       $processor->getLinkStatistics($linkTypes, $modTS['checkhidden']);
 
-               if (!empty($this->email)) {
-                       $linkCounts = $processor->getLinkCounts($page);
-                       $this->totalBrokenLink += $linkCounts['brokenlinkCount'];
-                       $pageSections = $this->buildMail($page, $pageIds, $linkCounts, $oldLinkCounts);
+                       if (!empty($this->email)) {
+                               $linkCounts = $processor->getLinkCounts($page);
+                               $this->totalBrokenLink += $linkCounts['brokenlinkCount'];
+                               $pageSections = $this->buildMail($page, $pageIds, $linkCounts, $oldLinkCounts);
+                       }
                }
+
                return $pageSections;
        }