From 51523935fc1f31b91995b5a7562c9ad0cd3795e1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 1 May 2009 03:36:04 +0000 Subject: [PATCH] MINOR Merged from 2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75838 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/ErrorPage.php | 8 ++++---- core/model/Translatable.php | 13 ++++++------- dev/TestRunner.php | 3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/model/ErrorPage.php b/core/model/ErrorPage.php index a0a4d6e73..ff9f5d6fa 100755 --- a/core/model/ErrorPage.php +++ b/core/model/ErrorPage.php @@ -149,12 +149,12 @@ class ErrorPage extends Page { * which is generated through {@link publish()}. * * @param int $statusCode A HTTP Statuscode, mostly 404 or 500 - * @param String $lang A language code in short locale format, e.g. 'de' (Optional) + * @param String $locale A locale, e.g. 'de_DE' (Optional) * @return String */ - static function get_filepath_for_errorcode($statusCode, $lang = null) { - if(Translatable::is_enabled() && $lang && $lang != Translatable::default_lang()) { - return self::$static_filepath . "/error-{$statusCode}-{$lang}.html"; + static function get_filepath_for_errorcode($statusCode, $locale = null) { + if(singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) { + return self::$static_filepath . "/error-{$statusCode}-{$locale}.html"; } else { return self::$static_filepath . "/error-{$statusCode}.html"; } diff --git a/core/model/Translatable.php b/core/model/Translatable.php index 7fc0c9a99..208275988 100755 --- a/core/model/Translatable.php +++ b/core/model/Translatable.php @@ -451,11 +451,14 @@ class Translatable extends DataObjectDecorator { * Use {@link $enable_lang_filter} to temporarily disable this "auto-filtering". */ function augmentSQL(SQLQuery &$query) { - $lang = Translatable::current_locale(); + // If the record is saved (and not a singleton), and has a locale, + // limit the current call to its locale. This fixes a lot of problems + // with other extensions like Versioned + $locale = ($this->owner->ID && $this->owner->Locale) ? $this->owner->Locale : Translatable::current_locale(); $baseTable = ClassInfo::baseDataClass($this->owner->class); $where = $query->where; if( - $lang + $locale // unless the filter has been temporarily disabled && self::$enable_lang_filter // DataObject::get_by_id() should work independently of language @@ -467,11 +470,7 @@ class Translatable extends DataObjectDecorator { && !preg_match('/("|\')Lang("|\')/', $query->getFilter()) //&& !$query->filtersOnFK() ) { - $qry = "`Locale` = '$lang'"; - if(self::$default_locale == self::current_locale()) { - $qry .= " OR `Locale` = '' "; - $qry .= " OR `Locale` IS NULL "; - } + $qry = sprintf('`%s`.`Locale` = \'%s\'', $baseTable, $locale); $query->where[] = $qry; } } diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 17e601529..81f2fdcc5 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -142,6 +142,7 @@ class TestRunner extends Controller { // run tests before outputting anything to the client $suite = new PHPUnit_Framework_TestSuite(); + natcasesort($classList); foreach($classList as $className) { // Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this. class_exists($className); @@ -157,7 +158,7 @@ class TestRunner extends Controller { self::$default_reporter->writeHeader("Sapphire Test Runner"); if (count($classList) > 1) { - self::$default_reporter->writeInfo("All Tests", "Running test cases: " . implode(", ", $classList)); + self::$default_reporter->writeInfo("All Tests", "Running test cases: " . implode(",", $classList)); } else { self::$default_reporter->writeInfo($classList[0], ""); }