diff --git a/src/controllers/AdminController.php b/src/controllers/AdminController.php index 9c37b9aba..d1896df29 100755 --- a/src/controllers/AdminController.php +++ b/src/controllers/AdminController.php @@ -668,4 +668,4 @@ class AdminController extends Controller implements CrawlConstants } return $data['SEARCH_ARRAY']; } -} \ No newline at end of file +} diff --git a/src/controllers/components/SystemComponent.php b/src/controllers/components/SystemComponent.php index 8b38599de..2745107dd 100755 --- a/src/controllers/components/SystemComponent.php +++ b/src/controllers/components/SystemComponent.php @@ -1272,4 +1272,4 @@ EOD; } return $out; } -} \ No newline at end of file +} diff --git a/src/data/default.db b/src/data/default.db index 827229958..82ac804b0 100644 Binary files a/src/data/default.db and b/src/data/default.db differ diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php index c07b385b4..534191864 100755 --- a/src/models/ProfileModel.php +++ b/src/models/ProfileModel.php @@ -105,6 +105,13 @@ class ProfileModel extends Model { $auto_increment = $dbm->autoIncrement($dbinfo); $serial = $dbm->serialType($dbinfo); + /** + * SQL statements used to create the Yioop database. Some of the + * these statements could use UNIQUE on some the columns that are + * later used in CREATE INDEX statements. However, because of + * restrictions on the number of bytes (not chars) in MYSQL for keys + * this has not been done. + */ $this->create_statements = ["ACTIVE_PROCESS" => "CREATE TABLE ACTIVE_PROCESS (NAME VARCHAR(".C\NAME_LEN. "), ID INTEGER, TYPE VARCHAR(" . C\NAME_LEN . "))", @@ -177,8 +184,7 @@ class ProfileModel extends Model 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 . "), - CONSTRAINT GID_TITLE_LOC UNIQUE(GROUP_ID, TITLE, LOCALE_TAG))", + "), 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( @@ -236,11 +242,11 @@ class ProfileModel extends Model "MACHINE" => "CREATE TABLE MACHINE (NAME VARCHAR(" . C\NAME_LEN .") PRIMARY KEY, URL VARCHAR(" . C\MAX_URL_LEN . - ") UNIQUE, HAS_QUEUE_SERVER INT, + "), HAS_QUEUE_SERVER INT, NUM_FETCHERS INTEGER, PARENT VARCHAR(" . C\NAME_LEN . ") )", "MEDIA_SOURCE" => "CREATE TABLE MEDIA_SOURCE ( TIMESTAMP NUMERIC(" . C\TIMESTAMP_LEN . ") PRIMARY KEY, - NAME VARCHAR(" . C\LONG_NAME_LEN . ") UNIQUE, + NAME VARCHAR(" . C\LONG_NAME_LEN . "), TYPE VARCHAR(" . C\NAME_LEN . "), SOURCE_URL VARCHAR(" . C\MAX_URL_LEN . "), AUX_INFO VARCHAR(". C\MAX_URL_LEN . "), LANGUAGE VARCHAR(" . C\NAME_LEN . "))", @@ -272,7 +278,7 @@ class ProfileModel extends Model "SCRAPER" => "CREATE TABLE SCRAPER (ID $serial PRIMARY KEY $auto_increment, NAME VARCHAR(" . - C\TITLE_LEN . ") UNIQUE, SIGNATURE VARCHAR(" + C\TITLE_LEN . "), SIGNATURE VARCHAR(" . C\TITLE_LEN . ")," . "SCRAPE_RULES VARCHAR(" . C\TITLE_LEN . "))", "SUBSEARCH" => "CREATE TABLE SUBSEARCH ( @@ -283,7 +289,7 @@ class ProfileModel extends Model "TRANSLATION" => "CREATE TABLE TRANSLATION ( TRANSLATION_ID $serial PRIMARY KEY $auto_increment, IDENTIFIER_STRING VARCHAR(" . C\TITLE_LEN - .") UNIQUE)", + ."))", "TRANS_IDENTIFIER_STRING_INDEX" => "CREATE INDEX TRANS_IDENTIFIER_STRING_INDEX ON TRANSLATION(IDENTIFIER_STRING)", @@ -550,7 +556,6 @@ EOT; if ($test_dbm === false || $test_dbm === true) { return $test_dbm; } - $this->initializeSql($test_dbm, $dbinfo); $copy_tables = array_diff(array_keys($this->create_statements), $skip_list); @@ -662,6 +667,7 @@ EOT; if (isset($test_dbm->special_quote)) { $q = $test_dbm->special_quote; } + restore_error_handler(); @$test_dbm->execute("CREATE DATABASE $q".$dbinfo['DB_NAME']."$q"); $test_dbm->disconnect(); if (!$test_dbm->connect( @@ -674,14 +680,9 @@ EOT; Temporarily disable more aggressive yioop error handler while do this */ - if ((C\DEBUG_LEVEL & C\ERROR_INFO) == C\ERROR_INFO) { - restore_error_handler(); - } $sql = "SELECT LOCALE_ID FROM LOCALE"; $result = $test_dbm->execute($sql); - if ((C\DEBUG_LEVEL & C\ERROR_INFO) == C\ERROR_INFO) { - set_error_handler(C\NS_LIB . "yioop_error_handler"); - } + set_error_handler(C\NS_LIB . "yioop_error_handler"); if ($result !== false && $test_dbm->fetchArray($result) !== false) { return true; } diff --git a/src/models/UserModel.php b/src/models/UserModel.php index e8bb7b2da..8cd422ced 100755 --- a/src/models/UserModel.php +++ b/src/models/UserModel.php @@ -126,7 +126,8 @@ class UserModel extends Model "FROM TRANSLATION_LOCALE ". "WHERE TRANSLATION_ID=? AND LOCALE_ID=? $limit_offset"; // maybe do left join at some point - while ($activities[$i] = $this->db->fetchArray($result)) { + while ($row = $this->db->fetchArray($result)) { + $activities[$i] = $row; $id = $activities[$i]['TRANSLATION_ID']; $result_sub = $db->execute($sub_sql, [$id, $locale_id]); $translate = $db->fetchArray($result_sub); @@ -140,7 +141,6 @@ class UserModel extends Model } $i++; } - unset($activities[$i]); //last one will be null return $activities; } /** @@ -562,4 +562,4 @@ class UserModel extends Model $this->db->execute($sql, $params); } } -} \ No newline at end of file +} diff --git a/src/models/datasources/DatasourceManager.php b/src/models/datasources/DatasourceManager.php index 630e6b49c..1a99b892e 100755 --- a/src/models/datasources/DatasourceManager.php +++ b/src/models/datasources/DatasourceManager.php @@ -369,12 +369,12 @@ abstract class DatasourceManager { $sql = "SELECT * FROM $from_table"; if (($result = $from_dbm->execute($sql)) === false) { - return false; + return true; } while ($row = $from_dbm->fetchArray($result)) { $statement = "INSERT INTO $to_table VALUES ("; $comma =""; - foreach ($row as $col=> $value) { + foreach ($row as $col => $value) { $statement .= $comma." '".$to_dbm->escapeString($value)."'"; $comma = ","; } @@ -385,4 +385,4 @@ abstract class DatasourceManager } return true; } -} \ No newline at end of file +}