Created by
Oleksiy Kalinichenko
| Index: xmlsitemap.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- xmlsitemap.module (revision 1faf49be5d5c29239d0977ec81a714bd44f162b0)
+++ xmlsitemap.module (revision 0fc4fa7f0eb4199c4a689b47ac7e3908d757a25a)
@@ -1560,7 +1560,7 @@
xmlsitemap_xmlsitemap_process_entity_links($entity_type_id, $ids);
}
catch (QueryException $e) {
-
+ // nop
}
}
}
@@ -1568,18 +1568,24 @@
/**
* Process sitemap links.
*
- * @param array $entities
- * An array of \Drupal\Core\Entity\EntityInterface objects.
- * @param array
+ * @param string $entity_type
+ * The entity type to load, e.g. node or user.
+ * @param array $ids
* Entity ids to be processed.
*/
function xmlsitemap_xmlsitemap_process_entity_links($entity_type, array $ids) {
- $entities = entity_load_multiple($entity_type, $ids);
- $anonymous_user = new AnonymousUserSession();
- foreach ($entities as $entity) {
- $link_storage = \Drupal::service('xmlsitemap.link_storage');
- $link = $link_storage->create($entity);
- $link_storage->save($link);
+ /** @var \Drupal\xmlsitemap\XmlSitemapLinkStorage $link_storage */
+ $link_storage = \Drupal::service('xmlsitemap.link_storage');
+ /** @var \Drupal\Core\Entity\EntityStorageInterface $entity_storage */
+ $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type);
+
+ foreach (array_chunk($ids, 100) as $chunked_ids) {
+ foreach ($entity_storage->loadMultiple($chunked_ids) as $entity) {
+ /** @var array $link */
+ $link = $link_storage->create($entity);
+ $link_storage->save($link);
+ }
+ $entity_storage->resetCache();
}
}
|