@@ -125,6 +125,7 @@ public function resolve($type, array $ids, $language = NULL, array $bundles = NU
125125 $ resolver = $ this ->entityBuffer ->add ($ type , $ ids );
126126
127127 return new Deferred (function () use ($ type , $ ids , $ language , $ bundles , $ resolver , $ context ) {
128+ /** @var \Drupal\Core\Entity\EntityInterface[] $entities */
128129 if (!$ entities = $ resolver ()) {
129130 // If there is no entity with this id, add the list cache tags so that the
130131 // cache entry is purged whenever a new entity of this type is saved.
@@ -137,16 +138,15 @@ public function resolve($type, array $ids, $language = NULL, array $bundles = NU
137138
138139 foreach ($ entities as $ id => $ entity ) {
139140 $ context ->addCacheableDependency ($ entities [$ id ]);
140-
141141 if (isset ($ bundles ) && !in_array ($ entities [$ id ]->bundle (), $ bundles )) {
142142 // If the entity is not among the allowed bundles, don't return it.
143143 unset($ entities [$ id ]);
144144 continue ;
145145 }
146146
147- if (isset ($ language ) && $ language != $ entities [$ id ]->language ()
148- ->getId () && $ entities [$ id ] instanceof TranslatableInterface) {
147+ if (isset ($ language ) && $ language !== $ entities [$ id ]->language ()->getId () && $ entities [$ id ] instanceof TranslatableInterface) {
149148 $ entities [$ id ] = $ entities [$ id ]->getTranslation ($ language );
149+ $ entities [$ id ]->addCacheContexts (["static:language: {$ language }" ]);
150150 }
151151
152152 $ access = $ entity ->access ('view ' , NULL , TRUE );
0 commit comments