In #2169099: Avoid unnecessary entity loads in group reference fields, we eliminated a call to Entity's load() method when loading field values. Looking at the codebase, it appears we can eliminate another call to this method when saving group field values.

In the attached patch, I followed the same approach of using og_get_entity_groups() instead of

$wrapper->{$field_name . '__og_membership'}->value() 

from #2169099 in _og_update_entity_fields().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

+++ b/og.module
@@ -929,9 +929,9 @@ function _og_update_entity_fields($entity_type, $entity) {
+      $gids = empty($gids) ? array() : array_values($gids[$target_type]);

shouldn't it be

$gids = !empty($gids[$target_type]) ? $gids[$target_type] : array();

ezra-g’s picture

Yes, that sounds correct. Thanks for the fast review!

Here's an updated patch.

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

  • Commit bf78bc7 on 7.x-2.x by Amitaibu:
    Revert "Issue #2220575 by ezra-g: Avoid Entity's load() method when...

  • Commit d187c93 on 7.x-2.x by Amitaibu:
    Revert "Revert "Issue #2220575 by ezra-g: Avoid Entity's load() method...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

guillaumev’s picture

This commit apparently caused this issue: https://drupal.org/node/2264759