Browse Source

mysql-related fixes

Andrew Dolgov 2 years ago
parent
commit
19d768353d
2 changed files with 3 additions and 9 deletions
  1. 2 4
      init.php
  2. 1 5
      sql/phash_schema_mysql.sql

+ 2 - 4
init.php

@@ -221,8 +221,6 @@ class Af_Zz_Img_Phash extends Plugin {
 
 	function hook_article_filter($article) {
 
-		if (DB_TYPE != "pgsql") return $article;
-
 		$enable_globally = $this->host->get($this, "enable_globally");
 		$domains_list = $this->host->get($this, "domains_list");
 
@@ -303,10 +301,10 @@ class Af_Zz_Img_Phash extends Plugin {
 							_debug("phash: calculated perceptual hash: $hash");
 
 							if ($hash) {
-								$hash_escaped = db_escape_string($hash);
+								$hash_escaped = db_escape_string(base_convert($hash, 16, 10));
 
 								db_query("INSERT INTO ttrss_plugin_img_phash_urls (url, article_guid, owner_uid, phash) VALUES
-									('$src_escaped', '$article_guid', $owner_uid, x'$hash_escaped'::bigint)");
+									('$src_escaped', '$article_guid', $owner_uid, '$hash_escaped')");
 							}
 
 						} else {

+ 1 - 5
sql/phash_schema_mysql.sql

@@ -1,4 +1,4 @@
-drop table ttrss_plugin_img_phash_urls;
+drop table if exists ttrss_plugin_img_phash_urls;
 
 create table ttrss_plugin_img_phash_urls(
   id integer not null PRIMARY KEY auto_increment,
@@ -8,8 +8,4 @@ create table ttrss_plugin_img_phash_urls(
   phash bigint,
   created_at timestamp not null default NOW()) ENGINE=InnoDB;
 
-drop index if exists ttrss_plugin_img_phash_urls_url_idx;
-create index ttrss_plugin_img_phash_urls_url_idx on ttrss_plugin_img_phash_urls(url);
-
-drop index if exists ttrss_plugin_img_phash_urls_created_idx;
 create index ttrss_plugin_img_phash_urls_created_idx on ttrss_plugin_img_phash_urls (created_at);