From 7f4159ac258c501f9666efc465a78cb2aec9d177 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Mon, 21 Sep 2020 21:21:30 +0200 Subject: Code cleanup - Remove unused variables - Remove unused utility functions - Asserting presence and typehinting global variables - Remove unused variables - Add missing global - Add parameter type constraint - Fix some references to nonexisting variables --- ratatoeskr/sys/models.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'ratatoeskr/sys/models.php') diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index 626b237..9f81fcf 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -278,10 +278,9 @@ class User extends BySQLRowEnabled */ public static function create($username, $pwhash) { - global $ratatoeskr_settings; global $db_con; try { - $obj = self::by_name($username); + self::by_name($username); } catch (DoesNotExistError $e) { global $ratatoeskr_settings; qdb( @@ -301,7 +300,7 @@ class User extends BySQLRowEnabled return $obj; } - throw new AlreadyExistsError("\"$name\" is already in database."); + throw new AlreadyExistsError("\"$username\" is already in database."); } protected function populate_by_sqlrow($sqlrow) @@ -504,7 +503,7 @@ class Group extends BySQLRowEnabled { global $db_con; try { - $obj = self::by_name($name); + self::by_name($name); } catch (DoesNotExistError $e) { qdb("INSERT INTO `PREFIX_groups` (`name`) VALUES (?)", $name); $obj = new self(); @@ -1787,7 +1786,7 @@ class Section extends BySQLRowEnabled } try { - $obj = self::by_name($name); + self::by_name($name); } catch (DoesNotExistError $e) { $obj = new self(); $obj->name = $name; @@ -2056,7 +2055,7 @@ class Tag extends BySQLRowEnabled } try { - $obj = self::by_name($name); + self::by_name($name); } catch (DoesNotExistError $e) { $obj = new self(); @@ -2634,7 +2633,7 @@ class Repository extends BySQLRowEnabled $this->name = $repometa["name"]; $this->description = $repometa["description"]; - $this->packages = @unserialize(@file_get_contents($this->baseurl . "/packagelist", false, $ctx)); + $this->packages = @unserialize(@file_get_contents($this->baseurl . "/packagelist", false, $this->stream_ctx)); $this->lastrefresh = time(); @@ -3259,6 +3258,8 @@ class ArticleExtradata extends KVStorage */ function dbversion() { + global $config; + /* Is the meta table present? If no, the version is 0. */ $stmt = qdb( "SELECT COUNT(*) FROM `information_schema`.`tables` WHERE `table_schema` = ? AND `table_name` = ?", -- cgit v1.2.3-70-g09d2