From 6136cf85023a4ca50a1e19c7c5ff498cb890bd58 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Mon, 14 Nov 2016 19:02:56 +0000 Subject: [PATCH 1/3] DOCS Update PHPDoc for SS_HTTPResponse --- control/HTTPResponse.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/control/HTTPResponse.php b/control/HTTPResponse.php index c952c9306..0b7f4c06f 100644 --- a/control/HTTPResponse.php +++ b/control/HTTPResponse.php @@ -66,12 +66,12 @@ class SS_HTTPResponse { ); /** - * @var Int + * @var int */ protected $statusCode = 200; /** - * @var String + * @var string */ protected $statusDescription = "OK"; @@ -93,9 +93,9 @@ class SS_HTTPResponse { /** * Create a new HTTP response * - * @param $body The body of the response - * @param $statusCode The numeric status code - 200, 404, etc - * @param $statusDescription The text to be given alongside the status code. + * @param string $body The body of the response + * @param int $statusCode The numeric status code - 200, 404, etc + * @param string $statusDescription The text to be given alongside the status code. * See {@link setStatusCode()} for more information. */ public function __construct($body = null, $statusCode = null, $statusDescription = null) { @@ -104,12 +104,12 @@ class SS_HTTPResponse { } /** - * @param String $code - * @param String $description Optional. See {@link setStatusDescription()}. + * @param int $code + * @param string $description Optional. See {@link setStatusDescription()}. * No newlines are allowed in the description. * If omitted, will default to the standard HTTP description * for the given $code value (see {@link $status_codes}). - * @return SS_HTTPRequest $this + * @return $this */ public function setStatusCode($code, $description = null) { if(isset(self::$status_codes[$code])) $this->statusCode = $code; @@ -124,8 +124,8 @@ class SS_HTTPResponse { * The text to be given alongside the status code ("reason phrase"). * Caution: Will be overwritten by {@link setStatusCode()}. * - * @param String $description - * @return SS_HTTPRequest $this + * @param string $description + * @return $this */ public function setStatusDescription($description) { $this->statusDescription = $description; @@ -133,7 +133,7 @@ class SS_HTTPResponse { } /** - * @return Int + * @return int */ public function getStatusCode() { return $this->statusCode; @@ -157,7 +157,7 @@ class SS_HTTPResponse { /** * @param string $body - * @return SS_HTTPRequest $this + * @return $this */ public function setBody($body) { $this->body = $body ? (string) $body : $body; // Don't type-cast false-ish values, eg null is null not '' @@ -176,7 +176,7 @@ class SS_HTTPResponse { * * @param string $header Example: "Content-Type" * @param string $value Example: "text/xml" - * @return SS_HTTPRequest $this + * @return $this */ public function addHeader($header, $value) { $this->headers[$header] = $value; @@ -206,7 +206,7 @@ class SS_HTTPResponse { * e.g. "Content-Type". * * @param string $header - * @return SS_HTTPRequest $this + * @return $this */ public function removeHeader($header) { if(isset($this->headers[$header])) unset($this->headers[$header]); @@ -216,7 +216,7 @@ class SS_HTTPResponse { /** * @param string $dest * @param int $code - * @return SS_HTTPRequest $this + * @return $this */ public function redirect($dest, $code=302) { if(!in_array($code, self::$redirect_codes)) $code = 302; @@ -310,12 +310,17 @@ EOT */ class SS_HTTPResponse_Exception extends Exception { + /** + * @var SS_HTTPResponse + */ protected $response; /** * @param string|SS_HTTPResponse body Either the plaintext content of the error message, or an SS_HTTPResponse * object representing it. In either case, the $statusCode and * $statusDescription will be the HTTP status of the resulting response. + * @param int $statusCode + * @param string $statusDescription * @see SS_HTTPResponse::__construct(); */ public function __construct($body = null, $statusCode = null, $statusDescription = null) { From bec5adf09b733904a4e8d0aa55bdc337489af533 Mon Sep 17 00:00:00 2001 From: Jonathon Menz Date: Fri, 21 Oct 2016 19:33:32 -0700 Subject: [PATCH 2/3] FIX Versioned sort by ID Prevent SQL error from a Versioned DataObject with e.g. $default_sort = 'ID DESC' --- model/Versioned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/Versioned.php b/model/Versioned.php index af1648b65..6ab3a25a4 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -313,7 +313,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider { // Ensure that any sort order referring to this ID is correctly aliased $orders = $query->getOrderBy(); foreach($orders as $order => $dir) { - if($order === "\"$baseTable\".\"ID\"") { + if($order === "\"$baseTable\".\"ID\"" || trim($order, "'\"") === "ID") { unset($orders[$order]); $orders["\"{$baseTable}_versions\".\"RecordID\""] = $dir; } From 03b4e6ea3201736c62a73e301489fe6a65a01a0f Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 23 Nov 2016 12:36:53 +0000 Subject: [PATCH 3/3] FIX Tests shouldnt set date or time format to null --- dev/SapphireTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 0964019c3..30f330520 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -188,8 +188,6 @@ class SapphireTest extends PHPUnit_Framework_TestCase { // i18n needs to be set to the defaults or tests fail i18n::set_locale(i18n::default_locale()); - i18n::config()->date_format = null; - i18n::config()->time_format = null; // Set default timezone consistently to avoid NZ-specific dependencies date_default_timezone_set('UTC');