BUGFIX getUsedFilesList() now gets single DataObjects one-by-one instead of the whole DataObjectSet of *all* File instances in the database (which is a huge memory hog on each AssetAdmin call)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@55080 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-05-24 05:16:05 +00:00
parent 7c0aa2902f
commit 168b9673d7

View File

@ -706,7 +706,6 @@ JS;
* *
* @returns String where clause which will work as filter. * @returns String where clause which will work as filter.
*/ */
private function getUsedFilesList() { private function getUsedFilesList() {
$result = DB::query("SELECT DISTINCT FileID FROM SiteTree_ImageTracking"); $result = DB::query("SELECT DISTINCT FileID FROM SiteTree_ImageTracking");
$usedFiles = array(); $usedFiles = array();
@ -718,19 +717,19 @@ JS;
} }
$classes = ClassInfo::subclassesFor('SiteTree'); $classes = ClassInfo::subclassesFor('SiteTree');
foreach($classes as $className) { foreach($classes as $className) {
$sng = singleton($className); $query = singleton($className)->extendedSQL();
$objects = DataObject::get($className); $ids = $query->execute()->column();
if($objects !== NULL) { if(!count($ids)) continue;
foreach($sng->has_one() as $fieldName => $joinClass) {
foreach(singleton($className)->has_one() as $fieldName => $joinClass) {
if($joinClass == 'Image' || $joinClass == 'File') { if($joinClass == 'Image' || $joinClass == 'File') {
foreach($objects as $object) { foreach($ids as $id) {
$object = DataObject::get_by_id($className, $id);
if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName; if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName;
unset($object);
} }
} elseif($joinClass == 'Folder') { } elseif($joinClass == 'Folder') {
/*foreach($objects as $object) { // @todo
var_dump($object->$fieldName);
}*/
}
} }
} }
} }