From dcfb090053265f654fe1da58c1a3a979e2178c12 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 16 Jan 2018 14:23:19 +0100 Subject: [PATCH] Fix getCBPTableNames function calls --- Changelog | 1 + app/Models/Group.php | 20 +++++++++++++++++--- nntmux/Binaries.php | 8 ++++---- nntmux/Regexes.php | 2 +- nntmux/processing/ProcessReleases.php | 5 ++--- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Changelog b/Changelog index 784694319..575eec206 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-01-16 DariusIII + * Fix: Fix getCBPTableNames function calls * Fix: Fix call to Releases * Chg: Use Group model and remove nntmux\Groups class * Chg: Update Books class processBookReleases function diff --git a/app/Models/Group.php b/app/Models/Group.php index ac03a687a..35d5898c0 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -41,8 +41,22 @@ class Group extends Model /** * @var bool */ - protected static $allasmgr = (int) Settings::settingValue('..allasmgr') === 1; + protected $allasmgr; + /** + * Group constructor. + * + * @throws \Exception + */ + public function __construct() + { + parent::__construct(); + $this->allasmgr = (int) Settings::settingValue('..allasmgr') === 1; + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function release() { return $this->hasMany(Release::class, 'groups_id'); @@ -486,7 +500,7 @@ class Group extends Model * @return array The table names. * @throws \Exception */ - public static function getCBPTableNames($groupID): array + public function getCBPTableNames($groupID): array { $groupKey = $groupID; @@ -495,7 +509,7 @@ class Group extends Model return self::$cbppTableNames[$groupKey]; } - if (NN_ECHOCLI && self::$allasmgr === false && self::createNewTPGTables($groupID) === false) { + if (NN_ECHOCLI && $this->allasmgr === false && self::createNewTPGTables($groupID) === false) { exit('There is a problem creating new TPG tables for this group ID: '.$groupID.PHP_EOL); } diff --git a/nntmux/Binaries.php b/nntmux/Binaries.php index cd6e4ee68..35a7fd8f8 100755 --- a/nntmux/Binaries.php +++ b/nntmux/Binaries.php @@ -593,7 +593,7 @@ class Binaries $this->notYEnc = $this->headersBlackListed = 0; // Check if MySQL tables exist, create if they do not, get their names at the same time. - $this->tableNames = Group::getCBPTableNames($this->groupMySQL['id']); + $this->tableNames = (new Group())->getCBPTableNames($this->groupMySQL['id']); $mgrPosters = $this->getMultiGroupPosters(); @@ -761,7 +761,7 @@ class Binaries // Standard headers go second so we can switch tableNames back and do part repair to standard group tables if (! empty($stdHeaders)) { - $this->tableNames = Group::getCBPTableNames($this->groupMySQL['id']); + $this->tableNames = (new Group())->getCBPTableNames($this->groupMySQL['id']); $this->storeHeaders($stdHeaders, false); } unset($stdHeaders); @@ -1126,7 +1126,7 @@ class Binaries $tableNames = $tables; if ($tableNames === '') { - $tableNames = Group::getCBPTableNames($groupArr['id']); + $tableNames = (new Group())->getCBPTableNames($groupArr['id']); } // Get all parts in partrepair table. $missingParts = $this->_pdo->query( @@ -1267,7 +1267,7 @@ class Binaries $groupID = Group::getIDByName($groupData['group']); $group = []; if ($groupID !== '') { - $group = Group::getCBPTableNames($groupID); + $group = (new Group())->getCBPTableNames($groupID); } $currentPost = $post; diff --git a/nntmux/Regexes.php b/nntmux/Regexes.php index b0ff8d0a4..2d2d1af6f 100755 --- a/nntmux/Regexes.php +++ b/nntmux/Regexes.php @@ -183,7 +183,7 @@ class Regexes return []; } - $tableNames = Group::getCBPTableNames($groupID); + $tableNames = (new Group())->getCBPTableNames($groupID); $rows = $this->pdo->query( sprintf( diff --git a/nntmux/processing/ProcessReleases.php b/nntmux/processing/ProcessReleases.php index eec377078..d1378b125 100755 --- a/nntmux/processing/ProcessReleases.php +++ b/nntmux/processing/ProcessReleases.php @@ -493,12 +493,11 @@ class ProcessReleases /** * @param $groupID - * - * @void + * @throws \Exception */ protected function initiateTableNames($groupID): void { - $this->tables = Group::getCBPTableNames($groupID); + $this->tables = (new Group())->getCBPTableNames($groupID); } /**