← All changes
|
src/actions/indexing/abstract-link-indexing-action.php
+15
-1
27.7
→
trunk
View file →
| @@ -68,11 +68,25 @@ | ||
| 68 | 68 | */ |
| 69 | 69 | public function index() { |
| 70 | 70 | $objects = $this->get_objects(); |
| 71 | 71 | |
| 72 | + $objects_by_type = []; | |
| 73 | + foreach ( $objects as $object ) { | |
| 74 | + $objects_by_type[ $object->type ][] = (int) $object->id; | |
| 75 | + } | |
| 76 | + | |
| 77 | + $indexable_map = []; | |
| 78 | + foreach ( $objects_by_type as $type => $ids ) { | |
| 79 | + foreach ( $this->repository->find_by_multiple_ids_and_type( $ids, $type ) as $indexable ) { | |
| 80 | + if ( $indexable ) { | |
| 81 | + $indexable_map[ $type ][ (int) $indexable->object_id ] = $indexable; | |
| 82 | + } | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 72 | 86 | $indexables = []; |
| 73 | 87 | foreach ( $objects as $object ) { |
| 74 | - $indexable = $this->repository->find_by_id_and_type( $object->id, $object->type ); | |
| 88 | + $indexable = ( $indexable_map[ $object->type ][ (int) $object->id ] ?? null ); | |
| 75 | 89 | if ( $indexable ) { |
| 76 | 90 | $this->link_builder->build( $indexable, $object->content ); |
| 77 | 91 | $this->indexable_helper->save_indexable( $indexable ); |
| 78 | 92 | |