mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
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:
parent
7c0aa2902f
commit
168b9673d7
@ -705,8 +705,7 @@ JS;
|
||||
* Looks for files used in system and create where clause which contains all ID's of files.
|
||||
*
|
||||
* @returns String where clause which will work as filter.
|
||||
*/
|
||||
|
||||
*/
|
||||
private function getUsedFilesList() {
|
||||
$result = DB::query("SELECT DISTINCT FileID FROM SiteTree_ImageTracking");
|
||||
$usedFiles = array();
|
||||
@ -718,20 +717,20 @@ JS;
|
||||
}
|
||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
||||
foreach($classes as $className) {
|
||||
$sng = singleton($className);
|
||||
$objects = DataObject::get($className);
|
||||
if($objects !== NULL) {
|
||||
foreach($sng->has_one() as $fieldName => $joinClass) {
|
||||
if($joinClass == 'Image' || $joinClass == 'File') {
|
||||
foreach($objects as $object) {
|
||||
if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName;
|
||||
}
|
||||
} elseif($joinClass == 'Folder') {
|
||||
/*foreach($objects as $object) {
|
||||
var_dump($object->$fieldName);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
$query = singleton($className)->extendedSQL();
|
||||
$ids = $query->execute()->column();
|
||||
if(!count($ids)) continue;
|
||||
|
||||
foreach(singleton($className)->has_one() as $fieldName => $joinClass) {
|
||||
if($joinClass == 'Image' || $joinClass == 'File') {
|
||||
foreach($ids as $id) {
|
||||
$object = DataObject::get_by_id($className, $id);
|
||||
if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName;
|
||||
unset($object);
|
||||
}
|
||||
} elseif($joinClass == 'Folder') {
|
||||
// @todo
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($usedFiles as $file) {
|
||||
|
Loading…
Reference in New Issue
Block a user