Increased core dep from 3.1 to 3.2

3.2 still uses SQLQuery rather than SQLSelect,
but changes the getWhere() return signature.
This commit is contained in:
Ingo Schommer 2015-02-21 15:56:01 +13:00
parent 1b196d8a83
commit f6d74a21d2
4 changed files with 16 additions and 11 deletions

View File

@ -6,7 +6,7 @@ php:
- 5.4 - 5.4
env: env:
- DB=MYSQL CORE_RELEASE=3.1 - DB=MYSQL CORE_RELEASE=3.2
before_script: before_script:
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer - pear -q install --onlyreqdeps pear/PHP_CodeSniffer

View File

@ -13,8 +13,7 @@ Note: This module was originally part of the SilverStripe CMS 2.x codebase.
## Requirements ## ## Requirements ##
* SilverStripe Framework 3.1+ and CMS 3.1+ * SilverStripe Framework 3.2+ and CMS 3.2+
* Note: For SilverStripe 2.3/2.4 support, please use the core built-in version (no module required)
## Maintainers ## ## Maintainers ##

View File

@ -590,7 +590,7 @@ class Translatable extends DataExtension implements PermissionProvider {
* *
* Use {@link disable_locale_filter()} to temporarily disable this "auto-filtering". * Use {@link disable_locale_filter()} to temporarily disable this "auto-filtering".
*/ */
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) { public function augmentSQL(SQLQuery &$query, DataQuery $dataQuery = null) {
// If the record is saved (and not a singleton), and has a 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 // limit the current call to its locale. This fixes a lot of problems
// with other extensions like Versioned // with other extensions like Versioned
@ -612,13 +612,19 @@ class Translatable extends DataExtension implements PermissionProvider {
// the query contains this table // the query contains this table
// @todo Isn't this always the case?! // @todo Isn't this always the case?!
&& array_search($baseTable, array_keys($query->getFrom())) !== false && array_search($baseTable, array_keys($query->getFrom())) !== false
// or we're already filtering by Lang (either from an earlier augmentSQL()
// call or through custom SQL filters)
&& !preg_match('/("|\'|`)Locale("|\'|`)/', implode(' ', $query->getWhere()))
//&& !$query->filtersOnFK() //&& !$query->filtersOnFK()
) { ) {
$qry = sprintf('"%s"."Locale" = \'%s\'', $baseTable, Convert::raw2sql($locale)); // Or we're already filtering by Lang (either from an earlier augmentSQL()
$query->addWhere($qry); // call or through custom SQL filters)
$filtersOnLocale = array_filter($query->getWhere(), function($predicates) {
foreach($predicates as $predicate => $params) {
if(preg_match('/("|\'|`)Locale("|\'|`)/', $predicate)) return true;
}
});
if(!$filtersOnLocale) {
$qry = sprintf('"%s"."Locale" = \'%s\'', $baseTable, Convert::raw2sql($locale));
$query->addWhere($qry);
}
} }
} }

View File

@ -15,8 +15,8 @@
"require": "require":
{ {
"php": ">=5.3.2", "php": ">=5.3.2",
"silverstripe/framework": "~3.1", "silverstripe/framework": "~3.2",
"silverstripe/cms": "~3.1" "silverstripe/cms": "~3.2"
}, },
"require-dev": { "require-dev": {
"silverstripe/postgresql": "*", "silverstripe/postgresql": "*",