viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Get Database Archive Iterator working again after namespace changes, a=chris

Chris Pollett [2015-07-03 05:Jul:rd]
Get Database Archive Iterator working again after namespace changes, a=chris
Filename
executables/Fetcher.php
library/archive_bundle_iterators/DatabaseBundleIterator.php
diff --git a/executables/Fetcher.php b/executables/Fetcher.php
index 6a874c380..436081af2 100755
--- a/executables/Fetcher.php
+++ b/executables/Fetcher.php
@@ -1172,10 +1172,10 @@ class Fetcher implements CrawlConstants
             "&session=$session&robot_instance=".$prefix.ROBOT_INSTANCE.
             "&machine_uri=".WEB_URI."&crawl_time=".$this->crawl_time.
             "&check_crawl_time=".$this->check_crawl_time;
+        L\crawlLog($request);
         $response_string = FetchUrl::getPage($request, null, true);
         if ($response_string === false) {
-            L\crawlLog("The following request failed:");
-            L\crawlLog($request);
+            L\crawlLog("Request failed!");
             return false;
         }
         if ($response_string) {
diff --git a/library/archive_bundle_iterators/DatabaseBundleIterator.php b/library/archive_bundle_iterators/DatabaseBundleIterator.php
index 46ec6b947..584b7158c 100644
--- a/library/archive_bundle_iterators/DatabaseBundleIterator.php
+++ b/library/archive_bundle_iterators/DatabaseBundleIterator.php
@@ -30,7 +30,9 @@
  */
 namespace seekquarry\yioop\library\archive_bundle_iterators;

+use seekquarry\yioop\library as L;
 use seekquarry\yioop\library\CrawlConstants;
+use seekquarry\yioop\library\FetchUrl;

 if (!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
 /** For webencode */
@@ -104,7 +106,7 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
         $this->iterate_dir = $iterate_dir;
         $this->result_timestamp = $result_timestamp;
         $this->result_dir = $result_dir;
-        $ini = parse_ini_with_fallback(
+        $ini = L\parse_ini_with_fallback(
             "{$this->iterate_dir}/arc_description.ini");
         $this->dbinfo = ["DBMS" => DBMS, "DB_HOST" => DB_HOST,
             "DB_NAME" => DB_NAME, "DB_USER" => DB_USER,
@@ -117,13 +119,14 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
         }
         $db_class = NS_DATASOURCES . ucfirst($this->dbinfo["DBMS"])."Manager";
         $this->db = new $db_class();
-        $this->db->connect($this->dbinfo['DB_HOST'],
+        $conn = $this->db->connect($this->dbinfo['DB_HOST'],
             $this->dbinfo['DB_USER'], $this->dbinfo['DB_PASSWORD'],
             $this->dbinfo['DB_NAME']);
         if (isset($ini['sql'])) {
             $this->sql = $ini['sql'];
         } else {
-            crawlLog("Database Archive Iterator needs a SQL statement to run");
+            L\crawlLog(
+                "Database Archive Iterator needs a SQL statement to run");
             exit();
         }
         if (isset($ini['field_value_separator'])) {
@@ -188,7 +191,8 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
         $pages = [];
         $page_count = 0;
         $db = $this->db;
-        $query = "{$this->sql} ". $db->limitOffset($this->limit, $num);
+        $query = "{$this->sql} " . $db->limitOffset($this->limit, $num,
+            $this->dbinfo);
         $result = $db->execute($query);
         $i = 0;
         while($row = $db->fetchArray($result)) {
@@ -203,13 +207,13 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
                 $pages[] = $page;
             } else {
                 $site = [];
-                $site[self::HEADER] = "database_bundle_iterator extractor";
+                $site[self::HEADER] = "DatabaseBundleIterator extractor";
                 $site[self::IP_ADDRESSES] = ["0.0.0.0"];
                 $site[self::TIMESTAMP] = date("U", time());
                 $site[self::TYPE] = "text/plain";
                 $site[self::PAGE] = $page;
                 $site[self::HASH] = FetchUrl::computePageHash($page);
-                $site[self::URL] = "record:".webencode($site[self::HASH]);
+                $site[self::URL] = "record:".L\webencode($site[self::HASH]);
                 $site[self::HTTP_CODE] = 200;
                 $site[self::ENCODING] = $this->encoding;
                 $site[self::SERVER] = "unknown";
ViewGit