Fix some edges cases for group feeds with no posts that arose after the new wiki page with comments code, a=chris

Chris Pollett [2017-01-11 04:Jan:th]
Fix some edges cases for group feeds with no posts that arose after the new wiki page with comments code, a=chris
Filename
src/controllers/Controller.php
src/controllers/RegisterController.php
src/controllers/SearchController.php
src/controllers/components/SocialComponent.php
src/examples/bot_examples/weather/WeatherBot.php
src/executables/ArcTool.php
src/library/CrawlDaemon.php
src/library/IndexShard.php
src/library/media_jobs/AnalyticsJob.php
src/views/elements/GroupfeedElement.php
tests/index.php
tests/test_files/scrapers/test.php
diff --git a/src/controllers/Controller.php b/src/controllers/Controller.php
index 2012d9f13..4e8cb5b5c 100755
--- a/src/controllers/Controller.php
+++ b/src/controllers/Controller.php
@@ -927,8 +927,8 @@ abstract class Controller
     /**
      * Fuzzifies the data to achieve differential privacy
      *
-     * @param int actual value
-     * @return int fuzzified value
+     * @param int $actual_value
+     * @return int $level_privacy
      */
     public function addDifferentialPrivacy($actual_value, $level_privacy = 1)
     {
diff --git a/src/controllers/RegisterController.php b/src/controllers/RegisterController.php
index baec46d7b..719ceb366 100755
--- a/src/controllers/RegisterController.php
+++ b/src/controllers/RegisterController.php
@@ -1052,6 +1052,8 @@ class RegisterController extends Controller implements CrawlConstants
     }
     /**
      *
+     * @param string $register_view
+     * @param string $locale
      */
     public static function getRecoveryQuestions($register_view, $locale)
     {
diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php
index a527615e7..bc860005f 100755
--- a/src/controllers/SearchController.php
+++ b/src/controllers/SearchController.php
@@ -1207,7 +1207,7 @@ class SearchController extends Controller implements CrawlConstants
      */
     public function relatedRequest($url, $results_per_page, $limit = 0,
         $crawl_time = 0, $grouping = 0, $save_timestamp = 0,
-        $limit_feds = true)
+        $limit_feeds = true)
     {
         if (!C\API_ACCESS) {return null; }
         $grouping = ($grouping > 0 ) ? 2 : 0;
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index 7e7ec71f9..59e7c3000 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -1597,8 +1597,8 @@ class SocialComponent extends Component implements CrawlConstants
             $pub_clause];
         $for_group = ($just_group_id) ? $just_group_id : (($just_thread) ?
             -2 : -1);
-        list($item_count, $pages) = $this->initializeFeedItems($data, $user_id,
-            $just_group_id, $search_array, $for_group, $sort, $limit,
+        list($item_count, $pages) = $this->initializeFeedItems($data, $pages,
+            $user_id, $just_group_id, $search_array, $for_group, $sort, $limit,
             $results_per_page);
         $data['SUBTITLE'] = "";
         $type = "";
@@ -1628,6 +1628,8 @@ class SocialComponent extends Component implements CrawlConstants
             $data['GROUP_STATUS'] = $group['STATUS'];
             if (!isset($page[self::SOURCE_NAME]) ) {
                 $page[self::SOURCE_NAME] = $group['GROUP_NAME'];
+            }
+            if (empty($pages) ) {
                 $data['NO_POSTS_YET'] = true;
                 if ($user_id == $group['OWNER_ID'] || $user_id == C\ROOT_ID) {
                         // this case happens when a group is no read
@@ -1668,7 +1670,18 @@ class SocialComponent extends Component implements CrawlConstants
         $this->initializeWikiEditor($data, -1);
         return $data;
     }
-    private function initializeFeedItems(&$data, $user_id, $group_id,
+    /**
+     * @param array &$data
+     * @param array $pages
+     * @param int $user_id
+     * @param int $group_id
+     * @param array $search_array
+     * @param int $for_group
+     * @param string $sort
+     * @param int $limit
+     * @param int $results_per_page
+     */
+    private function initializeFeedItems(&$data, $pages, $user_id, $group_id,
         $search_array, $for_group, $sort, $limit, $results_per_page)
     {
         $parent = $this->parent;
@@ -1684,7 +1697,6 @@ class SocialComponent extends Component implements CrawlConstants
         $parser = new WikiParser("", [], true);
         $locale_tag = L\getLocaleTag();
         $page = false;
-        $pages = [];
         $math = false;
         $csrf_token = C\CSRF_TOKEN . "=" .$this->parent->generateCSRFToken(
             $user_id);
@@ -2444,7 +2456,9 @@ class SocialComponent extends Component implements CrawlConstants
     }
     /**
      * @param array &$data
+     * @param int $user_id
      * @param int $group_id
+     * @param string $sub_path
      */
     private function initializeReadMode(&$data, $user_id, $group_id, $sub_path)
     {
@@ -2530,7 +2544,7 @@ class SocialComponent extends Component implements CrawlConstants
             $results_per_page =  (!empty($_REQUEST['num'])) ?
                 $parent->clean($_REQUEST['num'], 'int') :
                 C\NUM_RESULTS_PER_PAGE;
-            list($item_count, $pages) = $this->initializeFeedItems($data,
+            list($item_count, $pages) = $this->initializeFeedItems($data, [],
                 $user_id, $group_id, $search_array, -2, "krsort",
                 $limit, $results_per_page);
             if ($limit + count($pages) == $item_count) {
diff --git a/src/examples/bot_examples/weather/WeatherBot.php b/src/examples/bot_examples/weather/WeatherBot.php
index dc52ecf17..aab0aae62 100644
--- a/src/examples/bot_examples/weather/WeatherBot.php
+++ b/src/examples/bot_examples/weather/WeatherBot.php
@@ -43,6 +43,9 @@
  */
 class WeatherBot
 {
+    /**
+     * @param string $access_token
+     */
     function setKey($access_token)
     {
         $this->access_token = $access_token;
@@ -55,13 +58,13 @@ class WeatherBot
      */
     function getWeather($location)
     {
-        $BASE_URL = "http://query.yahooapis.com/v1/public/yql";
+        $WEATHER_URL = "http://query.yahooapis.com/v1/public/yql";
         $yql_query = "select * from weather.forecast where woeid in
                       (select woeid from geo.places(1) where text='".$location
                       ."')";
-        $Url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json";
+        $url = $WEATHER_URL . "?q=" . urlencode($yql_query) . "&format=json";
         $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $Url);
+        curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $data = curl_exec($ch);
         curl_close($ch);
diff --git a/src/executables/ArcTool.php b/src/executables/ArcTool.php
index 7c90ea23b..aa18900da 100755
--- a/src/executables/ArcTool.php
+++ b/src/executables/ArcTool.php
@@ -245,7 +245,7 @@ class ArcTool implements CrawlConstants
      *     an IndexArchiveBundle
      * @param string $word to look up dictionary record for
      * @param int $start_generation
-     * @param int $num_generation
+     * @param int $num_generations
      */
     public function outputDictInfo($archive_path, $word, $start_generation,
         $num_generations)
diff --git a/src/library/CrawlDaemon.php b/src/library/CrawlDaemon.php
index 0aa0c43a4..cb1682d2d 100644
--- a/src/library/CrawlDaemon.php
+++ b/src/library/CrawlDaemon.php
@@ -116,7 +116,7 @@ class CrawlDaemon implements CrawlConstants
      *     tell the daemon to stop. If the argument is terminal then the
      *     program won't be run as a daemon.
      * @param string $name the prefix to use for lock and message files
-     * @param int $exit whether this function should exit > 0 or return (1)
+     * @param int $exit_type whether this function should exit > 0 or return (1)
      *     by default a lock file is only written if exit (this allows
      *     both queue server processes (Indexer and Scheduler) to use the
      *     same lock file. If exit is >=3 or <= -3 then doesn't check lock
diff --git a/src/library/IndexShard.php b/src/library/IndexShard.php
index 197e4b232..f775cb5e4 100644
--- a/src/library/IndexShard.php
+++ b/src/library/IndexShard.php
@@ -528,7 +528,7 @@ class IndexShard extends PersistentStructure implements
      *  Return word record (word key + posting lookup data )from the shard
      *  from the shard posting list
      *
-     *  @param bool $is_disk whether the shard is on disk or in memory
+     *  @param boolean $is_disk whether the shard is on disk or in memory
      *  @param int $start offset to start of the dictionary
      *  @param int $location index of record to extract from dictionary
      *  @param int $word_item_len length of a word + data record
diff --git a/src/library/media_jobs/AnalyticsJob.php b/src/library/media_jobs/AnalyticsJob.php
index 40d153ae4..7874a2517 100644
--- a/src/library/media_jobs/AnalyticsJob.php
+++ b/src/library/media_jobs/AnalyticsJob.php
@@ -319,10 +319,10 @@ class AnalyticsJob extends MediaJob
      * would be returned by that query.
      *
      * @param string $query to use and count the results of
-     * @param array $machine_urls queue servers on which the count is to be
-     *      computed
      * @param string $index_timestamp timestamp of index to compute query
      *      count for
+     * @param array $machine_urls queue servers on which the count is to be
+     *      computed
      * @return int number of results that would be returned by the given query
      */
     public function countQuery($query, $index_timestamp, $machine_urls)
diff --git a/src/views/elements/GroupfeedElement.php b/src/views/elements/GroupfeedElement.php
index b2a8dc979..d9c5802a6 100644
--- a/src/views/elements/GroupfeedElement.php
+++ b/src/views/elements/GroupfeedElement.php
@@ -686,6 +686,7 @@ class GroupfeedElement extends Element implements CrawlConstants
             }
         }
         $this->view->helper("fileupload")->setupFileUploadParams();
+        $hide_title = "";
         if (!empty($data['DISCUSS_THREAD'])) {
             $hide_title = ' class="none" ';
         }
diff --git a/tests/index.php b/tests/index.php
index 62bbd66af..7a5043ea1 100644
--- a/tests/index.php
+++ b/tests/index.php
@@ -55,8 +55,15 @@ if (!C\PROFILE || !C\DISPLAY_TESTS) {
     echo "BAD REQUEST";
     exit();
 }
-/** Catch errors as exceptions too*/
-function exceptionErrorHandler($errno, $errstr, $errfile, $errline ) {
+/**
+ *Error handler so  catch errors as exceptions too
+ *
+ * @param int $errno number code of error
+ * @param string $errstr text of error message
+ * @param string $errfile filename of file in which error occurred
+ * @param int $errline line number of error
+ */
+function exceptionErrorHandler($errno, $errstr, $errfile, $errline) {
     throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
 }
 set_error_handler(C\NS_TESTS . "exceptionErrorHandler");
diff --git a/tests/test_files/scrapers/test.php b/tests/test_files/scrapers/test.php
deleted file mode 100644
index aa8b681e1..000000000
--- a/tests/test_files/scrapers/test.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-$dom = new \DOMDocument();
-$page = file_get_contents("Yioop01.txt");
-@$dom->loadHTML($page);
-$xpath_doc = new \DOMXpath($dom);
-$elements = $xpath_doc->query("/html/head/*[contains(@href, 'wp-content') or contains(@href, 'wp-includes')]");
-var_dump($elements);
ViewGit