]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Merge pull request #446 from mrclay/4929-18-entitiesopt
authorBrett Profitt <brett.profitt@gmail.com>
Mon, 17 Dec 2012 15:12:01 +0000 (07:12 -0800)
committerBrett Profitt <brett.profitt@gmail.com>
Mon, 17 Dec 2012 15:12:01 +0000 (07:12 -0800)
Fixes #4929: Optimize elgg_get_entities and add attribute loader

1  2 
engine/classes/ElggPlugin.php
engine/lib/entities.php
engine/lib/plugins.php

index c6ce2905f4207ca010deb76a35c45d153392c8c9,33f14ae37b1e2316d3c2f3a8ac249b660b6c5c02..32b5f952ae731c0b16d6753e11874609c538b191
@@@ -77,68 -76,8 +77,10 @@@ class ElggPlugin extends ElggObject 
                        // load the rest of the plugin
                        parent::__construct($existing_guid);
                }
 +
 +              _elgg_cache_plugin_by_id($this);
        }
  
-       /**
-        * Overridden from ElggEntity and ElggObject::load(). Core always inits plugins with
-        * a query joined to the objects_entity table, so all the info is there.
-        *
-        * @param mixed $guid GUID of an ElggObject or the stdClass object from entities table
-        *
-        * @return bool
-        * @throws InvalidClassException
-        */
-       protected function load($guid) {
-               $expected_attributes = $this->attributes;
-               unset($expected_attributes['tables_split']);
-               unset($expected_attributes['tables_loaded']);
-               // this was loaded with a full join
-               $needs_loaded = false;
-               if ($guid instanceof stdClass) {
-                       $row = (array) $guid;
-                       $missing_attributes = array_diff_key($expected_attributes, $row);
-                       if ($missing_attributes) {
-                               $needs_loaded = true;
-                               $guid = $row['guid'];
-                       } else {
-                               $this->attributes = $row;
-                       }
-               } else {
-                       $needs_loaded = true;
-               }
-               if ($needs_loaded) {
-                       $entity = (array) get_entity_as_row($guid);
-                       $object = (array) get_object_entity_as_row($guid);
-                       if (!$entity || !$object) {
-                               return false;
-                       }
-                       
-                       $this->attributes = array_merge($this->attributes, $entity, $object);
-               }
-               $this->attributes['tables_loaded'] = 2;
-               // Check the type
-               if ($this->attributes['type'] != 'object') {
-                       $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));
-                       throw new InvalidClassException($msg);
-               }
-               // guid needs to be an int  http://trac.elgg.org/ticket/4111
-               $this->attributes['guid'] = (int)$this->attributes['guid'];
-               cache_entity($this);
-               return true;
-       }
        /**
         * Save the plugin object.  Make sure required values exist.
         *
Simple merge
Simple merge