@@ 619-639 (lines=21) @@ | ||
616 | } |
|
617 | ||
618 | // First pass: use cache where possible, gather GUIDs that we're optimizing |
|
619 | foreach ($rows as $i => $row) { |
|
620 | if (empty($row->guid) || empty($row->type)) { |
|
621 | throw new \LogicException('Entity row missing guid or type'); |
|
622 | } |
|
623 | $entity = _elgg_retrieve_cached_entity($row->guid); |
|
624 | if ($entity) { |
|
625 | $entity->refresh($row); |
|
626 | $rows[$i] = $entity; |
|
627 | continue; |
|
628 | } |
|
629 | if (isset($types_to_optimize[$row->type])) { |
|
630 | // check if row already looks JOINed. |
|
631 | if (isset($row->{$types_to_optimize[$row->type]})) { |
|
632 | // Row probably already contains JOINed secondary table. Don't make another query just |
|
633 | // to pull data that's already there |
|
634 | continue; |
|
635 | } |
|
636 | $lookup_types[$row->type][] = $row->guid; |
|
637 | $guid_to_key[$row->guid] = $i; |
|
638 | } |
|
639 | } |
|
640 | // Do secondary queries and merge rows |
|
641 | if ($lookup_types) { |
|
642 | $dbprefix = _elgg_services()->config->get('dbprefix'); |
@@ 107-127 (lines=21) @@ | ||
104 | } |
|
105 | ||
106 | // First pass: use cache where possible, gather GUIDs that we're optimizing |
|
107 | foreach ($rows as $i => $row) { |
|
108 | if (empty($row->guid) || empty($row->type)) { |
|
109 | throw new \LogicException('Entity row missing guid or type'); |
|
110 | } |
|
111 | $entity = _elgg_retrieve_cached_entity($row->guid); |
|
112 | if ($entity) { |
|
113 | $entity->refresh($row); |
|
114 | $rows[$i] = $entity; |
|
115 | continue; |
|
116 | } |
|
117 | if (isset($types_to_optimize[$row->type])) { |
|
118 | // check if row already looks JOINed. |
|
119 | if (isset($row->{$types_to_optimize[$row->type]})) { |
|
120 | // Row probably already contains JOINed secondary table. Don't make another query just |
|
121 | // to pull data that's already there |
|
122 | continue; |
|
123 | } |
|
124 | $lookup_types[$row->type][] = $row->guid; |
|
125 | $guid_to_key[$row->guid] = $i; |
|
126 | } |
|
127 | } |
|
128 | // Do secondary queries and merge rows |
|
129 | if ($lookup_types) { |
|
130 | $dbprefix = _elgg_services()->config->get('dbprefix'); |