aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-04-16 11:52:37 -0400
committerBrett Profitt <brett.profitt@gmail.com>2011-04-16 11:52:37 -0400
commit309dff2bf948ab191ccb1e8d4a777e49ad498820 (patch)
tree813350181be64e239287c0bb587a3a49320a49b7 /engine
parent119ec1f1425ab77ed29c696d99c0c80df3886791 (diff)
parent2b2afd98c05139c1a5c25f1752e2bb412e26e335 (diff)
downloadelgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.gz
elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.bz2
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggEntity.php23
-rw-r--r--engine/classes/ElggMenuItem.php5
-rw-r--r--engine/classes/ElggPAM.php7
-rw-r--r--engine/classes/ElggUser.php8
-rw-r--r--engine/handlers/cache_handler.php15
-rw-r--r--engine/lib/actions.php6
-rw-r--r--engine/lib/cache.php2
-rw-r--r--engine/lib/deprecated-1.8.php28
-rw-r--r--engine/lib/elgglib.php76
-rw-r--r--engine/lib/entities.php2
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/output.php2
-rw-r--r--engine/lib/sessions.php4
-rw-r--r--engine/lib/upgrade.php2
-rw-r--r--engine/lib/upgrades/2011010101.php18
-rw-r--r--engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php60
-rw-r--r--engine/lib/widgets.php1
-rw-r--r--engine/tests/api/entity_getter_functions.php51
-rw-r--r--engine/tests/api/helpers.php4
-rw-r--r--engine/tests/objects/entities.php2
-rw-r--r--engine/tests/services/api.php8
21 files changed, 177 insertions, 149 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index cfdaede71..79b8c2a4e 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -246,18 +246,20 @@ abstract class ElggEntity extends ElggData implements
* @return mixed The value, or NULL if not found.
*/
public function getMetaData($name) {
- if ((int) ($this->guid) > 0) {
- $md = elgg_get_metadata(array(
- 'guid' => $this->getGUID(),
- 'metadata_name' => $name,
- 'limit' => 0,
- ));
- } else {
+ if ((int) ($this->guid) == 0) {
if (isset($this->temp_metadata[$name])) {
return $this->temp_metadata[$name];
+ } else {
+ return null;
}
}
+ $md = elgg_get_metadata(array(
+ 'guid' => $this->getGUID(),
+ 'metadata_name' => $name,
+ 'limit' => 0,
+ ));
+
if ($md && !is_array($md)) {
return $md->value;
} elseif (count($md) == 1) {
@@ -717,6 +719,9 @@ abstract class ElggEntity extends ElggData implements
*
* @warning By default, annotations are private.
*
+ * @warning Annotating an unsaved entity more than once with the same name
+ * will only save the last annotation.
+ *
* @param string $name Annotation name
* @param mixed $value Annotation value
* @param int $access_id Access ID
@@ -761,8 +766,10 @@ abstract class ElggEntity extends ElggData implements
}
return elgg_get_annotations($options);
+ } else if (isset($this->temp_annotations[$name])) {
+ return array($this->temp_annotations[$name]);
} else {
- return $this->temp_annotations[$name];
+ return array();
}
}
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 98a3d7d24..bf6cf2edc 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -127,6 +127,11 @@ class ElggMenuItem {
$item->setLinkClass($options['class']);
unset($options['class']);
}
+
+ if (isset($options['item_class'])) {
+ $item->setItemClass($options['item_class']);
+ unset($options['item_class']);
+ }
foreach ($options as $key => $value) {
$item->$key = $value;
diff --git a/engine/classes/ElggPAM.php b/engine/classes/ElggPAM.php
index 37436fba3..0681a909b 100644
--- a/engine/classes/ElggPAM.php
+++ b/engine/classes/ElggPAM.php
@@ -41,9 +41,14 @@ class ElggPAM {
* @param array $credentials Credentials array dependant on policy type
* @return bool
*/
- public function authenticate($credentials) {
+ public function authenticate($credentials = array()) {
global $_PAM_HANDLERS;
+ if (!isset($_PAM_HANDLERS[$this->policy]) ||
+ !is_array($_PAM_HANDLERS[$this->policy])) {
+ return false;
+ }
+
$authenticated = false;
foreach ($_PAM_HANDLERS[$this->policy] as $k => $v) {
diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php
index 5c65a4d66..1af4cdc3a 100644
--- a/engine/classes/ElggUser.php
+++ b/engine/classes/ElggUser.php
@@ -59,9 +59,11 @@ class ElggUser extends ElggEntity
// See if this is a username
} else if (is_string($guid)) {
- $guid = get_user_by_username($guid);
- foreach ($guid->attributes as $key => $value) {
- $this->attributes[$key] = $value;
+ $user = get_user_by_username($guid);
+ if ($user) {
+ foreach ($user->attributes as $key => $value) {
+ $this->attributes[$key] = $value;
+ }
}
// Is $guid is an ElggUser? Use a copy constructor
diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php
index 05c35171b..7d6f42dc3 100644
--- a/engine/handlers/cache_handler.php
+++ b/engine/handlers/cache_handler.php
@@ -3,7 +3,7 @@
* Cache handler.
*
* External access to cached CSS and JavaScript views. The cached file URLS
- * should be of the form: cache/<type>/<view>/<viewtype>/<unique_id> where
+ * should be of the form: cache/<type>/<viewtype>/<name/of/view>.<unique_id>.<type> where
* type is either css or js, view is the name of the cached view, and
* unique_id is an identifier that is updated every time the cache is flushed.
* The simplest way to maintain a unique identifier is to use the lastcache
@@ -50,13 +50,16 @@ if (!$request || !$simplecache_enabled) {
echo 'Cache error: bad request';
exit;
}
-$request = explode('/', $request);
+// testing showed regex to be marginally faster than array / string functions over 100000 reps
+// it won't make a difference in real life and regex is easier to read.
+// <type>/<viewtype>/<name/of/view.and.dots>.<ts>.<type>
+$regex = '|([^/]+)/([^/]+)/(.+)\.([^\.]+)\.([^.]+)$|';
+preg_match($regex, $request, $matches);
-//cache/<type>/<view>/<viewtype>/
-$type = $request[0];
-$view = $request[1];
-$viewtype = $request[2];
+$type = $matches[1];
+$viewtype = $matches[2];
+$view = $matches[3];
switch ($type) {
case 'css':
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 407b99f87..47e4dd4a4 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -113,7 +113,11 @@ function action($action, $forwarder = "") {
register_error(elgg_echo('actionundefined', array($action)));
}
- forward($forwarder);
+ if (!empty($forwarder)) {
+ forward($forwarder);
+ } else {
+ forward(REFERER);
+ }
}
/**
diff --git a/engine/lib/cache.php b/engine/lib/cache.php
index d4888f9d9..8529ae7fa 100644
--- a/engine/lib/cache.php
+++ b/engine/lib/cache.php
@@ -166,7 +166,7 @@ function elgg_get_simplecache_url($type, $view) {
if (elgg_is_simplecache_enabled()) {
$viewtype = elgg_get_viewtype();
- $url = elgg_get_site_url() . "cache/$type/$view/$viewtype/$view.$lastcache.$type";
+ $url = elgg_get_site_url() . "cache/$type/$viewtype/$view.$lastcache.$type";
} else {
$url = elgg_get_site_url() . "$type/$view.$lastcache.$type";
}
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index 165546d31..bb52881cd 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -115,7 +115,7 @@ function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type =
$options['limit'] = $limit;
$options['offset'] = $offset;
- $options['order_by'] = "calculated $orderdir";
+ $options['order_by'] = "calculation $orderdir";
$options['count'] = $count;
@@ -179,7 +179,7 @@ function get_entities_from_annotation_count($entity_type = "", $entity_subtype =
$options['limit'] = $limit;
$options['offset'] = $offset;
- $options['order_by'] = "calculated $orderdir";
+ $options['order_by'] = "calculation $orderdir";
$options['count'] = $count;
@@ -241,7 +241,7 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype
$options['limit'] = $limit;
- $options['order_by'] = "calculated $orderdir";
+ $options['order_by'] = "calculation $orderdir";
return elgg_get_entities_from_annotation_calculation($options);
}
@@ -1152,10 +1152,22 @@ function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type
$offset = (int)get_input('offset');
$limit = (int)$limit;
- $options = array('metadata_name' => $meta_name, 'metadata_value' => $meta_value,
- 'types' => $entity_type, 'subtypes' => $entity_subtype, 'owner_guid' => $owner_guid,
- 'limit' => $limit, 'offset' => $offset, 'count' => TRUE,
- 'metadata_case_sensitive' => $case_sensitive);
+ $options = array(
+ 'metadata_name' => $meta_name,
+ 'metadata_value' => $meta_value,
+ 'types' => $entity_type,
+ 'subtypes' => $entity_subtype,
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'count' => TRUE,
+ 'metadata_case_sensitive' => $case_sensitive
+ );
+
+ // previous function allowed falsy $owner_guid for anything
+ if ($owner_guid) {
+ $options['owner_guid'] = $owner_guid;
+ }
+
$count = elgg_get_entities_from_metadata($options);
$options['count'] = FALSE;
@@ -3492,7 +3504,7 @@ $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $or
$options['limit'] = $limit;
- $options['order_by'] = "calculated $orderdir";
+ $options['order_by'] = "calculation $orderdir";
return elgg_get_entities_from_annotation_calculation($options);
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 1aef48ef4..6c94133df 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -400,7 +400,7 @@ function elgg_get_loaded_external_files($type, $location) {
if (isset($CONFIG->externals) && isset($CONFIG->externals[$type])) {
$items = array_values($CONFIG->externals[$type]);
- $callback = "return \$v->loaded == true && \$v->location == $location;";
+ $callback = "return \$v->loaded == true && \$v->location == '$location';";
$items = array_filter($items, create_function('$v', $callback));
if ($items) {
usort($items, create_function('$a,$b','return $a->priority >= $b->priority;'));
@@ -1685,21 +1685,7 @@ function _elgg_shutdown_hook() {
* @elgg_pagehandler js
*/
function elgg_js_page_handler($page) {
- if (is_array($page) && sizeof($page)) {
- $js = implode('/', $page);
- $js = substr($js, 0, strpos($js, '.'));
- $return = elgg_view('js/' . $js);
-
- header('Content-type: text/javascript');
-
- // @todo should js be cached when simple cache turned off
- //header('Expires: ' . date('r', time() + 864000));
- //header("Pragma: public");
- //header("Cache-Control: public");
- //header("Content-Length: " . strlen($return));
-
- echo $return;
- }
+ return elgg_cacheable_view_page_handler($page, 'js');
}
/**
@@ -1749,18 +1735,60 @@ function elgg_css_page_handler($page) {
// default css
$page[0] = 'elgg';
}
+
+ return elgg_cacheable_view_page_handler($page, 'css');
+}
+
+/**
+ * Serves a JS or CSS view with headers for caching.
+ *
+ * /<css||js>/name/of/view.<last_cache>.<css||js>
+ *
+ * @param array $page The page array
+ * @param string $type The type: js or css
+ *
+ * @return mixed
+ */
+function elgg_cacheable_view_page_handler($page, $type) {
+
+ switch ($type) {
+ case 'js':
+ $content_type = 'text/javascript';
+ break;
+
+ case 'css':
+ $content_type = 'text/css';
+ break;
+
+ default:
+ return false;
+ break;
+ }
- $css = substr($page[0], 0, strpos($page[0], '.'));
- $return = elgg_view("css/$css");
+ if ($page) {
+ // the view file names can have multiple dots
+ // eg: views/default/js/calendars/jquery.fullcalendar.min.php
+ // translates to the url /js/calendars/jquery.fullcalendar.min.<ts>.js
+ // and the view js/calendars/jquery.fullcalendar.min
+ // we ignore the last two dots for the ts and the ext.
+ $page = implode('/', $page);
+ $regex = '|(.+)\.([^\.]+)\.([^.]+)$|';
+ preg_match($regex, $page, $matches);
+ $view = $matches[1];
+ $return = elgg_view("$type/$view");
- header("Content-type: text/css", true);
+ header("Content-type: $content_type");
- // @todo should css be cached when simple cache is turned off
- //header('Expires: ' . date('r', time() + 86400000), true);
- //header("Pragma: public", true);
- //header("Cache-Control: public", true);
+ // @todo should js be cached when simple cache turned off
+ //header('Expires: ' . date('r', time() + 864000));
+ //header("Pragma: public");
+ //header("Cache-Control: public");
+ //header("Content-Length: " . strlen($return));
- echo $return;
+ echo $return;
+ }
+
+ return true;
}
/**
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 742630cc7..685c68a5b 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -740,7 +740,7 @@ function elgg_entity_exists($guid) {
* type_subtype_pairs => NULL|ARR (array('type' => 'subtype'))
* (type = '$type' AND subtype = '$subtype') pairs
*
- * entity_guids => NULL|ARR Array of entity guids
+ * guids => NULL|ARR Array of entity guids
*
* owner_guids => NULL|ARR Array of owner guids
*
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 6db4e6d7c..604c7f765 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -75,7 +75,7 @@ function get_metastring_id($string, $case_sensitive = TRUE) {
$ids[] = $metaString->id;
}
return $ids;
- } else if ($metaStrings) {
+ } else if (isset($metaStrings[0])) {
$row = $metaStrings[0];
}
}
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 8c2a3d50d..3f35a1576 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -170,7 +170,7 @@ function elgg_format_attributes(array $attrs) {
}
// ignore $vars['entity'] => ElggEntity stuff
- if (is_not_null($val) && (is_array($val) || !is_object($var))) {
+ if (is_not_null($val) && (is_array($val) || !is_object($val))) {
// allow $vars['class'] => array('one', 'two');
// @todo what about $vars['style']? Needs to be semi-colon separated...
diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php
index 5d45cc73d..ae42956a9 100644
--- a/engine/lib/sessions.php
+++ b/engine/lib/sessions.php
@@ -155,9 +155,9 @@ function elgg_authenticate($username, $password) {
* @return bool
* @throws LoginException
*/
-function pam_auth_userpass($credentials = NULL) {
+function pam_auth_userpass(array $credentials = array()) {
- if (!is_array($credentials) || !isset($credentials['username']) || !isset($credentials['password'])) {
+ if (!isset($credentials['username']) || !isset($credentials['password'])) {
return false;
}
diff --git a/engine/lib/upgrade.php b/engine/lib/upgrade.php
index 755c100dd..85810956b 100644
--- a/engine/lib/upgrade.php
+++ b/engine/lib/upgrade.php
@@ -147,6 +147,8 @@ function elgg_get_upgrade_files($upgrade_path = null) {
$upgrade_files[] = $upgrade_file;
}
+ sort($upgrade_files);
+
return $upgrade_files;
}
diff --git a/engine/lib/upgrades/2011010101.php b/engine/lib/upgrades/2011010101.php
index be1adac1a..9dbaff1e4 100644
--- a/engine/lib/upgrades/2011010101.php
+++ b/engine/lib/upgrades/2011010101.php
@@ -73,3 +73,21 @@ remove_metadata($site->guid, 'pluginorder');
remove_metadata($site->guid, 'enabled_plugins');
elgg_set_ignore_access($old_id);
+
+/**
+ * @hack
+ *
+ * We stop the upgrade at this point because plugins weren't given the chance to
+ * load due to the new plugin code introduced with Elgg 1.8. Instead, we manually
+ * set the version and start the upgrade process again.
+ *
+ * The variables from upgrade_code() are available because this script was included
+ */
+if ($upgrade_version > $version) {
+ datalist_set('version', $upgrade_version);
+}
+
+$processed_upgrades = array_unique($processed_upgrades);
+datalist_set('processed_upgrades', serialize($processed_upgrades));
+
+forward('upgrade.php');
diff --git a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php b/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php
deleted file mode 100644
index 6a5f2fa02..000000000
--- a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * Elgg 1.8-svn upgrade 2011032300
- * update_default_widgets
- *
- * Pre-1.8, default widgets were stored as metadata on a defaultwidgets object.
- * Now they are stored as widget objects owned by the site.
- */
-
-$object = elgg_get_entities(array(
- 'type' => 'object',
- 'subtype' => 'moddefaultwidgets',
- 'limit' => 1,
-));
-
-if (!$object) {
- // nothing to upgrade
- return true;
-}
-
-$object = $object[0];
-
-$site = elgg_get_site_entity();
-
-$ia = elgg_set_ignore_access(true);
-foreach (array('profile', 'dashboard') as $context) {
- if (isset($object->$context)) {
- elgg_push_context($context);
- elgg_push_context('default_widgets');
- elgg_push_context('widgets');
-
- // deserialize the widget information
- list($left, $middle, $right) = split('%%', $object->$context);
- $left_widgets = split('::', $left);
- $middle_widgets = split('::', $middle);
- $right_widgets = split('::', $right);
-
- // 1st column is right column in default theme
- $widgets = array(
- 1 => array_reverse($right_widgets),
- 2 => array_reverse($middle_widgets),
- 3 => array_reverse($left_widgets),
- );
-
- foreach ($widgets as $column => $column_widgets) {
- foreach ($column_widgets as $handler) {
- $guid = elgg_create_widget($site->getGUID(), $handler, $context);
- if ($guid) {
- $widget = get_entity($guid);
- $widget->move($column, 0);
- }
- }
- }
-
- elgg_pop_context();
- elgg_pop_context();
- elgg_pop_context();
- }
-}
-elgg_set_ignore_access($ia);
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index b20f92f74..cc3cf20e4 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -272,6 +272,7 @@ function elgg_widgets_init() {
elgg_register_action('widgets/add');
elgg_register_action('widgets/move');
elgg_register_action('widgets/delete');
+ elgg_register_action('widgets/upgrade', '', 'admin');
run_function_once("elgg_widget_run_once");
}
diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php
index 1633cbe19..aef7a991e 100644
--- a/engine/tests/api/entity_getter_functions.php
+++ b/engine/tests/api/entity_getter_functions.php
@@ -1341,7 +1341,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
$e->save();
$guids[] = $e->getGUID();
@@ -1406,11 +1406,13 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
// make some bad ones
$invalid_md_name = 'test_metadata_name_' . rand();
+ $invalid_md_name2 = 'test_metadata_name_' . rand();
+ $invalid_md_name3 = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
- $e->$md_name2 = $invalid_md_value;
- $e->$md_name3 = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
+ $e->$invalid_md_name2 = $md_value2;
+ $e->$invalid_md_name3 = $md_value3;
$e->save();
$guids[] = $e->getGUID();
@@ -1483,10 +1485,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
// make some bad ones
$invalid_md_name = 'test_metadata_name_' . rand();
+ $invalid_md_name2 = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
- $e->$md_name2 = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
+ $e->$invalid_md_name2 = $md_value2;
$e->save();
$guids[] = $e->getGUID();
@@ -1572,11 +1575,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
- $e->$md_name2 = $invalid_md_value;
- $e->$md_name3 = $invalid_md_value;
- $e->$md_name4 = $invalid_md_value;
- $e->$md_name5 = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
+ $e->$md_name2 = $md_value2;
+ $e->$md_name3 = $md_value3;
+ $e->$md_name4 = $md_value4;
+ $e->$md_name5 = $md_value5;
$e->save();
$guids[] = $e->getGUID();
@@ -1649,7 +1652,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
$e->save();
$guids[] = $e->getGUID();
@@ -1694,7 +1697,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
$e->save();
$guids[] = $e->getGUID();
@@ -1758,7 +1761,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
$e->save();
$guids[] = $e->getGUID();
@@ -1836,7 +1839,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$invalid_md_name = 'test_metadata_name_' . rand();
$e = new ElggObject();
$e->subtype = $subtype;
- $e->$md_name = $invalid_md_value;
+ $e->$invalid_md_name = $md_value;
$e->save();
$guids[] = $e->getGUID();
@@ -1888,33 +1891,32 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$md_name = 'test_metadata_name_' . rand();
- $md_value = 2;
$guids = array();
$valid_guids = array();
// our targets
$valid = new ElggObject();
$valid->subtype = $subtype;
- $valid->$md_name = $md_value;
+ $valid->$md_name = 1;
$valid->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid->getGUID();
$valid2 = new ElggObject();
$valid2->subtype = $subtype;
- $valid2->$md_name = 3;
+ $valid2->$md_name = 2;
$valid2->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid2->getGUID();
$valid3 = new ElggObject();
$valid3->subtype = $subtype;
- $valid3->$md_name = 1;
+ $valid3->$md_name = 3;
$valid3->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid3->getGUID();
- $md_valid_values = array($md_value, $md_value2);
+ $md_valid_values = array(1, 2, 3);
$options = array(
'type' => 'object',
@@ -1947,33 +1949,32 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$md_name = 'test_metadata_name_' . rand();
- $md_value = 'b';
$guids = array();
$valid_guids = array();
// our targets
$valid = new ElggObject();
$valid->subtype = $subtype;
- $valid->$md_name = $md_value;
+ $valid->$md_name = 'a';
$valid->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid->getGUID();
$valid2 = new ElggObject();
$valid2->subtype = $subtype;
- $valid2->$md_name = 'c';
+ $valid2->$md_name = 'b';
$valid2->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid2->getGUID();
$valid3 = new ElggObject();
$valid3->subtype = $subtype;
- $valid3->$md_name = 'a';
+ $valid3->$md_name = 'c';
$valid3->save();
$guids[] = $valid->getGUID();
$valid_guids[] = $valid3->getGUID();
- $md_valid_values = array($md_value, $md_value2);
+ $md_valid_values = array('a', 'b', 'c');
$options = array(
'type' => 'object',
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index 1362b3c9d..461627547 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -109,7 +109,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical('http://test1.com', $CONFIG->externals['js']['key']->url);
// send a bad url
- $result = elgg_register_js();
+ $result = @elgg_register_js('bad');
$this->assertFalse($result);
}
@@ -140,7 +140,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$result = elgg_unregister_js('id1');
$this->assertTrue($result);
- $this->assertNULL($CONFIG->externals['js']['head']['id1']);
+ @$this->assertNULL($CONFIG->externals['js']['head']['id1']);
$result = elgg_unregister_js('id1');
$this->assertFalse($result);
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php
index ca3abb274..c04bc60ff 100644
--- a/engine/tests/objects/entities.php
+++ b/engine/tests/objects/entities.php
@@ -107,7 +107,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
// set and check temp annotation
$this->assertTrue($this->entity->annotate('non_existent', 'testing'));
- $this->assertIdentical($this->entity->getAnnotations('non_existent'), 'testing');
+ $this->assertIdentical($this->entity->getAnnotations('non_existent'), array('testing'));
$this->assertTrue(array_key_exists('non_existent', $this->entity->expose_annotations()));
// save entity and check for annotation
diff --git a/engine/tests/services/api.php b/engine/tests/services/api.php
index 39951da1c..3d07c0bbb 100644
--- a/engine/tests/services/api.php
+++ b/engine/tests/services/api.php
@@ -19,7 +19,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest {
// expose_function
public function testExposeFunctionNoMethod() {
try {
- expose_function();
+ @expose_function();
$this->assertTrue(FALSE);
} catch (Exception $e) {
$this->assertIsA($e, 'InvalidParameterException');
@@ -29,7 +29,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest {
public function testExposeFunctionNoFunction() {
try {
- expose_function('test');
+ @expose_function('test');
$this->assertTrue(FALSE);
} catch (Exception $e) {
$this->assertIsA($e, 'InvalidParameterException');
@@ -39,7 +39,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest {
public function testExposeFunctionBadParameters() {
try {
- expose_function('test', 'test', 'BAD');
+ @expose_function('test', 'test', 'BAD');
$this->assertTrue(FALSE);
} catch (Exception $e) {
$this->assertIsA($e, 'InvalidParameterException');
@@ -59,7 +59,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest {
public function testExposeFunctionBadHttpMethod() {
try {
- expose_function('test', 'test', null, '', 'BAD');
+ @expose_function('test', 'test', null, '', 'BAD');
$this->assertTrue(FALSE);
} catch (Exception $e) {
$this->assertIsA($e, 'InvalidParameterException');