From 35da873ad9f79d7893a6894a66afa84ce39b21c5 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Mon, 15 Oct 2012 20:40:38 +0200
Subject: [PATCH 1/3] BUG Using Session::set() for
DB::set_alternative_database_name()
Setting session directly through $_SESSION relies on
session_autostart which might not be set on every environment,
and isn't consistent with other framework use.
---
model/DB.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/model/DB.php b/model/DB.php
index e544d1372..70ef907ac 100644
--- a/model/DB.php
+++ b/model/DB.php
@@ -65,14 +65,14 @@ class DB {
* Set it to null to revert to the main database.
*/
public static function set_alternative_database_name($dbname) {
- $_SESSION["alternativeDatabaseName"] = $dbname;
+ Session::set("alternativeDatabaseName", $dbname);
}
/**
* Get the name of the database in use
*/
public static function get_alternative_database_name() {
- return $_SESSION["alternativeDatabaseName"];
+ return Session::get("alternativeDatabaseName");
}
/**
@@ -84,8 +84,8 @@ class DB {
*/
public static function connect($databaseConfig) {
// This is used by TestRunner::startsession() to test up a test session using an alt
- if(isset($_SESSION) && !empty($_SESSION['alternativeDatabaseName'])) {
- $databaseConfig['database'] = $_SESSION['alternativeDatabaseName'];
+ if($name = Session::get('alternativeDatabaseName')) {
+ $databaseConfig['database'] = $name;
}
if(!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
From a171c7e4b00d29516e43948022b96d1a44cb9e2d Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Tue, 16 Oct 2012 11:59:30 +1300
Subject: [PATCH 2/3] BUG Fixing regression in 26d70d6fca with formatted output
in SS_HTMLValue
If formatOutput is set to TRUE, then the regexes in getContent()
will not match the newlines, and the output will include html, body
and meta tags. Introduce a few new tests to ensure the output is
correct, and fix the regex.
---
model/HTMLValue.php | 44 +++++++++++++++++++++--------
tests/integration/HTMLValueTest.php | 24 ++++++++++++----
2 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/model/HTMLValue.php b/model/HTMLValue.php
index 4d1884d2b..86d754895 100644
--- a/model/HTMLValue.php
+++ b/model/HTMLValue.php
@@ -17,14 +17,30 @@ class SS_HTMLValue extends ViewableData {
* @param string $content
*/
public function __construct($content = null) {
- $this->document = new DOMDocument('1.0', 'UTF-8');
- $this->document->scrictErrorChecking = false;
-
+ $this->setDocument(new DOMDocument('1.0', 'UTF-8'));
+ $this->setScrictErrorChecking(false);
+ $this->setOutputFormatting(false);
$this->setContent($content);
-
+
parent::__construct();
}
-
+
+ /**
+ * Should strict error checking be used?
+ * @param boolean $bool
+ */
+ public function setScrictErrorChecking($bool) {
+ $this->getDocument()->scrictErrorChecking = $bool;
+ }
+
+ /**
+ * Should the output be formatted?
+ * @param boolean $bool
+ */
+ public function setOutputFormatting($bool) {
+ $this->getDocument()->formatOutput = $bool;
+ }
+
/**
* @return string
*/
@@ -35,16 +51,15 @@ class SS_HTMLValue extends ViewableData {
return trim(
preg_replace(
array(
- '/^/i',
- '/(.*)/i',
- '/<\/body>(.*)/i',
+ '/(.*)/is',
+ '/<\/body>(.*)/is',
),
'',
urldecode($this->getDocument()->saveHTML())
)
);
}
-
+
/**
* @param string $content
* @return bool
@@ -59,14 +74,21 @@ class SS_HTMLValue extends ViewableData {
"$content"
);
}
-
+
/**
* @return DOMDocument
*/
public function getDocument() {
return $this->document;
}
-
+
+ /**
+ * @param DOMDocument $document
+ */
+ public function setDocument($document) {
+ $this->document = $document;
+ }
+
/**
* A simple convenience wrapper around DOMDocument::getElementsByTagName().
*
diff --git a/tests/integration/HTMLValueTest.php b/tests/integration/HTMLValueTest.php
index 600325adf..aa2beadbb 100644
--- a/tests/integration/HTMLValueTest.php
+++ b/tests/integration/HTMLValueTest.php
@@ -6,9 +6,10 @@
class SS_HTMLValueTest extends SapphireTest {
public function testInvalidHTMLSaving() {
- $value = new SS_HTMLValue();
+ $value = new SS_HTMLValue();
$invalid = array (
'Enclosed Value
' => 'Enclosed Value
',
+ '' => '',
'' => '',
'' => '',
'/bodu>/body>' => '/bodu>/body>'
@@ -19,9 +20,22 @@ class SS_HTMLValueTest extends SapphireTest {
$this->assertEquals($expected, $value->getContent(), 'Invalid HTML can be saved');
}
}
-
+
+ public function testUtf8Saving() {
+ $value = new SS_HTMLValue();
+ $value->setContent('ö ß ā い 家
');
+ $this->assertEquals('ö ß ā い 家
', $value->getContent());
+ }
+
+ public function testOutputFormatting() {
+ $value = new SS_HTMLValue();
+ $value->setOutputFormatting(true);
+ $value->setContent('');
+ $this->assertEquals('', $value->getContent(), 'Formatted output works');
+ }
+
public function testInvalidHTMLTagNames() {
- $value = new SS_HTMLValue();
+ $value = new SS_HTMLValue();
$invalid = array(
'',
'',
@@ -30,7 +44,7 @@ class SS_HTMLValueTest extends SapphireTest {
foreach($invalid as $input) {
$value->setContent($input);
- $this->assertEquals (
+ $this->assertEquals(
'test-link',
$value->getElementsByTagName('a')->item(0)->getAttribute('href'),
'Link data can be extraced from malformed HTML'
@@ -47,5 +61,5 @@ class SS_HTMLValueTest extends SapphireTest {
'Newlines get converted'
);
}
-
+
}
From be8ab2ef56dcb038fb9ffb4dfda7892005a248a6 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Tue, 16 Oct 2012 10:25:18 +0200
Subject: [PATCH 3/3] Travis branch exclusions
---
.travis.yml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index e4d835d3e..d2d94d077 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,15 @@ script:
- phpunit -c phpunit.xml.dist
- phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs -np framework
+branches:
+ except:
+ - 2.1
+ - 2.2
+ - 2.3
+ - 2.4
+ - post-2.4
+ - translation-staging
+
notifications:
irc:
channels: