mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Reverted text replacement performance improvement in SQLQuery - it was replacing more ocurrences via str_replace() than the previous implementation based on arrays, which broke queries augmented by Translatable (originally committed in r60468 and r54044)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65291 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
486ae69f09
commit
ccd149f689
@ -65,8 +65,6 @@ class SQLQuery extends Object {
|
|||||||
*/
|
*/
|
||||||
public $delete = false;
|
public $delete = false;
|
||||||
|
|
||||||
private $replacements = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logical connective used to join WHERE clauses. Defaults to AND.
|
* The logical connective used to join WHERE clauses. Defaults to AND.
|
||||||
* @var string
|
* @var string
|
||||||
@ -354,8 +352,6 @@ class SQLQuery extends Object {
|
|||||||
* @param string $new The new text.
|
* @param string $new The new text.
|
||||||
*/
|
*/
|
||||||
function replaceText($old, $new) {
|
function replaceText($old, $new) {
|
||||||
$this->replacements[] = array($old, $new);
|
|
||||||
/*
|
|
||||||
if($this->select) foreach($this->select as $i => $item)
|
if($this->select) foreach($this->select as $i => $item)
|
||||||
$this->select[$i] = str_replace($old, $new, $item);
|
$this->select[$i] = str_replace($old, $new, $item);
|
||||||
|
|
||||||
@ -378,7 +374,6 @@ class SQLQuery extends Object {
|
|||||||
foreach($this->having as $i => $item)
|
foreach($this->having as $i => $item)
|
||||||
$this->having[$i] = str_replace($old, $new, $item);
|
$this->having[$i] = str_replace($old, $new, $item);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,10 +406,6 @@ class SQLQuery extends Object {
|
|||||||
if($this->orderby) $text .= " ORDER BY " . $this->orderby;
|
if($this->orderby) $text .= " ORDER BY " . $this->orderby;
|
||||||
if($this->limit) $text .= " LIMIT " . $this->limit;
|
if($this->limit) $text .= " LIMIT " . $this->limit;
|
||||||
|
|
||||||
foreach($this->replacements as $replacement) {
|
|
||||||
$text = str_replace($replacement[0], $replacement[1], $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user