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.
|
* 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.
|
* @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,20 +717,20 @@ 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) {
|
|
||||||
if($joinClass == 'Image' || $joinClass == 'File') {
|
foreach(singleton($className)->has_one() as $fieldName => $joinClass) {
|
||||||
foreach($objects as $object) {
|
if($joinClass == 'Image' || $joinClass == 'File') {
|
||||||
if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName;
|
foreach($ids as $id) {
|
||||||
}
|
$object = DataObject::get_by_id($className, $id);
|
||||||
} elseif($joinClass == 'Folder') {
|
if($object->$fieldName != NULL) $usedFiles[] = $object->$fieldName;
|
||||||
/*foreach($objects as $object) {
|
unset($object);
|
||||||
var_dump($object->$fieldName);
|
}
|
||||||
}*/
|
} elseif($joinClass == 'Folder') {
|
||||||
}
|
// @todo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($usedFiles as $file) {
|
foreach($usedFiles as $file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user