aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-09 16:30:26 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-09 16:30:26 +0000
commit72a23a6b2bae1cf907484b435987dce0c16e66f0 (patch)
tree0a4573e2d384adc358ed170c93031b7eb7258579 /engine/lib/entities.php
parentce53ba5234dc3614de4171c4d5c5ba78fe5ffe98 (diff)
downloadelgg-72a23a6b2bae1cf907484b435987dce0c16e66f0.tar.gz
elgg-72a23a6b2bae1cf907484b435987dce0c16e66f0.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Added table counter git-svn-id: https://code.elgg.org/elgg/trunk@837 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index cbcd5ccad..7e1bd8ab7 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -65,6 +65,20 @@
$this->attributes['access_id'] = 0;
$this->attributes['time_created'] = "";
$this->attributes['time_updated'] = "";
+
+ // There now follows a bit of a hack
+ /* Problem: To speed things up, some objects are split over several tables, this means that it requires
+ * n number of database reads to fully populate an entity. This causes problems for caching and create events
+ * since it is not possible to tell whether a subclassed entity is complete.
+ * Solution: We have two counters, one 'tables_split' which tells whatever is interested how many tables
+ * are going to need to be searched in order to fully populate this object, and 'tables_loaded' which is how
+ * many have been loaded thus far.
+ * If the two are the same then this object is complete.
+ *
+ * Use: isFullyLoaded() to check
+ */
+ $this->attributes['tables_split'] = 1;
+ $this->attributes['tables_loaded'] = 0;
}
/**
@@ -391,6 +405,13 @@
public function getURL() { return get_entity_url($this->getGUID()); }
/**
+ * Tests to see whether the object has been fully loaded.
+ *
+ * @return bool
+ */
+ public function isFullyLoaded() { return $this->attributes['tables_split'] == $this->attributes['tables_loaded']; }
+
+ /**
* Save generic attributes to the entities table.
*/
public function save()
@@ -445,6 +466,9 @@
foreach($objarray as $key => $value)
$this->attributes[$key] = $value;
+ // Increment the portion counter
+ $this->attributes['tables_loaded'] ++;
+
// Cache object handle
if ($this->attributes['guid']) cache_entity($this);
@@ -499,6 +523,9 @@
case 'type' : // Don't use type
case 'access_id' : // Don't use access - if can export then its public for you, then importer decides what access to give this object.
case 'time_updated' : // Don't use date in export
+
+ case 'tables_split' : // We don't want to export the internal counter variables.
+ case 'tables_loaded' : // Or this one
break;
case 'time_created' : // Created = published