diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/cache.php | 47 | ||||
-rw-r--r-- | engine/lib/configuration.php | 2 | ||||
-rw-r--r-- | engine/lib/entities.php | 58 | ||||
-rw-r--r-- | engine/lib/navigation.php | 6 | ||||
-rw-r--r-- | engine/lib/plugins.php | 2 | ||||
-rw-r--r-- | engine/lib/users.php | 4 | ||||
-rw-r--r-- | engine/lib/views.php | 2 |
7 files changed, 47 insertions, 74 deletions
diff --git a/engine/lib/cache.php b/engine/lib/cache.php index b329c58ec..c117b9ec9 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -369,7 +369,7 @@ function elgg_invalidate_simplecache() { $return = true; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { - $return = $return && unlink($CONFIG->dataroot . 'views_simplecache/' . $file); + $return &= unlink($CONFIG->dataroot . 'views_simplecache/' . $file); } } closedir($handle); @@ -382,8 +382,8 @@ function elgg_invalidate_simplecache() { } foreach ($viewtypes as $viewtype) { - $return = $return && datalist_set("simplecache_lastupdate_$viewtype", 0); - $return = $return && datalist_set("simplecache_lastcached_$viewtype", 0); + $return &= datalist_set("simplecache_lastupdate_$viewtype", 0); + $return &= datalist_set("simplecache_lastcached_$viewtype", 0); } return $return; @@ -395,26 +395,23 @@ function elgg_invalidate_simplecache() { */ function _elgg_load_cache() { global $CONFIG; + + $CONFIG->system_cache_loaded = false; + + $CONFIG->views = new stdClass(); + $data = elgg_load_system_cache('view_locations'); + if (!is_string($data)) { + return; + } + $CONFIG->views->locations = unserialize($data); - $result = true; - $cache_types = array( - 'view_paths' => 'views', - 'view_types' => 'view_types', - ); - $data = array(); - foreach ($cache_types as $type => $var_name) { - $data[$var_name] = elgg_load_system_cache($type); - $result = $result && is_string($data[$var_name]); + $data = elgg_load_system_cache('view_types'); + if (!is_string($data)) { + return; } + $CONFIG->view_types = unserialize($data); - if ($result) { - $CONFIG->system_cache_loaded = true; - foreach ($data as $name => $value) { - $CONFIG->$name = unserialize($value); - } - } else { - $CONFIG->system_cache_loaded = false; - } + $CONFIG->system_cache_loaded = true; } /** @@ -440,14 +437,8 @@ function _elgg_cache_init() { // cache system data if enabled and not loaded if ($CONFIG->system_cache_enabled && !$CONFIG->system_cache_loaded) { - $cache_types = array( - 'view_paths' => 'views', - 'view_types' => 'view_types', - ); - $data = array(); - foreach ($cache_types as $type => $var_name) { - elgg_save_system_cache($type, serialize($CONFIG->$var_name)); - } + elgg_save_system_cache('view_locations', serialize($CONFIG->views->locations)); + elgg_save_system_cache('view_types', serialize($CONFIG->view_types)); } if ($CONFIG->system_cache_enabled && !$CONFIG->i18n_loaded_from_cache) { diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index 998cd1943..9bf1529d6 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -303,7 +303,7 @@ function datalist_set($name, $value) { . " set name = '{$sanitised_name}', value = '{$sanitised_value}'" . " ON DUPLICATE KEY UPDATE value='{$sanitised_value}'"); - if ($success) { + if ($success !== FALSE) { $DATALIST_CACHE[$name] = $value; return true; } else { diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 2dc0eb8ae..4875b2c2f 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -738,6 +738,7 @@ function elgg_entity_exists($guid) { * Joined with subtypes by AND. See below) * * subtypes => NULL|STR entity subtype (SQL: subtype IN ('subtype1', 'subtype2)) + * Use ELGG_ENTITIES_NO_VALUE for no subtype. * * type_subtype_pairs => NULL|ARR (array('type' => 'subtype')) * (type = '$type' AND subtype = '$subtype') pairs @@ -1520,18 +1521,23 @@ function delete_entity($guid, $recursive = true) { $entity_disable_override = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); - $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities - WHERE container_guid=$guid - or owner_guid=$guid - or site_guid=$guid", 'entity_row_to_elggstar'); - if ($sub_entities) { - foreach ($sub_entities as $e) { - // check for equality so that an entity that is its own - // owner or container does not cause infinite loop - if ($e->guid != $guid) { - $e->delete(true); - } - } + + // @todo there was logic in the original code that ignored + // entities with owner or container guids of themselves. + // this should probably be prevented in ElggEntity instead of checked for here + $options = array( + 'wheres' => array( + "((container_guid = $guid OR owner_guid = $guid OR site_guid = $guid)" + . " AND guid != $guid)" + ), + 'limit' => 0 + ); + + $batch = new ElggBatch('elgg_get_entities', $options); + $batch->setIncrementOffset(false); + + foreach ($batch as $e) { + $e->delete(true); } access_show_hidden_entities($entity_disable_override); @@ -2173,29 +2179,6 @@ function elgg_list_registered_entities(array $options = array()) { } /** - * Check the recursive delete permissions token. - * - * If an entity is deleted recursively, a permissions override is required to allow - * contained or owned entities to be removed. - * - * @return bool - * @elgg_plugin_hook_handler permissions_check all - * @elgg_plugin_hook_handler permissions_check:metadata all - * @access private - */ -function recursive_delete_permissions_check() { - static $__RECURSIVE_DELETE_TOKEN; - - if ((elgg_is_logged_in()) && ($__RECURSIVE_DELETE_TOKEN) - && (strcmp($__RECURSIVE_DELETE_TOKEN, md5(elgg_get_logged_in_user_guid())))) { - return true; - } - - // consult next function - return NULL; -} - -/** * Checks if $entity is an ElggEntity and optionally for type and subtype. * * @tip Use this function in actions and views to check that you are dealing @@ -2309,11 +2292,6 @@ function entities_init() { elgg_register_plugin_hook_handler('unit_test', 'system', 'entities_test'); - // Allow a permission override for recursive entity deletion - // @todo Can this be done better? - elgg_register_plugin_hook_handler('permissions_check', 'all', 'recursive_delete_permissions_check'); - elgg_register_plugin_hook_handler('permissions_check:metadata', 'all', 'recursive_delete_permissions_check'); - elgg_register_plugin_hook_handler('gc', 'system', 'entities_gc'); } diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index dcbd7b397..a7984ce5a 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -78,7 +78,11 @@ * link_class => STR A class or classes for the <a> tag * item_class => STR A class or classes for the <li> tag * - * Custom options can be added as key value pairs. + * Additional options that the view output/url takes can be + * passed in the array. If the 'confirm' key is passed, the + * menu link uses the 'output/confirmlink' view. Custom + * options can be added by using the 'data' key with the + * value being an associative array. * * @return bool * @since 1.8.0 diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 07b21d276..70bfcb28b 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -62,7 +62,7 @@ function elgg_get_plugin_ids_in_dir($dir = null) { $dir = elgg_get_plugins_path(); } - $plugin_idss = array(); + $plugin_ids = array(); $handle = opendir($dir); if ($handle) { diff --git a/engine/lib/users.php b/engine/lib/users.php index 14cdd55d4..f1d42e25e 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -612,11 +612,11 @@ function get_user_by_code($code) { } /** - * Get an array of users from their email addresses + * Get an array of users from an email address * * @param string $email Email address. * - * @return Array of users + * @return array */ function get_user_by_email($email) { global $CONFIG; diff --git a/engine/lib/views.php b/engine/lib/views.php index 4883ee739..052387191 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -560,7 +560,7 @@ function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $vie * * @return void * @since 1.7.0 - * @link http://docs.elgg.org/Views/Ejxtend + * @link http://docs.elgg.org/Views/Extend * @example views/extend.php */ function elgg_extend_view($view, $view_extension, $priority = 501, $viewtype = '') { |