aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/entities.php27
-rw-r--r--engine/lib/objects.php7
-rw-r--r--engine/lib/sites.php7
-rw-r--r--engine/lib/users.php7
4 files changed, 45 insertions, 3 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
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 3c7448137..d1e9b78c2 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -136,7 +136,12 @@
return false;
// Now save specific stuff
- return create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'));
+ $result = create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'));
+
+ // Increment the portion counter
+ if ($result) $this->attributes['tables_loaded'] ++;
+
+ return $result;
}
/**
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index cceffcda2..96e65d7c2 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -142,7 +142,12 @@
return false;
// Now save specific stuff
- return create_site_entity($this->get('guid'), $this->get('name'), $this->get('description'), $this->get('url'));
+ $result = create_site_entity($this->get('guid'), $this->get('name'), $this->get('description'), $this->get('url'));
+
+ // Increment the portion counter
+ if ($result) $this->attributes['tables_loaded'] ++;
+
+ return $result;
}
/**
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 2466170fa..2718d18b9 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -149,7 +149,12 @@
return false;
// Now save specific stuff
- return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('email'), $this->get('language'), $this->get('code'));
+ $result = create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('email'), $this->get('language'), $this->get('code'));
+
+ // Increment the portion counter
+ if ($result) $this->attributes['tables_loaded'] ++;
+
+ return $result;
}
/**