From the top of my head and without having at hand, right now another solution, i can only tell that this
...
AND o.id NOT IN(
SELECT contentobject_id FROM ezcontentobject_name WHERE real_translation = "'.$language.'" )
';
can be of an issue in case of a large content base, perf-wise.
Exactly ! I should have warn about this potential issue
I was convinced there was a way to make a SQL query that gets records not matching a join but can't figure out how to do this with MySQL.
It's runing fine so far with about 22 000 record in ezcontentobject_name
Another point about ezcontentobject_name's real_translation and content_translation fields : Those two fields looks like storing the same data so I just took one of them... Not a very scientific approach I admit.
mysql> SELECT COUNT(*) FROM ezcontentobject_name WHERE content_translation != real_translation ;
+----------+
| COUNT(*) |
+----------+
| 0 | +----------+
Why not joining on the ezcontentobject_name table ?
SELECT t.node_id FROM ezcontentobject_tree t, ezcontentclass c, ezcontentobject o, ezcontentobject_name oname
WHERE c.identifier NOT IN("'. implode('", "', $excludeClasses ).'" )
AND c.id = o.contentclass_id
AND o.id = t.contentobject_id
AND t.contentobject_id = oname.contentobject_id
AND t.node_id = t.main_node_id
AND t.path_string like "'.$parentNode['path_string'].'%"
AND oname.real_translation != "'.$language.'"
--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board