From 2a90145ef3f2189019af918ca164caee556beea5 Mon Sep 17 00:00:00 2001 From: Darko Date: Wed, 28 May 2014 08:57:06 +0200 Subject: [PATCH] Fixes in db.sql and added a patch. --- lib/DB/db.sql | 6 ++---- lib/DB/patches/0045_prehash.sql | 3 +++ lib/namefixer.php | 6 ++++-- start.php | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 lib/DB/patches/0045_prehash.sql diff --git a/lib/DB/db.sql b/lib/DB/db.sql index b6be4bc8a..66bfa86ed 100644 --- a/lib/DB/db.sql +++ b/lib/DB/db.sql @@ -52,7 +52,7 @@ CREATE TABLE prehash ( AUTO_INCREMENT =1; CREATE INDEX `ix_prehash_filename` ON `prehash` (`filename`); -CREATE INDEX `ix_prehash_title` ON `prehash` (`title`); +CREATE UNIQUE INDEX `ix_prehash_title` ON `prehash` (`title`); CREATE INDEX `ix_prehash_nfo` ON `prehash` (`nfo`); CREATE INDEX `ix_prehash_predate` ON `prehash` (`predate`); CREATE INDEX `ix_prehash_source` ON `prehash` (`source`); @@ -60,8 +60,6 @@ CREATE INDEX `ix_prehash_requestid` ON `prehash` (`requestID`, `groupID`); CREATE INDEX `ix_prehash_size` ON `prehash` (`size`); CREATE INDEX `ix_prehash_category` ON `prehash` (`category`); CREATE INDEX `ix_prehash_searched` ON `prehash` (`searched`); -CREATE UNIQUE INDEX `ix_prehash_md5` ON `prehash` (`md5`); -CREATE UNIQUE INDEX `ix_prehash_sha1` ON `prehash` (`sha1`); DROP TABLE IF EXISTS tmux; CREATE TABLE tmux ( @@ -205,7 +203,7 @@ INSERT INTO tmux (setting, value) VALUES ('defrag_cache', '900'), ('ffmpeg_duration', '5'), ('ffmpeg_image_time', '5'), ('processvideos', '0'), - ('sqlpatch', '43'); + ('sqlpatch', '45'); DROP TABLE IF EXISTS releasesearch; CREATE TABLE releasesearch ( diff --git a/lib/DB/patches/0045_prehash.sql b/lib/DB/patches/0045_prehash.sql new file mode 100644 index 000000000..4137cfa0b --- /dev/null +++ b/lib/DB/patches/0045_prehash.sql @@ -0,0 +1,3 @@ +ALTER TABLE prehash DROP INDEX ix_prehash_title; +ALTER IGNORE TABLE prehash ADD UNIQUE INDEX ix_prehash_title (title); +UPDATE `tmux` SET value = '45' WHERE `setting` = 'sqlpatch'; \ No newline at end of file diff --git a/lib/namefixer.php b/lib/namefixer.php index 3f7821bbf..0e33f948e 100644 --- a/lib/namefixer.php +++ b/lib/namefixer.php @@ -382,7 +382,6 @@ class Namefixer $this->category = new Category(); $this->functions = new Functions(); $this->matched = false; - //Remove all non-printable chars, preg match all interesting words $titlelike = "%" . $this->functions->stripNonPrintingChars($pre['title']) . "%"; preg_match_all('#\w+#', $pre['title'], $matches, PREG_PATTERN_ORDER); @@ -392,7 +391,9 @@ class Namefixer $res = $db->queryDirect(sprintf("SELECT rs.releaseID AS releaseID FROM releasesearch rs WHERE MATCH (rs.name, rs.searchname) AGAINST ('%s' IN BOOLEAN MODE) AND (rs.name LIKE %s OR rs.searchname LIKE %s) - LIMIT 16", $titlematch, $db->escapeString($titlelike), $db->escapeString($titlelike))); + LIMIT 16", $titlematch, $db->escapeString($titlelike), $db->escapeString($titlelike) + ) + ); if ($res !== false) { $total = count($res); @@ -434,6 +435,7 @@ class Namefixer } elseif ($total >= 10) { $matching = -1; } + return $matching; } diff --git a/start.php b/start.php index 85a71c086..2e15b83a1 100644 --- a/start.php +++ b/start.php @@ -15,7 +15,7 @@ $tmux = $t->get(); $patch = (isset($tmux->sqlpatch)) ? $tmux->sqlpatch : 0; // Check database patch version -if ($patch < 44) { +if ($patch < 45) { exit($c->error("\nYour database is not up to date. Please update.\nphp ${DIR}/lib/DB/patchDB.php\n")); } $tmux_session = (isset($tmux->tmux_session)) ? $tmux->tmux_session : 0;