mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 09:05:59 +00:00
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:
parent
1b196d8a83
commit
f6d74a21d2
@ -6,7 +6,7 @@ php:
|
||||
- 5.4
|
||||
|
||||
env:
|
||||
- DB=MYSQL CORE_RELEASE=3.1
|
||||
- DB=MYSQL CORE_RELEASE=3.2
|
||||
|
||||
before_script:
|
||||
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
|
||||
|
@ -13,8 +13,7 @@ Note: This module was originally part of the SilverStripe CMS 2.x codebase.
|
||||
|
||||
## Requirements ##
|
||||
|
||||
* SilverStripe Framework 3.1+ and CMS 3.1+
|
||||
* Note: For SilverStripe 2.3/2.4 support, please use the core built-in version (no module required)
|
||||
* SilverStripe Framework 3.2+ and CMS 3.2+
|
||||
|
||||
## Maintainers ##
|
||||
|
||||
|
@ -590,7 +590,7 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
*
|
||||
* 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,
|
||||
// limit the current call to its locale. This fixes a lot of problems
|
||||
// with other extensions like Versioned
|
||||
@ -612,13 +612,19 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
// the query contains this table
|
||||
// @todo Isn't this always the case?!
|
||||
&& 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()
|
||||
) {
|
||||
$qry = sprintf('"%s"."Locale" = \'%s\'', $baseTable, Convert::raw2sql($locale));
|
||||
$query->addWhere($qry);
|
||||
// Or we're already filtering by Lang (either from an earlier augmentSQL()
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
"require":
|
||||
{
|
||||
"php": ">=5.3.2",
|
||||
"silverstripe/framework": "~3.1",
|
||||
"silverstripe/cms": "~3.1"
|
||||
"silverstripe/framework": "~3.2",
|
||||
"silverstripe/cms": "~3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"silverstripe/postgresql": "*",
|
||||
|
Loading…
x
Reference in New Issue
Block a user