Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX Don't call LinkTracking/ImageTracking relationships in HTMLEdi…

…torField->saveInto() unless we have internal links/files to save. This helps to improve CMS saving times on records with many HTMLEditorField instances

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114139 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit eeed9ce189f61d721b69586eaab46d88f6a0e101 1 parent 19f7484
@chillu chillu authored
Showing with 17 additions and 10 deletions.
  1. +17 −10 forms/HtmlEditorField.php
View
27 forms/HtmlEditorField.php
@@ -138,24 +138,31 @@ public function saveInto($record) {
}
// Save file & link tracking data.
- if($record->ID && $record->many_many('LinkTracking') && $tracker = $record->LinkTracking()) {
+
+ if($record->ID && $record->many_many('LinkTracking')) {
$filter = sprintf('"FieldName" = \'%s\' AND "SiteTreeID" = %d', $this->name, $record->ID);
- DB::query("DELETE FROM \"$tracker->tableName\" WHERE $filter");
+ DB::query("DELETE FROM \"SiteTree_LinkTracking\" WHERE $filter");
- if($linkedPages) foreach($linkedPages as $item) {
- $SQL_fieldName = Convert::raw2sql($this->name);
- DB::query("INSERT INTO \"SiteTree_LinkTracking\" (\"SiteTreeID\",\"ChildID\", \"FieldName\")
- VALUES ($record->ID, $item, '$SQL_fieldName')");
+ if($linkedPages) {
+ $tracker = $record->LinkTracking();
+ foreach($linkedPages as $item) {
+ $SQL_fieldName = Convert::raw2sql($this->name);
+ DB::query("INSERT INTO \"SiteTree_LinkTracking\" (\"SiteTreeID\",\"ChildID\", \"FieldName\")
+ VALUES ($record->ID, $item, '$SQL_fieldName')");
+ }
}
}
- if($record->ID && $record->many_many('ImageTracking') && $tracker = $record->ImageTracking()) {
+ if($record->ID && $record->many_many('ImageTracking')) {
$filter = sprintf('"FieldName" = \'%s\' AND "SiteTreeID" = %d', $this->name, $record->ID);
- DB::query("DELETE FROM \"$tracker->tableName\" WHERE $filter");
+ DB::query("DELETE FROM \"SiteTree_ImageTracking\" WHERE $filter");
$fieldName = $this->name;
- if($linkedFiles) foreach($linkedFiles as $item) {
- $tracker->add($item, array('FieldName' => $this->name));
+ if($linkedFiles) {
+ $tracker = $record->ImageTracking();
+ foreach($linkedFiles as $item) {
+ $tracker->add($item, array('FieldName' => $this->name));
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.