diff --git a/README.md b/README.md index 953a14d..395f6b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection) -_The current release is **2.2.9**_ +_The current release is **2.2.10**_ > A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling. diff --git a/code/tasks/MisdirectionHistoricalLinkMappingTask.php b/code/tasks/MisdirectionHistoricalLinkMappingTask.php index 7a9995a..61e4e0f 100644 --- a/code/tasks/MisdirectionHistoricalLinkMappingTask.php +++ b/code/tasks/MisdirectionHistoricalLinkMappingTask.php @@ -71,7 +71,12 @@ public function run($request) { protected function getPublishedVersionRecords() { - $query = new SQLSelect('ID, RecordID, ParentID, URLSegment, Version', 'SiteTree_versions', 'WasPublished = 1', 'ID ASC'); + $query = new SQLSelect( + 'ID, RecordID, ParentID, URLSegment, Version', + 'SiteTree_versions', + 'WasPublished = 1', + 'ID ASC' + ); return $query->execute(); } @@ -126,11 +131,13 @@ protected function updateURLs($records) { protected function addMappingToList($URL, $ID) { $this->linkMappings[$URL] = $ID; - $query = new SQLUpdate($this->replayTable, array( - 'FullURL' => $URL - ), array( - 'ID' => $ID - )); + $query = new SQLUpdate( + $this->replayTable, + array( + 'FullURL' => $URL + ), + "ID = {$ID}" + ); $query->execute(); } @@ -174,7 +181,11 @@ protected function isUpdated($ID, $oldURLSegment, $oldParentID) { protected function getReplayRecordByID($ID) { - $query = new SQLSelect('*', $this->replayTable, "ID = {$ID}"); + $query = new SQLSelect( + '*', + $this->replayTable, + "ID = {$ID}" + ); $records = $query->execute(); return $records->first(); } @@ -188,7 +199,11 @@ protected function getReplayRecordByID($ID) { protected function getChildren($ID) { - $query = new SQLSelect('*', $this->replayTable, 'ParentID = ' . (int)$ID); + $query = new SQLSelect( + '*', + $this->replayTable, + 'ParentID = ' . (int)$ID + ); return $query->execute(); } @@ -218,7 +233,15 @@ protected function getURLForRecord($record = null, $URL = null) { // Retrieve the parent element which was most recently published. - $parentQuery = new SQLSelect('ID, ParentID, URLSegment, Version', $this->replayTable, "ID = {$parentID}", null, null, null, 1); + $parentQuery = new SQLSelect( + 'ID, ParentID, URLSegment, Version', + $this->replayTable, + "ID = {$parentID}", + null, + null, + null, + 1 + ); $parent = $parentQuery->execute()->first(); return $this->getURLForRecord($parent, $URL); } @@ -239,7 +262,11 @@ protected function checkAndCreateMappings() { // Check that the URL is not the current live URL. - $query = new SQLSelect('ID', $this->replayTable, "FullURL = '{$URL}'"); + $query = new SQLSelect( + 'ID', + $this->replayTable, + "FullURL = '{$URL}'" + ); if($query->count('ID') == 0) { echo "
{$siteTreeID} - {$URL}

"; if($this->live) { @@ -273,7 +300,9 @@ protected function setupStructure() { // Delete all records from the table. - $query = new SQLDelete(self::$default_table); + $query = new SQLDelete( + self::$default_table + ); $query->execute(); } }