From ef6a7289bb778aa79c9cc7908b3f5310e70a608c Mon Sep 17 00:00:00 2001 From: Daku Date: Wed, 12 Aug 2015 06:11:21 +0100 Subject: [PATCH] if alias is negative and has multiple tags, make sure each tag becomes negative --- core/imageboard.pack.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index b07c2f3c..3bee9ef3 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -1168,6 +1168,7 @@ class Tag { */ public static function resolve_alias($tag) { assert('is_string($tag)'); + global $database; $negative = false; if(!empty($tag) && ($tag[0] == '-')) { @@ -1175,14 +1176,18 @@ class Tag { $tag = substr($tag, 1); } - global $database; + $newtag = $database->get_one( $database->scoreql_to_sql("SELECT newtag FROM aliases WHERE SCORE_STRNORM(oldtag)=SCORE_STRNORM(:tag)"), - array("tag"=>$tag)); + array("tag"=>$tag) + ); + if(empty($newtag)) { + //tag has no alias, use old tag $newtag = $tag; } - return $negative ? "-$newtag" : $newtag; + + return !$negative ? $newtag : preg_replace("/(\S+)/", "-$1", $newtag); } /**