Forums / Setup & design / trash count[SOLVED]

trash count[SOLVED]

Author Message

Mads Ovesen

Wednesday 09 November 2005 3:45:04 am

I have a problem with the trash in admin. Even though there are only 20 objects in the trashcan, the trash_count function thinks there are 400. This causes the google to make a lot of empty pages. Does anyone know whats wrong and how to fix this problem?

- Thx

/m

Ɓukasz Serwatka

Tuesday 13 December 2005 11:54:05 pm

Hi Mads,

Could you post your solution here?

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Mads Ovesen

Monday 19 December 2005 3:04:48 am

Sure, I was going to, but just forgot about it. There are two functions controlling the trash in trash.tpl:
1) Trash_count fetches the number of items in the trash (objects with status 2 in the ezcontentobject table).
2) Trash_object_list fetches the trashed objects (also status 2).

The integer returned by trash_count is different compared to the number of objects returned by trash_object_list in version 3.4.8. The reason is that the trash_object_list function is based on each user while trash_count is based on the global trash. I can't come up with a reason why this is so, so I made trash_count function count only the trash objects of each user by editing the following in kernel/content/ezcontentfunctioncollection.php to the following:

function fetchTrashObjectCount()
    {
        $userID = ezUser::currentUserID();
        $trashObjectList = &eZPersistentObject::fetchObjectList( 
                       eZContentObject::definition(), array(), 
                       array( 'status' => EZ_CONTENT_OBJECT_STATUS_ARCHIVED, 'owner_id' => $userID ), 
                       array(), null, false,false, 
                       array( array( 'operation' => 'count( * )',                                                                                                                                                        
                       'name' => 'count' ) ) );     

return array( 'result' => $trashObjectList[0]['count'] );
}

/m