From fb5e488103b6dde6f01fbc835b14ac2f36a04cc1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 3 Oct 2012 18:08:34 +0200 Subject: [PATCH] Line length fixes --- control/Cookie.php | 4 +++- model/Database.php | 5 ++++- model/MySQLDatabase.php | 4 +++- model/SQLQuery.php | 3 ++- tests/model/DataListTest.php | 21 +++++++++++++++++---- tests/model/DataQueryTest.php | 16 +++++++++++++--- view/SSViewer.php | 3 ++- 7 files changed, 44 insertions(+), 12 deletions(-) diff --git a/control/Cookie.php b/control/Cookie.php index ecaa894aa..1c1299c3c 100644 --- a/control/Cookie.php +++ b/control/Cookie.php @@ -98,7 +98,9 @@ class Cookie { * @param boolean $secure See http://php.net/set_session * @param boolean $httpOnly See http://php.net/set_session */ - protected function inst_set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) { + protected function inst_set($name, $value, $expiry = 90, $path = null, + $domain = null, $secure = false, $httpOnly = false + ) { if(!headers_sent($file, $line)) { $expiry = $expiry > 0 ? time()+(86400*$expiry) : $expiry; $path = ($path) ? $path : Director::baseURL(); diff --git a/model/Database.php b/model/Database.php index f2a0b35fb..ec93128ce 100644 --- a/model/Database.php +++ b/model/Database.php @@ -559,7 +559,10 @@ abstract class SS_Database { } } $this->transAlterField($table, $field, $spec_orig); - $this->alterationMessage("Field $table.$field: changed to $specValue (from {$fieldValue})","changed"); + $this->alterationMessage( + "Field $table.$field: changed to $specValue (from {$fieldValue})", + "changed" + ); } } diff --git a/model/MySQLDatabase.php b/model/MySQLDatabase.php index 436676dd6..43b74d12d 100644 --- a/model/MySQLDatabase.php +++ b/model/MySQLDatabase.php @@ -857,7 +857,9 @@ class MySQLDatabase extends SS_Database { // We make the relevance search by converting a boolean mode search into a normal one $relevanceKeywords = str_replace(array('*','+','-'),'',$keywords); $htmlEntityRelevanceKeywords = str_replace(array('*','+','-'),'',$htmlEntityKeywords); - $relevance['SiteTree'] = "MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('$relevanceKeywords') + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('$htmlEntityRelevanceKeywords')"; + $relevance['SiteTree'] = "MATCH (Title, MenuTitle, Content, MetaDescription) " + . "AGAINST ('$relevanceKeywords') " + . "+ MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('$htmlEntityRelevanceKeywords')"; $relevance['File'] = "MATCH (Filename, Title, Content) AGAINST ('$relevanceKeywords')"; } else { $relevance['SiteTree'] = $relevance['File'] = 1; diff --git a/model/SQLQuery.php b/model/SQLQuery.php index 30ae36415..69eff0e33 100644 --- a/model/SQLQuery.php +++ b/model/SQLQuery.php @@ -888,7 +888,8 @@ class SQLQuery { else $filter = "(" . implode(") AND (", $join['filter']) . ")"; $aliasClause = ($alias != $join['table']) ? " AS \"" . Convert::raw2sql($alias) . "\"" : ""; - $this->from[$alias] = strtoupper($join['type']) . " JOIN \"" . $join['table'] . "\"$aliasClause ON $filter"; + $this->from[$alias] = strtoupper($join['type']) . " JOIN \"" + . $join['table'] . "\"$aliasClause ON $filter"; } } diff --git a/tests/model/DataListTest.php b/tests/model/DataListTest.php index 4af7fd024..29ca2f11c 100644 --- a/tests/model/DataListTest.php +++ b/tests/model/DataListTest.php @@ -108,10 +108,23 @@ class DataListTest extends SapphireTest { // Test with namespaces (with non-sensical join, but good enough for testing) $list = DataObjectTest_TeamComment::get(); - $list->leftJoin('DataObjectTest\NamespacedClass', '"DataObjectTest\NamespacedClass"."ID" = "DataObjectTest_TeamComment"."ID"'); - $expected = 'SELECT DISTINCT "DataObjectTest_TeamComment"."ClassName", "DataObjectTest_TeamComment"."Created", "DataObjectTest_TeamComment"."LastEdited", "DataObjectTest_TeamComment"."Name", "DataObjectTest_TeamComment"."Comment", "DataObjectTest_TeamComment"."TeamID", "DataObjectTest_TeamComment"."ID", CASE WHEN "DataObjectTest_TeamComment"."ClassName" IS NOT NULL THEN "DataObjectTest_TeamComment"."ClassName" ELSE '.$db->prepStringForDB('DataObjectTest_TeamComment').' END AS "RecordClassName" ' . - 'FROM "DataObjectTest_TeamComment" ' . - 'LEFT JOIN "DataObjectTest\NamespacedClass" ON "DataObjectTest\NamespacedClass"."ID" = "DataObjectTest_TeamComment"."ID"'; + $list->leftJoin( + 'DataObjectTest\NamespacedClass', + '"DataObjectTest\NamespacedClass"."ID" = "DataObjectTest_TeamComment"."ID"' + ); + $expected = 'SELECT DISTINCT "DataObjectTest_TeamComment"."ClassName", ' + . '"DataObjectTest_TeamComment"."Created", ' + . '"DataObjectTest_TeamComment"."LastEdited", ' + . '"DataObjectTest_TeamComment"."Name", ' + . '"DataObjectTest_TeamComment"."Comment", ' + . '"DataObjectTest_TeamComment"."TeamID", ' + . '"DataObjectTest_TeamComment"."ID", ' + . 'CASE WHEN "DataObjectTest_TeamComment"."ClassName" IS NOT NULL ' + . 'THEN "DataObjectTest_TeamComment"."ClassName" ' + . 'ELSE ' . $db->prepStringForDB('DataObjectTest_TeamComment') . ' END AS "RecordClassName" ' + . 'FROM "DataObjectTest_TeamComment" ' + . 'LEFT JOIN "DataObjectTest\NamespacedClass" ON ' + . '"DataObjectTest\NamespacedClass"."ID" = "DataObjectTest_TeamComment"."ID"'; $this->assertEquals($expected, $list->sql(), 'Retains backslashes in namespaced classes'); } diff --git a/tests/model/DataQueryTest.php b/tests/model/DataQueryTest.php index f2ab94659..d3d731110 100644 --- a/tests/model/DataQueryTest.php +++ b/tests/model/DataQueryTest.php @@ -41,7 +41,10 @@ class DataQueryTest extends SapphireTest { $subDq->where('DataQueryTest_A.Name = \'John\''); $subDq->where('DataQueryTest_A.Name = \'Bob\''); - $this->assertContains("WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') OR (DataQueryTest_A.Name = 'Bob'))", $dq->sql()); + $this->assertContains( + "WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') OR (DataQueryTest_A.Name = 'Bob'))", + $dq->sql() + ); } public function testConjunctiveGroup() { @@ -52,7 +55,10 @@ class DataQueryTest extends SapphireTest { $subDq->where('DataQueryTest_A.Name = \'John\''); $subDq->where('DataQueryTest_A.Name = \'Bob\''); - $this->assertContains("WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') AND (DataQueryTest_A.Name = 'Bob'))", $dq->sql()); + $this->assertContains( + "WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') AND (DataQueryTest_A.Name = 'Bob'))", + $dq->sql() + ); } public function testNestedGroups() { @@ -66,7 +72,11 @@ class DataQueryTest extends SapphireTest { $subSubDq->where('DataQueryTest_A.Age = 50'); $subDq->where('DataQueryTest_A.Name = \'Bob\''); - $this->assertContains("WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') OR ((DataQueryTest_A.Age = 18) AND (DataQueryTest_A.Age = 50)) OR (DataQueryTest_A.Name = 'Bob'))", $dq->sql()); + $this->assertContains( + "WHERE (DataQueryTest_A.ID = 2) AND ((DataQueryTest_A.Name = 'John') OR ((DataQueryTest_A.Age = 18) " + . "AND (DataQueryTest_A.Age = 50)) OR (DataQueryTest_A.Name = 'Bob'))", + $dq->sql() + ); } public function testEmptySubgroup() { diff --git a/view/SSViewer.php b/view/SSViewer.php index 893125715..9806df789 100644 --- a/view/SSViewer.php +++ b/view/SSViewer.php @@ -843,7 +843,8 @@ class SSViewer { $template = $this->chosenTemplates[$key]; } - $cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\','/',':'), '.', Director::makeRelative(realpath($template))); + $cacheFile = TEMP_FOLDER . "/.cache" + . str_replace(array('\\','/',':'), '.', Director::makeRelative(realpath($template))); $lastEdited = filemtime($template); if(!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {