@@ -14,7 +14,7 @@ static function citiesBySubtree( eZContentObjectTreeNode $node, $params )
14
14
15
15
$ object_state = ($ params ['object_state ' ]!=null ) ? true : false ;
16
16
17
- $ subselect = ($ object_state )?"JOIN ezcobj_state_link AS ezlink ON ezlink.contentobject_id = ezobj.id AND ezlink.contentobject_state_id = {$ params ['object_state ' ]}" : "" ;
17
+ $ subselect = ($ object_state )?"JOIN ezcobj_state_link AS ezlink ON ezlink.contentobject_id = x.obj_id AND ezlink.contentobject_state_id = {$ params ['object_state ' ]}" : "" ;
18
18
19
19
$ cacheDir = eZSys::cacheDirectory ();
20
20
$ currentSiteAccessName = $ GLOBALS ['eZCurrentAccess ' ]['name ' ];
@@ -27,25 +27,21 @@ static function citiesBySubtree( eZContentObjectTreeNode $node, $params )
27
27
$ cacheFile = eZClusterFileHandler::instance ( $ cacheFilePath );
28
28
if ( !$ cacheFile ->exists () or ( time () - $ cacheFile ->mtime () > $ cacheTime ) )
29
29
{
30
- $ list = $ db ->arrayQuery ( "SELECT city, count(city) as 'count' FROM ezxgis_position AS gisp
31
- JOIN ezcontentobject_attribute AS ezatt
32
- ON gisp.contentobject_attribute_id = ezatt.id
33
- JOIN ezcontentobject as ezobj
34
- ON ezatt.contentobject_id = ezobj.id
35
- AND ezobj.current_version = gisp.contentobject_attribute_version
36
- JOIN ezcontentobject_tree as eztree
37
- ON ezobj.id = eztree.contentobject_id
38
- AND eztree.path_string LIKE ' {$ node ->attribute ('path_string ' )}%'
39
- AND eztree.is_hidden = 0
40
- AND eztree.is_invisible = 0
41
- {$ subselect }
42
- WHERE city != ''
43
- GROUP BY city
44
- ORDER BY count desc " , array ('column ' => 'city ' ) );
30
+ $ list = $ db ->arrayQuery ( "(SELECT city, count(city) as 'count' FROM ezxgis_position AS gisp,
31
+ (SELECT ezatt.id AS obj_att_id, x.obj_id, x.obj_current_version FROM ezcontentobject_attribute AS ezatt,
32
+ (SELECT ezobj.id AS obj_id, ezobj.current_version AS obj_current_version FROM ezcontentobject AS ezobj,
33
+ (SELECT contentobject_id FROM ezcontentobject_tree AS eztree
34
+ WHERE eztree.path_string LIKE ' {$ node ->attribute ('path_string ' )}%' AND eztree.is_hidden = 0 AND eztree.is_invisible = 0
35
+ ) AS z
36
+ WHERE z.contentobject_id = ezobj.id
37
+ ) AS x
38
+ {$ subselect }
39
+ WHERE ezatt.contentobject_id = x.obj_id
40
+ ) AS y
41
+ WHERE city != '' AND gisp.contentobject_attribute_id = y.obj_att_id AND gisp.contentobject_attribute_version = y.obj_current_version
42
+ GROUP BY city ORDER BY null) ORDER BY count desc " , array ('column ' => 'city ' ) );
45
43
$ cacheFile ->storeContents ( serialize ( $ list ), 'query_cache ' , 'json ' );
46
- }
47
- else
48
- {
44
+ } else {
49
45
$ list = unserialize ( $ cacheFile ->fetchContents () );
50
46
}
51
47
return $ list ;
0 commit comments