From 2bd588045a230ff3dc43f51ef700d23643c772ac Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 3 Jul 2024 14:55:33 +0200 Subject: [PATCH] PHP/Compat * remove sources of deprecation warnings. Mostly dynamic creation of object properties. * some string function no longer accept null as string --- includes/libs/DbSimple/Database.php | 2 +- includes/types/areatrigger.class.php | 7 +-- includes/types/arenateam.class.php | 2 + includes/types/guide.class.php | 7 +-- includes/types/guild.class.php | 2 + includes/types/profile.class.php | 4 +- pages/areatrigger.php | 2 - pages/genericPage.class.php | 59 ++++++++++++------------ pages/guide.php | 3 -- pages/more.php | 1 - pages/sound.php | 2 - template/pages/list-page-generic.tpl.php | 2 +- 12 files changed, 46 insertions(+), 47 deletions(-) diff --git a/includes/libs/DbSimple/Database.php b/includes/libs/DbSimple/Database.php index ee861d88..d6a6a5bf 100644 --- a/includes/libs/DbSimple/Database.php +++ b/includes/libs/DbSimple/Database.php @@ -1144,7 +1144,7 @@ abstract class DbSimple_Database extends DbSimple_LastError $len = 0; $values = array(); foreach ($rows[0] as $k=>$v) { - $len += strlen($v); + $len += strlen($v ?? ''); if ($len > $this->MAX_LOG_ROW_LEN) { break; } diff --git a/includes/types/areatrigger.class.php b/includes/types/areatrigger.class.php index 4334204b..5b309b91 100644 --- a/includes/types/areatrigger.class.php +++ b/includes/types/areatrigger.class.php @@ -8,9 +8,10 @@ class AreaTriggerList extends BaseType { use spawnHelper; - public static $type = Type::AREATRIGGER; - public static $brickFile = 'areatrigger'; - public static $dataTable = '?_areatrigger'; + public static $type = Type::AREATRIGGER; + public static $brickFile = 'areatrigger'; + public static $dataTable = '?_areatrigger'; + public static $contribute = CONTRIBUTE_CO; protected $queryBase = 'SELECT a.*, a.id AS ARRAY_KEY FROM ?_areatrigger a'; protected $queryOpts = array( diff --git a/includes/types/arenateam.class.php b/includes/types/arenateam.class.php index bc38abb4..90b4a0b7 100644 --- a/includes/types/arenateam.class.php +++ b/includes/types/arenateam.class.php @@ -10,6 +10,8 @@ class ArenaTeamList extends BaseType private $rankOrder = []; + public static $contribute = CONTRIBUTE_NONE; + public function getListviewData() { $data = []; diff --git a/includes/types/guide.class.php b/includes/types/guide.class.php index 5f98d13b..b5980b97 100644 --- a/includes/types/guide.class.php +++ b/includes/types/guide.class.php @@ -16,9 +16,10 @@ class GuideList extends BaseType GUIDE_STATUS_ARCHIVED => '#FFD100' ); - public static $type = Type::GUIDE; - public static $brickFile = 'guide'; - public static $dataTable = '?_guides'; + public static $type = Type::GUIDE; + public static $brickFile = 'guide'; + public static $dataTable = '?_guides'; + public static $contribute = CONTRIBUTE_CO; private $article = []; private $jsGlobals = []; diff --git a/includes/types/guild.class.php b/includes/types/guild.class.php index 5f65f5a7..a24f2806 100644 --- a/includes/types/guild.class.php +++ b/includes/types/guild.class.php @@ -8,6 +8,8 @@ class GuildList extends BaseType { use profilerHelper, listviewHelper; + public static $contribute = CONTRIBUTE_NONE; + public function getListviewData() { $this->getGuildScores(); diff --git a/includes/types/profile.class.php b/includes/types/profile.class.php index 165d2dd8..f1771bd5 100644 --- a/includes/types/profile.class.php +++ b/includes/types/profile.class.php @@ -8,6 +8,8 @@ class ProfileList extends BaseType { use profilerHelper, listviewHelper; + public static $contribute = CONTRIBUTE_NONE; + public function getListviewData($addInfo = 0, array $reqCols = []) { $data = []; @@ -35,7 +37,7 @@ class ProfileList extends BaseType 'talenttree3' => $this->getField('talenttree3'), 'talentspec' => $this->getField('activespec') + 1, // 0 => 1; 1 => 2 'achievementpoints' => $this->getField('achievementpoints'), - 'guild' => '$"'.str_replace ('"', '', $this->curTpl['guildname']).'"',// force this to be a string + 'guild' => $this->curTpl['guildname'] ? '$"'.str_replace ('"', '', $this->curTpl['guildname']).'"' : '', // force this to be a string 'guildrank' => $this->getField('guildrank'), 'realm' => Profiler::urlize($this->getField('realmName'), true), 'realmname' => $this->getField('realmName'), diff --git a/pages/areatrigger.php b/pages/areatrigger.php index 73bb9fc3..a845a428 100644 --- a/pages/areatrigger.php +++ b/pages/areatrigger.php @@ -20,8 +20,6 @@ class AreaTriggerPage extends GenericPage public function __construct($pageCall, $id) { - $this->contribute = CONTRIBUTE_NONE; - parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index faf465e9..b308fc2e 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -22,13 +22,9 @@ trait TrDetailPage protected $redButtons = []; // see template/redButtons.tpl.php protected $smartAI = null; protected $map = null; - protected $article = null; protected $headIcons = []; protected $expansion = EXP_CLASSIC; - - protected $contribute = CONTRIBUTE_ANY; - protected function generateCacheKey(bool $withStaff = true) : string { $staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE)); @@ -149,7 +145,6 @@ trait TrProfiler { $this->prepareContent(); - $this->contribute = CONTRIBUTE_NONE; $this->notFound = array( 'title' => sprintf(Lang::profiler('firstUseTitle'), $this->subjectName, $this->realm), 'msg' => '' @@ -187,7 +182,7 @@ class GenericPage protected $reqUGroup = U_GROUP_NONE; protected $reqAuth = false; protected $mode = CACHE_TYPE_NONE; - // protected $contribute; // defined in __construct() + protected $contribute = CONTRIBUTE_NONE; protected $wowheadLink = 'https://wowhead.com/'; @@ -197,6 +192,12 @@ class GenericPage protected $name = ''; // for h1-Element protected $tabId = null; protected $gDataKey = false; // adds the dataKey to the user vars + protected $notFound = []; + protected $pageTemplate = []; + protected $article = null; + protected $articleUrl = ''; + protected $editAccess = null; // 0 is valid access value, so null + protected $scripts = array( [SC_JS_FILE, 'js/jquery-3.7.0.min.js', SC_FLAG_NO_TIMESTAMP ], [SC_JS_FILE, 'js/basic.js' ], @@ -212,23 +213,24 @@ class GenericPage ); // private vars don't get cached - private $time = 0; - private $cacheDir = 'cache/template/'; - private $jsgBuffer = []; - private $gPageInfo = []; - private $gUser = []; - private $pageTemplate = []; - private $community = ['co' => [], 'sc' => [], 'vi' => []]; + private $time = 0; + private $cacheDir = 'cache/template/'; + private $jsgBuffer = []; + private $gPageInfo = []; + private $gUser = []; + private $gFavorites = []; + private $community = ['co' => [], 'sc' => [], 'vi' => []]; + private $announcements = []; - private $cacheLoaded = []; - private $skipCache = 0x0; - private $memcached = null; - private $mysql = ['time' => 0, 'count' => 0]; + private $cacheLoaded = []; + private $skipCache = 0x0; + private $memcached = null; + private $mysql = ['time' => 0, 'count' => 0]; - private $js = []; - private $css = []; - private $headerLogo = ''; - private $fullParams = ''; + private $js = []; + private $css = []; + private $headerLogo = ''; + private $fullParams = ''; private $lvTemplates = array( 'achievement' => ['template' => 'achievement', 'id' => 'achievements', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_achievements' ], @@ -274,9 +276,6 @@ class GenericPage $this->title[] = Cfg::get('NAME'); - if (!isset($this->contribute)) - $this->contribute = CONTRIBUTE_NONE; - $this->fullParams = $pageCall; if ($pageParam) $this->fullParams .= '='.$pageParam; @@ -439,7 +438,7 @@ class GenericPage { $this->gPageInfo = array( 'articleUrl' => $this->fullParams, // is actually be the url-param - 'editAccess' => isset($this->editAccess) ? $this->editAccess : (U_GROUP_ADMIN | U_GROUP_EDITOR | U_GROUP_BUREAU) + 'editAccess' => $this->editAccess ?? (U_GROUP_ADMIN | U_GROUP_EDITOR | U_GROUP_BUREAU) ); } @@ -453,7 +452,7 @@ class GenericPage $this->postCache(); // determine contribute tabs - if (isset($this->subject) && !isset($this->contribute)) + if (isset($this->subject)) { $x = get_class($this->subject); $this->contribute = $x::$contribute; @@ -469,7 +468,7 @@ class GenericPage $this->community['vi'] = CommunityContent::getVideos($this->type, $this->typeId); // as comments are not cached, those globals cant be either - if ($this->contribute) + if ($this->contribute != CONTRIBUTE_NONE) { $this->extendGlobalData(CommunityContent::getJSGlobals()); $this->applyGlobals(); @@ -716,12 +715,12 @@ class GenericPage // unknown page public function error() : void { - $this->path = null; - $this->tabId = null; + // $this->path = null; + // $this->tabId = null; $this->articleUrl = 'page-not-found'; $this->title[] = Lang::main('errPageTitle'); $this->name = Lang::main('errPageTitle'); - $this->lvTabs = []; + // $this->lvTabs = []; $this->addArticle(); diff --git a/pages/guide.php b/pages/guide.php index 887fd1c1..070d9708 100644 --- a/pages/guide.php +++ b/pages/guide.php @@ -30,7 +30,6 @@ class GuidePage extends GenericPage protected /* string */ $author = ''; protected /* array */ $gPageInfo = []; protected /* int */ $show = self::SHOW_GUIDE; - protected /* int */ $articleUrl = ''; private /* array */ $validCats = [1, 2, 3, 4, 5, 6, 7, 8, 9]; private /* string */ $extra = ''; @@ -59,8 +58,6 @@ class GuidePage extends GenericPage public function __construct($pageCall, $pageParam) { - $this->contribute = CONTRIBUTE_CO; - $guide = explode( "&", $pageParam, 2); parent::__construct($pageCall, $pageParam); diff --git a/pages/more.php b/pages/more.php index 61943f11..a5538d49 100644 --- a/pages/more.php +++ b/pages/more.php @@ -10,7 +10,6 @@ if (!defined('AOWOW_REVISION')) class MorePage extends GenericPage { - protected $articleUrl = ''; protected $tabsTitle = ''; protected $privReqPoints = ''; protected $forceTabs = true; diff --git a/pages/sound.php b/pages/sound.php index 9c0ddd05..5721b106 100644 --- a/pages/sound.php +++ b/pages/sound.php @@ -10,8 +10,6 @@ class SoundPage extends GenericPage { use TrDetailPage; - protected $articleUrl = ''; - protected $type = Type::SOUND; protected $typeId = 0; protected $tpl = 'sound'; diff --git a/template/pages/list-page-generic.tpl.php b/template/pages/list-page-generic.tpl.php index c5ed3d8e..80158f57 100644 --- a/template/pages/list-page-generic.tpl.php +++ b/template/pages/list-page-generic.tpl.php @@ -9,7 +9,7 @@ $this->brick('pageTemplate'); - if (isset($this->notFound)): + if ($this->notFound): ?>