BUGFIX: Prevented notice-level error when publishing HTMLText fiels on tables other than SiteTree. (from r89908) (from r96724)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102346 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 01:49:50 +00:00
parent 9281b28339
commit d89552485e

View File

@ -1485,14 +1485,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
// Published site
$published = DB::query("SELECT * FROM \"SiteTree_Live\" WHERE \"ID\" = $this->ID")->record();
$origPublished = $published;
$published[$fieldName] = str_replace($old, $new, $published[$fieldName], $numReplaced);
if($numReplaced) {
DB::query("UPDATE \"SiteTree_Live\" SET \"$fieldName\" = '"
. Convert::raw2sql($published[$fieldName]) . "' WHERE \"ID\" = $this->ID");
$publishedClass = $origPublished['ClassName'];
$origPublishedObj = new $publishedClass($origPublished);
$this->extend('onRenameLinkedAsset', $origPublishedObj);
// TODO: This doesn't work for HTMLText fields on other tables.
if(isset($published[$fieldName])) {
$published[$fieldName] = str_replace($old, $new, $published[$fieldName], $numReplaced);
if($numReplaced) {
DB::query("UPDATE \"SiteTree_Live\" SET \"$fieldName\" = '"
. Convert::raw2sql($published[$fieldName]) . "' WHERE \"ID\" = $this->ID");
$publishedClass = $origPublished['ClassName'];
$origPublishedObj = new $publishedClass($origPublished);
$this->extend('onRenameLinkedAsset', $origPublishedObj);
}
}
}
}