aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggAttributeLoader.php
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2013-06-01 21:51:32 -0400
committerSteve Clay <steve@mrclay.org>2013-06-01 21:51:32 -0400
commit2e979f75cd625c42ac5251140a3e7a797108f669 (patch)
tree49926f10be0ab24da3d72541addbce44272c6637 /engine/classes/ElggAttributeLoader.php
parentc7572e614606396617cb1611653f6a759be0a058 (diff)
downloadelgg-2e979f75cd625c42ac5251140a3e7a797108f669.tar.gz
elgg-2e979f75cd625c42ac5251140a3e7a797108f669.tar.bz2
Add filtering for site entities, faster filtering
Diffstat (limited to 'engine/classes/ElggAttributeLoader.php')
-rw-r--r--engine/classes/ElggAttributeLoader.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/engine/classes/ElggAttributeLoader.php b/engine/classes/ElggAttributeLoader.php
index b91e4b88a..0b770da75 100644
--- a/engine/classes/ElggAttributeLoader.php
+++ b/engine/classes/ElggAttributeLoader.php
@@ -24,7 +24,7 @@ class ElggAttributeLoader {
'time_created',
'time_updated',
'last_action',
- 'enabled'
+ 'enabled',
);
/**
@@ -200,6 +200,8 @@ class ElggAttributeLoader {
// saved, these are stored w/ type "site", but with no sites_entity row. These
// are probably only created in the unit tests.
// @todo Don't save vanilla ElggEntities with type "site"
+
+ $row = $this->filterAddedColumns($row);
$row['guid'] = (int) $row['guid'];
return $row;
}
@@ -209,6 +211,8 @@ class ElggAttributeLoader {
}
}
+ $row = $this->filterAddedColumns($row);
+
// Note: If there are still missing attributes, we're running on a 1.7 or earlier schema. We let
// this pass so the upgrades can run.
@@ -217,4 +221,28 @@ class ElggAttributeLoader {
return $row;
}
+
+ /**
+ * Filter out keys returned by the query which should not appear in the entity's attributes
+ *
+ * @param array $row All columns from the query
+ * @return array Columns acceptable for the entity's attributes
+ */
+ protected function filterAddedColumns($row) {
+ // make an array with keys as acceptable attribute names
+ $acceptable_attrs = self::$primary_attr_names;
+ array_splice($acceptable_attrs, count($acceptable_attrs), 0, $this->secondary_attr_names);
+ $acceptable_attrs = array_combine($acceptable_attrs, $acceptable_attrs);
+
+ // @todo remove these when #4584 is in place
+ $acceptable_attrs['tables_split'] = true;
+ $acceptable_attrs['tables_loaded'] = true;
+
+ foreach ($row as $key => $val) {
+ if (!isset($acceptable_attrs[$key])) {
+ unset($row[$key]);
+ }
+ }
+ return $row;
+ }
}