Make sure dbms works mysql 5.7.32, a=chris

Chris Pollett [2021-02-22 08:Feb:nd]
Make sure dbms works mysql 5.7.32, a=chris
Filename
src/configs/Createdb.php
src/models/ProfileModel.php
src/models/datasources/DatasourceManager.php
diff --git a/src/configs/Createdb.php b/src/configs/Createdb.php
index dbd8ae1e6..61aceaa6a 100755
--- a/src/configs/Createdb.php
+++ b/src/configs/Createdb.php
@@ -71,7 +71,7 @@ if (!in_array($lower_dbms, ['sqlite', 'sqlite3'])) {
         $host = preg_replace("/\;dbname\=\w+/", "", DB_HOST);
         L\crawlLog('Public database doesn\'t exist yet, trying to create it');
         $public_exist = false;
-        $db->connect($host, DB_USER, DB_PASSWORD);
+        $db->connect($host, DB_USER, DB_PASSWORD, "");
     }
     $private_exist = true;
     if(!$private_db->connect(PRIVATE_DB_HOST, PRIVATE_DB_USER,
diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php
index 598a9cec7..c94c9876c 100755
--- a/src/models/ProfileModel.php
+++ b/src/models/ProfileModel.php
@@ -119,6 +119,8 @@ class ProfileModel extends Model
         $auto_increment = $dbm->autoIncrement($dbinfo);
         $serial = $dbm->serialType($dbinfo);
         $integer = $dbm->integerType($dbinfo);
+        $page_type = $dbm->pageType($dbinfo);
+        $scraper_factor = (stristr($dbinfo['DBMS'], "mysql") !== false) ? 4: 10;
         /**
          * SQL statements used to create the Yioop database. Some of the
          * these statements could use UNIQUE on some the columns that are
@@ -200,14 +202,12 @@ class ProfileModel extends Model
             "GROUP_PAGE" => "CREATE TABLE GROUP_PAGE (
                 ID $serial PRIMARY KEY $auto_increment, GROUP_ID $integer,
                 DISCUSS_THREAD $integer, TITLE VARCHAR(" . C\TITLE_LEN . "),
-                PAGE VARCHAR(" . C\MAX_GROUP_PAGE_LEN .
-                    "), LOCALE_TAG VARCHAR(" . C\NAME_LEN . "))",
+                PAGE $page_type, LOCALE_TAG VARCHAR(" . C\NAME_LEN . "))",
             "GP_ID_INDEX" => "CREATE INDEX GP_ID_INDEX ON GROUP_PAGE
                  (GROUP_ID, TITLE, LOCALE_TAG)",
             "GROUP_PAGE_HISTORY" => "CREATE TABLE GROUP_PAGE_HISTORY(
                 PAGE_ID $integer, GROUP_ID $integer, EDITOR_ID $integer,
-                TITLE VARCHAR(" . C\TITLE_LEN . "),
-                PAGE VARCHAR(" . C\MAX_GROUP_PAGE_LEN . "),
+                TITLE VARCHAR(" . C\TITLE_LEN . "), PAGE  $page_type,
                 EDIT_COMMENT VARCHAR(" . C\SHORT_TITLE_LEN .
                 "), LOCALE_TAG VARCHAR(" . C\NAME_LEN . "),
                 PUBDATE NUMERIC(" . C\TIMESTAMP_LEN . "),
@@ -318,9 +318,9 @@ class ProfileModel extends Model
                 PRIORITY $integer DEFAULT 0,
                 SIGNATURE VARCHAR(" . C\MAX_URL_LEN . "),
                 TEXT_PATH VARCHAR(" . C\MAX_URL_LEN . ") DEFAULT '',
-                DELETE_PATHS VARCHAR(" . (10 * C\MAX_URL_LEN) . ") DEFAULT '',
-                EXTRACT_FIELDS VARCHAR(" . (10 * C\MAX_URL_LEN) .
-                ") DEFAULT '')",
+                DELETE_PATHS VARCHAR(" . ($scraper_factor * C\MAX_URL_LEN) .
+                ") DEFAULT '', EXTRACT_FIELDS VARCHAR(" .
+                ($scraper_factor * C\MAX_URL_LEN) . ") DEFAULT '')",
             "SUBSEARCH" => "CREATE TABLE SUBSEARCH (
                 LOCALE_STRING VARCHAR(" . C\LONG_NAME_LEN . ") PRIMARY KEY,
                 FOLDER_NAME VARCHAR(" . C\NAME_LEN."),
diff --git a/src/models/datasources/DatasourceManager.php b/src/models/datasources/DatasourceManager.php
index 627b72f26..7a5acc61d 100755
--- a/src/models/datasources/DatasourceManager.php
+++ b/src/models/datasources/DatasourceManager.php
@@ -342,6 +342,22 @@ abstract class DatasourceManager
         }
         return $integer;
     }
+    /**
+     * Used when creating databases to set what type should be used for
+     * wiki pages
+     * @param array $dbinfo containing fields for the current DBMS
+     * @return string to use for column type corresponding to wiki page
+     */
+    public function pageType($dbinfo)
+    {
+        $page_type = "VARCHAR(" . C\MAX_GROUP_PAGE_LEN . ")";
+        $dbms = strtolower($dbinfo['DBMS']);
+        if (in_array($dbms, ['mysql']) || (stristr($dbinfo['DBMS'], 'pdo') &&
+            stristr($dbinfo['DB_HOST'], 'mysql'))) {
+            $page_type = "TEXT";
+        }
+        return $page_type;
+    }
     /**
      * Used to convert a sql string that does an insert statement
      * into a sql string where a duplicate insert
ViewGit