]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Small changes to remove static analysis noise and simplify flow
authorSteve Clay <steve@mrclay.org>
Tue, 5 Feb 2013 01:51:07 +0000 (20:51 -0500)
committerCash Costello <cash.costello@gmail.com>
Sat, 9 Feb 2013 12:53:45 +0000 (07:53 -0500)
27 files changed:
engine/classes/ElggAutoP.php
engine/classes/ElggData.php
engine/classes/ElggDiskFilestore.php
engine/classes/ElggFile.php
engine/classes/ElggGroup.php
engine/classes/ElggMenuBuilder.php
engine/classes/ElggRelationship.php
engine/lib/admin.php
engine/lib/annotations.php
engine/lib/cache.php
engine/lib/configuration.php
engine/lib/cron.php
engine/lib/elgglib.php
engine/lib/export.php
engine/lib/location.php
engine/lib/plugins.php
engine/lib/relationships.php
engine/lib/river.php
engine/lib/sessions.php
engine/lib/sites.php
engine/lib/statistics.php
engine/lib/system_log.php
engine/lib/tags.php
engine/lib/upgrades/create_upgrade.php
engine/lib/user_settings.php
engine/lib/users.php
engine/lib/views.php

index 40600aa1339e21ddf0ea4d00c041d1cf94d9770d..f3c7cc972cbd42696bc00824165239d65d164a5c 100644 (file)
@@ -159,8 +159,9 @@ class ElggAutoP {
                        /* @var DOMElement $el */
                        $autops = $this->_xpath->query('./autop', $el);
                        if ($autops->length === 1) {
-                               // strip w/ preg_replace later (faster than moving nodes out)
-                               $autops->item(0)->setAttribute("r", "1");
+                               $firstAutop = $autops->item(0);
+                               /* @var DOMElement $firstAutop */
+                               $firstAutop->setAttribute("r", "1");
                        }
                }
 
@@ -220,12 +221,12 @@ class ElggAutoP {
 
                                $isElement = ($node->nodeType === XML_ELEMENT_NODE);
                                if ($isElement) {
-                                       $elName = $node->nodeName;
+                                       $isBlock = in_array($node->nodeName, $this->_blocks);
+                               } else {
+                                       $isBlock = false;
                                }
-                               $isBlock = ($isElement && in_array($elName, $this->_blocks));
 
                                if ($alterInline) {
-                                       $isInline = $isElement && ! $isBlock;
                                        $isText = ($node->nodeType === XML_TEXT_NODE);
                                        $isLastInline = (! $node->nextSibling
                                                                   || ($node->nextSibling->nodeType === XML_ELEMENT_NODE
index a0df3c924933e11c360d303e889e198968ed47c0..426248ca3ad99bee951cb5fdd9e69edc92251078 100644 (file)
@@ -273,6 +273,7 @@ abstract class ElggData implements
                if (array_key_exists($key, $this->attributes)) {
                        return $this->attributes[$key];
                }
+               return null;
        }
 
        /**
index 5483eed819e64f5812766530aa7d02f4f1862eef..2d86e7c2dcc5d4eec254831e922d97c7a69e3866 100644 (file)
@@ -316,8 +316,6 @@ class ElggDiskFilestore extends ElggFilestore {
                } else {
                        return str_split($string);
                }
-
-               return false;
        }
 
        /**
index 86406d10836f94e3dec3bb0cdcb4408e650761be..3f652ff19b10e1ca0c483a6f4e95daa50ec080f9 100644 (file)
@@ -127,9 +127,11 @@ class ElggFile extends ElggObject {
         * @param mixed $default A default. Useful to pass what the browser thinks it is.
         * @since 1.7.12
         *
+        * @note If $file is provided, this may be called statically
+        *
         * @return mixed Detected type on success, false on failure.
         */
-       static function detectMimeType($file = null, $default = null) {
+       public function detectMimeType($file = null, $default = null) {
                if (!$file) {
                        if (isset($this) && $this->filename) {
                                $file = $this->filename;
index d17fa4f1a513c66cd061ebbf38f3c32a91026dda..24bdee79ea0035aad32f402ed82b000dd9bf05ad 100644 (file)
@@ -284,7 +284,7 @@ class ElggGroup extends ElggEntity
         *
         * @return bool
         */
-       public function isMember($user = 0) {
+       public function isMember($user = null) {
                if (!($user instanceof ElggUser)) {
                        $user = elgg_get_logged_in_user_entity();
                }
index 2fd5ad9c487bb8a3f19a36fb60193266c02c52f2..028eef15f583d063278c11100be40f238875b192 100644 (file)
@@ -122,6 +122,7 @@ class ElggMenuBuilder {
                        // attach children to parents
                        $iteration = 0;
                        $current_gen = $parents;
+                       $next_gen = null;
                        while (count($children) && $iteration < 5) {
                                foreach ($children as $index => $menu_item) {
                                        $parent_name = $menu_item->getParentName();
index 377a4109371fa0c69530327585193dc230beb438..d2e88882aa1337499c18b280e6a942b9964c61df 100644 (file)
@@ -180,6 +180,8 @@ class ElggRelationship extends ElggData implements
                                return true;
                        }
                }
+
+               return false;
        }
 
        // SYSTEM LOG INTERFACE ////////////////////////////////////////////////////////////
index 3677a3b69cfeb7d91fb15165ed61cd21a23c95fe..ec19a54763851d7514596a8348da99d003162158 100644 (file)
@@ -346,7 +346,7 @@ function elgg_admin_add_plugin_settings_menu() {
        $active_plugins = elgg_get_plugins('active');
        if (!$active_plugins) {
                // nothing added because no items
-               return FALSE;
+               return;
        }
 
        foreach ($active_plugins as $plugin) {
index 9ba0491b2efcb48f4f286c13865eb57ace149bbf..3d94a1d55f1586ae5b181dee2d62aa703d9c1f9b 100644 (file)
@@ -542,6 +542,7 @@ function elgg_comment_url_handler(ElggAnnotation $comment) {
        if ($entity) {
                return $entity->getURL() . '#item-annotation-' . $comment->id;
        }
+       return "";
 }
 
 /**
index 5c917bb18c627778bb93ac9b92580f704a6652b5..74644019c55d1ecf64e48099a090678ccf5a44b6 100644 (file)
@@ -125,7 +125,7 @@ function elgg_get_filepath_cache() {
  * @access private
  */
 function elgg_filepath_cache_reset() {
-       return elgg_reset_system_cache();
+       elgg_reset_system_cache();
 }
 /**
  * @access private
@@ -143,13 +143,13 @@ function elgg_filepath_cache_load($type) {
  * @access private
  */
 function elgg_enable_filepath_cache() {
-       return elgg_enable_system_cache();
+       elgg_enable_system_cache();
 }
 /**
  * @access private
  */
 function elgg_disable_filepath_cache() {
-       return elgg_disable_system_cache();
+       elgg_disable_system_cache();
 }
 
 /* Simplecache */
index 851430127f12017f5310b84aef92d4683d950992..a0f297f0c628fba01d037c55ab24cc7cc9253190 100644 (file)
@@ -182,7 +182,7 @@ function verify_installation() {
        global $CONFIG;
 
        if (isset($CONFIG->installed)) {
-               return $CONFIG->installed;
+               return;
        }
 
        try {
index f2939bdd66391e999514ac8a6d7ab579f672f8ff..dd83a98498cec3c532cd3629211e32087abcf81d 100644 (file)
@@ -52,7 +52,6 @@ function cron_page_handler($page) {
        $params['time'] = time();
 
        // Data to return to
-       $std_out = "";
        $old_stdout = "";
        ob_start();
 
index 746fd8aa99373e5bf819380a52585f28dbae0c3e..6a2ebf97bd5b2d44f66253e2e242d0840031a7de 100644 (file)
@@ -1903,6 +1903,7 @@ function elgg_cacheable_view_page_handler($page, $type) {
                echo $return;
                return true;
        }
+       return false;
 }
 
 /**
index 31afc1b741927a48807b0cd82807fd9e26ada4be..1996bc88533ec15315638a01a7a8c124792e0c90 100644 (file)
@@ -117,18 +117,19 @@ function _process_element(ODD $odd) {
        global $IMPORTED_DATA, $IMPORTED_OBJECT_COUNTER;
 
        // See if anyone handles this element, return true if it is.
+       $to_be_serialised = null;
        if ($odd) {
                $handled = elgg_trigger_plugin_hook("import", "all", array("element" => $odd), $to_be_serialised);
-       }
 
-       // If not, then see if any of its sub elements are handled
-       if ($handled) {
-               // Increment validation counter
-               $IMPORTED_OBJECT_COUNTER ++;
-               // Return the constructed object
-               $IMPORTED_DATA[] = $handled;
+               // If not, then see if any of its sub elements are handled
+               if ($handled) {
+                       // Increment validation counter
+                       $IMPORTED_OBJECT_COUNTER ++;
+                       // Return the constructed object
+                       $IMPORTED_DATA[] = $handled;
 
-               return true;
+                       return true;
+               }
        }
 
        return false;
index 5b889509ba29ce26cd34edadaf6f5913bf046332..b319bb3bb613628c086bf7a79aa9c2b5d1342128 100644 (file)
@@ -101,7 +101,7 @@ function elgg_get_entities_from_location(array $options = array()) {
        $long_min = $long - $long_distance;
        $long_max = $long + $long_distance;
 
-       $where = array();
+       $wheres = array();
        $wheres[] = "lat_name.string='geo:lat'";
        $wheres[] = "lat_value.string >= $lat_min";
        $wheres[] = "lat_value.string <= $lat_max";
index 3a42cb9b8ce695f45da804b28b877136da4b0e75..973ca40269982f681149adfb4084492255230fc1 100644 (file)
@@ -261,6 +261,8 @@ function elgg_get_max_plugin_priority() {
        $data = get_data($q);
        if ($data) {
                $max = $data[0]->max;
+       } else {
+               $max = 1;
        }
 
        // can't have a priority of 0.
@@ -442,6 +444,7 @@ function elgg_set_plugin_priorities(array $order) {
        // though we do start with 1
        $order = array_values($order);
 
+       $missing_plugins = array();
        foreach ($plugins as $plugin) {
                $plugin_id = $plugin->getID();
 
@@ -640,19 +643,18 @@ function elgg_get_plugins_provides($type = null, $name = null) {
  * @access private
  */
 function elgg_check_plugins_provides($type, $name, $version = null, $comparison = 'ge') {
-       if (!$provided = elgg_get_plugins_provides($type, $name)) {
+       $provided = elgg_get_plugins_provides($type, $name);
+       if (!$provided) {
                return array(
                        'status' => false,
                        'version' => ''
                );
        }
 
-       if ($provided) {
-               if ($version) {
-                       $status = version_compare($provided['version'], $version, $comparison);
-               } else {
-                       $status = true;
-               }
+       if ($version) {
+               $status = version_compare($provided['version'], $version, $comparison);
+       } else {
+               $status = true;
        }
 
        return array(
index 74954b4ff67c3b397757e0f6cc536a1ae45b4601..6f18bda9346cfc0d0ffb2538be916fe7d76cf171 100644 (file)
@@ -571,9 +571,8 @@ function import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $par
        if ($element instanceof ODDRelationship) {
                $tmp = new ElggRelationship();
                $tmp->import($element);
-
-               return $tmp;
        }
+       return $tmp;
 }
 
 /**
index 148fee051e5d6b615c8979629759069031d10e10..6274887b5eaa662f9cd971a6f70c0fd1f1075e45 100644 (file)
@@ -500,6 +500,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
                return '';
        }
 
+       $wheres = array();
        $types_wheres = array();
        $subtypes_wheres = array();
 
index 72ca0a1c220f8368a66ed8b24c690ce7587105d0..eb451f05a3329367d71594e81e146c93e476b00a 100644 (file)
@@ -616,7 +616,7 @@ function _elgg_session_destroy($id) {
                global $sess_save_path;
 
                $sess_file = "$sess_save_path/sess_$id";
-               return(@unlink($sess_file));
+               return (@unlink($sess_file));
        }
 
        return false;
index fe9af8c7ab6f1c5dae5c064e2a13766c80c0d37d..8ee3213d312cbf784c33cd6f139fed4122555413 100644 (file)
@@ -26,7 +26,7 @@ function elgg_get_site_entity($site_guid = 0) {
                $site = get_entity($site_guid);
        }
        
-       if($site instanceof ElggSite){
+       if ($site instanceof ElggSite) {
                $result = $site;
        }
 
index 5ee640549f620c5f62f63521986f85f0c0f8d763..0c9a3c945b16fe4f9458e27e81d92b0f0bd61086 100644 (file)
@@ -101,9 +101,10 @@ function get_online_users() {
        if ($objects) {
                return elgg_view_entity_list($objects, array(
                        'count' => $count,
-                       'limit' => 10
+                       'limit' => 10,
                ));
        }
+       return '';
 }
 
 /**
index 8149d3fac5f75bab3d3447f561f739363c29c139..38bc4ba961dab98ed3602cf503e9c7bdfb75c391 100644 (file)
@@ -25,9 +25,9 @@
  * @param string    $ip_address The IP address.
  * @return mixed
  */
-function get_system_log($by_user = "", $event = "", $class = "", $type = "", $subtype = "",
-$limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0,
-$ip_address = false) {
+function get_system_log($by_user = "", $event = "", $class = "", $type = "", $subtype = "", $limit = 10,
+                                               $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0,
+                                               $ip_address = "") {
 
        global $CONFIG;
 
index a25bd7d33658bd05e6b2561cf48fbf282bbc8cc4..586a9b9e419eaff00d2724b393f9b259c9a509d4 100644 (file)
@@ -172,6 +172,7 @@ function elgg_get_tags(array $options = array()) {
        // catch for tags that were spaces
        $wheres[] = "msv.string != ''";
 
+       $sanitised_tags = array();
        foreach ($options['tag_names'] as $tag) {
                $sanitised_tags[] = '"' . sanitise_string($tag) . '"';
        }
index 3652e18a2d6fd35b874e7150254ea433deae52ad..f0fa9b5948b3b32071f0521802d29a6b38597284 100644 (file)
@@ -93,7 +93,7 @@ if (!$h) {
        die("Could not open file $upgrade_file");
 }
 
-if (!fputs($h, $upgrade_code)) {
+if (!fwrite($h, $upgrade_code)) {
        die("Could not write to $upgrade_file");
 } else {
        elgg_set_version_dot_php_version($upgrade_version);
@@ -130,6 +130,7 @@ function elgg_set_version_dot_php_version($version) {
 
        fputs($h, $out);
        fclose($h);
+       return true;
 }
 
 /**
index e4069fb535b2442625ae4b8f3df9fd80516a97f9..cca5359a42874fc9ace3a598d68edd08698e9cdb 100644 (file)
@@ -332,6 +332,7 @@ function usersettings_page_handler($page) {
                require $path;
                return true;
        }
+       return false;
 }
 
 /**
index 22ce08e101cc17bee30ab319f873608c73605e63..7a62452615ec5b0847c596972c229168510bf77c 100644 (file)
@@ -560,7 +560,7 @@ function get_user_by_username($username) {
 
        // Caching
        if ((isset($USERNAME_TO_GUID_MAP_CACHE[$username]))
-       && (retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]))) {
+                       && (retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]))) {
                return retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]);
        }
 
@@ -687,15 +687,14 @@ function send_new_password_request($user_guid) {
                $code = generate_random_cleartext_password();
                $user->setPrivateSetting('passwd_conf_code', $code);
 
-
                // generate link
-               $link = $CONFIG->site->url . "resetpassword?u=$user_guid&c=$code";
+               $link = elgg_get_site_url() . "resetpassword?u=$user_guid&c=$code";
 
                // generate email
                $email = elgg_echo('email:resetreq:body', array($user->name, $_SERVER['REMOTE_ADDR'], $link));
 
-               return notify_user($user->guid, $CONFIG->site->guid,
-                       elgg_echo('email:resetreq:subject'), $email, NULL, 'email');
+               return notify_user($user->guid, elgg_get_site_entity()->guid,
+                       elgg_echo('email:resetreq:subject'), $email, array(), 'email');
        }
 
        return false;
@@ -760,7 +759,7 @@ function execute_new_password_request($user_guid, $conf_code) {
                                $email = elgg_echo('email:resetpassword:body', array($user->name, $password));
 
                                return notify_user($user->guid, $CONFIG->site->guid,
-                                       elgg_echo('email:resetpassword:subject'), $email, NULL, 'email');
+                                       elgg_echo('email:resetpassword:subject'), $email, array(), 'email');
                        }
                }
        }
@@ -1036,7 +1035,7 @@ function elgg_get_user_validation_status($user_guid) {
                'metadata_name' => 'validated'
        ));
        if ($md == false) {
-               return;
+               return null;
        }
 
        if ($md[0]->value) {
@@ -1208,7 +1207,8 @@ function set_last_login($user_guid) {
 function user_create_hook_add_site_relationship($event, $object_type, $object) {
        global $CONFIG;
 
-       add_entity_relationship($object->getGUID(), 'member_of_site', $CONFIG->site->getGUID());
+       add_entity_relationship($object->getGUID(), 'member_of_site', elgg_get_site_entity()->guid);
+       return true;
 }
 
 /**
index 9ee7ae00c7cfbb1f2eb6e15a53676598c7435d42..7d83478637d94ceeffab8ac522e171b72e69c22f 100644 (file)
@@ -1451,17 +1451,13 @@ function elgg_get_views($dir, $base) {
  */
 function elgg_view_tree($view_root, $viewtype = "") {
        global $CONFIG;
-       static $treecache;
+       static $treecache = array();
 
        // Get viewtype
        if (!$viewtype) {
                $viewtype = elgg_get_viewtype();
        }
 
-       // Has the treecache been initialised?
-       if (!isset($treecache)) {
-               $treecache = array();
-       }
        // A little light internal caching
        if (!empty($treecache[$view_root])) {
                return $treecache[$view_root];