remove SCORE_STRNORM - everyone supports LOWER now
This commit is contained in:
parent
7b7febea55
commit
d7a2ca9ddc
12 changed files with 22 additions and 26 deletions
|
@ -6,7 +6,6 @@ abstract class SCORE
|
|||
const BOOL_Y = "SCORE_BOOL_Y";
|
||||
const BOOL_N = "SCORE_BOOL_N";
|
||||
const BOOL = "SCORE_BOOL";
|
||||
const STRNORM = "SCORE_STRNORM";
|
||||
const ILIKE = "SCORE_ILIKE";
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,6 @@ class MySQL extends DBEngine
|
|||
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
|
||||
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
|
||||
$data = str_replace(SCORE::BOOL, "ENUM('Y', 'N')", $data);
|
||||
$data = str_replace(SCORE::STRNORM, "", $data);
|
||||
$data = str_replace(SCORE::ILIKE, "LIKE", $data);
|
||||
return $data;
|
||||
}
|
||||
|
@ -101,7 +99,6 @@ class PostgreSQL extends DBEngine
|
|||
$data = str_replace(SCORE::BOOL_Y, $this->BOOL_Y, $data);
|
||||
$data = str_replace(SCORE::BOOL_N, $this->BOOL_N, $data);
|
||||
$data = str_replace(SCORE::BOOL, "BOOL", $data);
|
||||
$data = str_replace(SCORE::STRNORM, "lower", $data);
|
||||
$data = str_replace(SCORE::ILIKE, "ILIKE", $data);
|
||||
return $data;
|
||||
}
|
||||
|
@ -196,7 +193,6 @@ class SQLite extends DBEngine
|
|||
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
|
||||
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
|
||||
$data = str_replace(SCORE::BOOL, "CHAR(1)", $data);
|
||||
$data = str_replace(SCORE::STRNORM, "lower", $data);
|
||||
$data = str_replace(SCORE::ILIKE, "LIKE", $data);
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ class Image
|
|||
}
|
||||
} elseif ($tag_count === 1 && !preg_match("/[:=><\*\?]/", $tags[0])) {
|
||||
$total = $database->get_one(
|
||||
$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"),
|
||||
$database->scoreql_to_sql("SELECT count FROM tags WHERE LOWER(tag) = LOWER(:tag)"),
|
||||
["tag"=>$tags[0]]
|
||||
);
|
||||
} else {
|
||||
|
@ -720,7 +720,7 @@ class Image
|
|||
$database->scoreql_to_sql("
|
||||
SELECT id
|
||||
FROM tags
|
||||
WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)
|
||||
WHERE LOWER(tag) = LOWER(:tag)
|
||||
"),
|
||||
["tag"=>$tag]
|
||||
);
|
||||
|
@ -733,7 +733,7 @@ class Image
|
|||
$database->execute(
|
||||
$database->scoreql_to_sql(
|
||||
"INSERT INTO image_tags(image_id, tag_id)
|
||||
VALUES(:id, (SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)))"
|
||||
VALUES(:id, (SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)))"
|
||||
),
|
||||
["id"=>$this->id, "tag"=>$tag]
|
||||
);
|
||||
|
@ -754,7 +754,7 @@ class Image
|
|||
$database->scoreql_to_sql("
|
||||
UPDATE tags
|
||||
SET count = count + 1
|
||||
WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)
|
||||
WHERE LOWER(tag) = LOWER(:tag)
|
||||
"),
|
||||
["tag"=>$tag]
|
||||
);
|
||||
|
@ -957,7 +957,7 @@ class Image
|
|||
$sq = "
|
||||
SELECT id
|
||||
FROM tags
|
||||
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:tag)
|
||||
WHERE LOWER(tag) LIKE LOWER(:tag)
|
||||
";
|
||||
if ($database->get_driver_name() === DatabaseDriver::SQLITE) {
|
||||
$sq .= "ESCAPE '\\'";
|
||||
|
|
|
@ -52,7 +52,7 @@ class Tag
|
|||
$database->scoreql_to_sql("
|
||||
SELECT newtag
|
||||
FROM aliases
|
||||
WHERE SCORE_STRNORM(oldtag)=SCORE_STRNORM(:tag)
|
||||
WHERE LOWER(oldtag)=LOWER(:tag)
|
||||
"),
|
||||
["tag"=>$tag]
|
||||
);
|
||||
|
|
|
@ -99,7 +99,7 @@ class User
|
|||
public static function by_name(string $name): ?User
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_row($database->scoreql_to_sql("SELECT * FROM users WHERE SCORE_STRNORM(name) = SCORE_STRNORM(:name)"), ["name"=>$name]);
|
||||
$row = $database->get_row($database->scoreql_to_sql("SELECT * FROM users WHERE LOWER(name) = LOWER(:name)"), ["name"=>$name]);
|
||||
return is_null($row) ? null : new User($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class AdminPage extends Extension
|
|||
{
|
||||
global $database;
|
||||
$database->execute($database->scoreql_to_sql(
|
||||
"UPDATE tags SET tag=:tag1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag2)"
|
||||
"UPDATE tags SET tag=:tag1 WHERE LOWER(tag) = LOWER(:tag2)"
|
||||
), ["tag1" => $_POST['tag'], "tag2" => $_POST['tag']]);
|
||||
log_info("admin", "Fixed the case of ".html_escape($_POST['tag']), "Fixed case");
|
||||
return true;
|
||||
|
|
|
@ -48,8 +48,8 @@ class AutoComplete extends Extension
|
|||
$database->scoreql_to_sql("
|
||||
SELECT tag, count
|
||||
FROM tags
|
||||
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search)
|
||||
-- OR SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:cat_search)
|
||||
WHERE LOWER(tag) LIKE LOWER(:search)
|
||||
-- OR LOWER(tag) LIKE LOWER(:cat_search)
|
||||
AND count > 0
|
||||
ORDER BY count DESC
|
||||
$limitSQL"),
|
||||
|
|
|
@ -86,7 +86,7 @@ class DanbooruApi extends Extension
|
|||
foreach ($namelist as $name) {
|
||||
$sqlresult = $database->get_all(
|
||||
$database->scoreql_to_sql(
|
||||
"SELECT id,tag,count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
"SELECT id,tag,count FROM tags WHERE LOWER(tag) = LOWER(:tag)"
|
||||
),
|
||||
['tag'=>$name]
|
||||
);
|
||||
|
|
|
@ -114,7 +114,7 @@ class NotATag extends Extension
|
|||
$input = validate_input(["d_tag"=>"string"]);
|
||||
$database->execute(
|
||||
$database->scoreql_to_sql(
|
||||
"DELETE FROM untags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
"DELETE FROM untags WHERE LOWER(tag) = LOWER(:tag)"
|
||||
),
|
||||
["tag"=>$input['d_tag']]
|
||||
);
|
||||
|
|
|
@ -579,10 +579,10 @@ class OuroborosAPI extends Extension
|
|||
$database->scoreql_to_sql(
|
||||
"
|
||||
SELECT DISTINCT
|
||||
id, SCORE_STRNORM(substr(tag, 1, 1)), count
|
||||
id, LOWER(substr(tag, 1, 1)), count
|
||||
FROM tags
|
||||
WHERE count >= :tags_min
|
||||
ORDER BY SCORE_STRNORM(substr(tag, 1, 1)) LIMIT :start, :max_items
|
||||
ORDER BY LOWER(substr(tag, 1, 1)) LIMIT :start, :max_items
|
||||
"
|
||||
),
|
||||
['tags_min' => $config->get_int(TagListConfig::TAGS_MIN), 'start' => $start, 'max_items' => $limit]
|
||||
|
|
|
@ -75,7 +75,7 @@ class TagCategories extends Extension
|
|||
$count = $matches[3];
|
||||
|
||||
$types = $database->get_col(
|
||||
$database->scoreql_to_sql('SELECT SCORE_STRNORM(category) FROM image_tag_categories')
|
||||
$database->scoreql_to_sql('SELECT LOWER(category) FROM image_tag_categories')
|
||||
);
|
||||
if (in_array($type, $types)) {
|
||||
$event->add_querylet(
|
||||
|
@ -85,7 +85,7 @@ class TagCategories extends Extension
|
|||
LEFT JOIN tags t ON it.tag_id = t.id
|
||||
WHERE images.id = it.image_id
|
||||
GROUP BY image_id
|
||||
HAVING SUM(CASE WHEN SCORE_STRNORM(t.tag) LIKE SCORE_STRNORM('$type:%') THEN 1 ELSE 0 END) $cmp $count
|
||||
HAVING SUM(CASE WHEN LOWER(t.tag) LIKE LOWER('$type:%') THEN 1 ELSE 0 END) $cmp $count
|
||||
)"))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class TagList extends Extension
|
|||
$res = $database->get_col($database->scoreql_to_sql("
|
||||
SELECT tag
|
||||
FROM tags
|
||||
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:search)
|
||||
WHERE LOWER(tag) LIKE LOWER(:search)
|
||||
AND count > 0
|
||||
$limitSQL
|
||||
"), $SQLarr);
|
||||
|
@ -238,10 +238,10 @@ class TagList extends Extension
|
|||
|
||||
$tag_data = $database->get_col($database->scoreql_to_sql("
|
||||
SELECT DISTINCT
|
||||
SCORE_STRNORM(substr(tag, 1, 1))
|
||||
LOWER(substr(tag, 1, 1))
|
||||
FROM tags
|
||||
WHERE count >= :tags_min
|
||||
ORDER BY SCORE_STRNORM(substr(tag, 1, 1))
|
||||
ORDER BY LOWER(substr(tag, 1, 1))
|
||||
"), ["tags_min"=>$tags_min]);
|
||||
|
||||
$html = "<span class='atoz'>";
|
||||
|
@ -284,7 +284,7 @@ class TagList extends Extension
|
|||
FROM tags
|
||||
WHERE count >= :tags_min
|
||||
AND tag SCORE_ILIKE :starts_with
|
||||
ORDER BY SCORE_STRNORM(tag)
|
||||
ORDER BY LOWER(tag)
|
||||
"), ["tags_min"=>$tags_min, "tags_min2"=>$tags_min, "starts_with"=>$starts_with]);
|
||||
|
||||
$html = "";
|
||||
|
@ -327,7 +327,7 @@ class TagList extends Extension
|
|||
FROM tags
|
||||
WHERE count >= :tags_min
|
||||
AND tag SCORE_ILIKE :starts_with
|
||||
ORDER BY SCORE_STRNORM(tag)
|
||||
ORDER BY LOWER(tag)
|
||||
"), ["tags_min"=>$tags_min, "starts_with"=>$starts_with]);
|
||||
|
||||
$html = "";
|
||||
|
|
|
@ -231,7 +231,7 @@ class Wiki extends Extension
|
|||
$database->scoreql_to_sql("
|
||||
SELECT *
|
||||
FROM wiki_pages
|
||||
WHERE SCORE_STRNORM(title) LIKE SCORE_STRNORM(:title)
|
||||
WHERE LOWER(title) LIKE LOWER(:title)
|
||||
ORDER BY revision DESC"),
|
||||
["title"=>$title]
|
||||
);
|
||||
|
|
Reference in a new issue