@@ -257,19 +257,47 @@ protected function getAncestorLookupSql(array $batch)
257
257
INNER JOIN {$ this ->options ['oid_ancestors_table_name ' ]} a ON a.object_identity_id = o.id
258
258
WHERE (
259
259
SELECTCLAUSE ;
260
-
261
- $ where = ' (o.object_identifier = %s AND c.class_type = %s) ' ;
260
+
261
+ $ types = array () ;
262
262
for ($ i =0 ,$ c =count ($ batch ); $ i <$ c ; $ i ++) {
263
- $ sql .= sprintf (
264
- $ where ,
265
- $ this ->connection ->quote ($ batch [$ i ]->getIdentifier ()),
266
- $ this ->connection ->quote ($ batch [$ i ]->getType ())
267
- );
268
-
269
- if ($ i +1 < $ c ) {
270
- $ sql .= ' OR ' ;
271
- }
263
+ if (!isset ($ types [$ batch [$ i ]->getType ()])) {
264
+ $ types [$ batch [$ i ]->getType ()] = true ;
265
+ if (count ($ batch ) > 1 ) {
266
+ break ;
267
+ }
268
+ }
272
269
}
270
+
271
+ if (count ($ types ) === 1 ) {
272
+
273
+ $ where = '(o.object_identifier IN (%s) AND c.class_type = %s) ' ;
274
+ $ ids = array ();
275
+ for ($ i =0 ,$ c =count ($ batch ); $ i <$ c ; $ i ++) {
276
+ $ ids [] = $ this ->connection ->quote ($ batch [$ i ]->getIdentifier ());
277
+ }
278
+
279
+ $ sql .= sprintf (
280
+ $ where ,
281
+ implode (', ' , $ ids ),
282
+ $ this ->connection ->quote ($ batch [0 ]->getType ())
283
+ );
284
+
285
+ } else {
286
+
287
+ $ where = '(o.object_identifier = %s AND c.class_type = %s) ' ;
288
+ for ($ i =0 ,$ c =count ($ batch ); $ i <$ c ; $ i ++) {
289
+ $ sql .= sprintf (
290
+ $ where ,
291
+ $ this ->connection ->quote ($ batch [$ i ]->getIdentifier ()),
292
+ $ this ->connection ->quote ($ batch [$ i ]->getType ())
293
+ );
294
+
295
+ if ($ i +1 < $ c ) {
296
+ $ sql .= ' OR ' ;
297
+ }
298
+ }
299
+ }
300
+
273
301
274
302
$ sql .= ') ' ;
275
303
@@ -417,7 +445,7 @@ private function doUpdateAceIdentityMap(array &$aces)
417
445
* @param array $oidLookup
418
446
*
419
447
* @return \SplObjectStorage mapping object identities to ACL instances
420
- *
448
+ *
421
449
* @throws AclNotFoundException
422
450
*/
423
451
private function lookupObjectIdentities (array $ batch , array $ sids , array $ oidLookup )
0 commit comments