Use PreparedStatement::fetchObject() in Tag::getTag()
authorMatthias Schmidt <gravatronics@live.com>
Sun, 7 Aug 2016 11:45:57 +0000 (13:45 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 7 Aug 2016 11:45:57 +0000 (13:45 +0200)
wcfsetup/install/files/lib/data/tag/Tag.class.php

index 9cc4ad169f3df6fea6e2cfdf99e1626e2641bde0..f580b9b0bc7eaa355ac6a5d20c134698d81357fd 100644 (file)
@@ -24,7 +24,7 @@ class Tag extends DatabaseObject implements IRouteController {
         * 
         * @param       string          $name
         * @param       integer         $languageID
-        * @return      mixed
+        * @return      Tag|null
         */
        public static function getTag($name, $languageID = 0) {
                $sql = "SELECT  *
@@ -33,10 +33,8 @@ class Tag extends DatabaseObject implements IRouteController {
                                AND name = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$languageID, $name]);
-               $row = $statement->fetchArray();
-               if ($row !== false) return new Tag(null, $row);
                
-               return null;
+               return $statement->fetchObject(Tag::class);
        }
        
        /**