PHP/Compat

* remove sources of deprecation warnings. Mostly dynamic creation of object properties.
 * some string function no longer accept null as string
This commit is contained in:
Sarjuuk
2024-07-03 14:55:33 +02:00
parent 05c036bd9f
commit 2bd588045a
12 changed files with 46 additions and 47 deletions

View File

@@ -1144,7 +1144,7 @@ abstract class DbSimple_Database extends DbSimple_LastError
$len = 0; $len = 0;
$values = array(); $values = array();
foreach ($rows[0] as $k=>$v) { foreach ($rows[0] as $k=>$v) {
$len += strlen($v); $len += strlen($v ?? '');
if ($len > $this->MAX_LOG_ROW_LEN) { if ($len > $this->MAX_LOG_ROW_LEN) {
break; break;
} }

View File

@@ -8,9 +8,10 @@ class AreaTriggerList extends BaseType
{ {
use spawnHelper; use spawnHelper;
public static $type = Type::AREATRIGGER; public static $type = Type::AREATRIGGER;
public static $brickFile = 'areatrigger'; public static $brickFile = 'areatrigger';
public static $dataTable = '?_areatrigger'; public static $dataTable = '?_areatrigger';
public static $contribute = CONTRIBUTE_CO;
protected $queryBase = 'SELECT a.*, a.id AS ARRAY_KEY FROM ?_areatrigger a'; protected $queryBase = 'SELECT a.*, a.id AS ARRAY_KEY FROM ?_areatrigger a';
protected $queryOpts = array( protected $queryOpts = array(

View File

@@ -10,6 +10,8 @@ class ArenaTeamList extends BaseType
private $rankOrder = []; private $rankOrder = [];
public static $contribute = CONTRIBUTE_NONE;
public function getListviewData() public function getListviewData()
{ {
$data = []; $data = [];

View File

@@ -16,9 +16,10 @@ class GuideList extends BaseType
GUIDE_STATUS_ARCHIVED => '#FFD100' GUIDE_STATUS_ARCHIVED => '#FFD100'
); );
public static $type = Type::GUIDE; public static $type = Type::GUIDE;
public static $brickFile = 'guide'; public static $brickFile = 'guide';
public static $dataTable = '?_guides'; public static $dataTable = '?_guides';
public static $contribute = CONTRIBUTE_CO;
private $article = []; private $article = [];
private $jsGlobals = []; private $jsGlobals = [];

View File

@@ -8,6 +8,8 @@ class GuildList extends BaseType
{ {
use profilerHelper, listviewHelper; use profilerHelper, listviewHelper;
public static $contribute = CONTRIBUTE_NONE;
public function getListviewData() public function getListviewData()
{ {
$this->getGuildScores(); $this->getGuildScores();

View File

@@ -8,6 +8,8 @@ class ProfileList extends BaseType
{ {
use profilerHelper, listviewHelper; use profilerHelper, listviewHelper;
public static $contribute = CONTRIBUTE_NONE;
public function getListviewData($addInfo = 0, array $reqCols = []) public function getListviewData($addInfo = 0, array $reqCols = [])
{ {
$data = []; $data = [];
@@ -35,7 +37,7 @@ class ProfileList extends BaseType
'talenttree3' => $this->getField('talenttree3'), 'talenttree3' => $this->getField('talenttree3'),
'talentspec' => $this->getField('activespec') + 1, // 0 => 1; 1 => 2 'talentspec' => $this->getField('activespec') + 1, // 0 => 1; 1 => 2
'achievementpoints' => $this->getField('achievementpoints'), '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'), 'guildrank' => $this->getField('guildrank'),
'realm' => Profiler::urlize($this->getField('realmName'), true), 'realm' => Profiler::urlize($this->getField('realmName'), true),
'realmname' => $this->getField('realmName'), 'realmname' => $this->getField('realmName'),

View File

@@ -20,8 +20,6 @@ class AreaTriggerPage extends GenericPage
public function __construct($pageCall, $id) public function __construct($pageCall, $id)
{ {
$this->contribute = CONTRIBUTE_NONE;
parent::__construct($pageCall, $id); parent::__construct($pageCall, $id);
$this->typeId = intVal($id); $this->typeId = intVal($id);

View File

@@ -22,13 +22,9 @@ trait TrDetailPage
protected $redButtons = []; // see template/redButtons.tpl.php protected $redButtons = []; // see template/redButtons.tpl.php
protected $smartAI = null; protected $smartAI = null;
protected $map = null; protected $map = null;
protected $article = null;
protected $headIcons = []; protected $headIcons = [];
protected $expansion = EXP_CLASSIC; protected $expansion = EXP_CLASSIC;
protected $contribute = CONTRIBUTE_ANY;
protected function generateCacheKey(bool $withStaff = true) : string protected function generateCacheKey(bool $withStaff = true) : string
{ {
$staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE)); $staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE));
@@ -149,7 +145,6 @@ trait TrProfiler
{ {
$this->prepareContent(); $this->prepareContent();
$this->contribute = CONTRIBUTE_NONE;
$this->notFound = array( $this->notFound = array(
'title' => sprintf(Lang::profiler('firstUseTitle'), $this->subjectName, $this->realm), 'title' => sprintf(Lang::profiler('firstUseTitle'), $this->subjectName, $this->realm),
'msg' => '' 'msg' => ''
@@ -187,7 +182,7 @@ class GenericPage
protected $reqUGroup = U_GROUP_NONE; protected $reqUGroup = U_GROUP_NONE;
protected $reqAuth = false; protected $reqAuth = false;
protected $mode = CACHE_TYPE_NONE; protected $mode = CACHE_TYPE_NONE;
// protected $contribute; // defined in __construct() protected $contribute = CONTRIBUTE_NONE;
protected $wowheadLink = 'https://wowhead.com/'; protected $wowheadLink = 'https://wowhead.com/';
@@ -197,6 +192,12 @@ class GenericPage
protected $name = ''; // for h1-Element protected $name = ''; // for h1-Element
protected $tabId = null; protected $tabId = null;
protected $gDataKey = false; // adds the dataKey to the user vars 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( protected $scripts = array(
[SC_JS_FILE, 'js/jquery-3.7.0.min.js', SC_FLAG_NO_TIMESTAMP ], [SC_JS_FILE, 'js/jquery-3.7.0.min.js', SC_FLAG_NO_TIMESTAMP ],
[SC_JS_FILE, 'js/basic.js' ], [SC_JS_FILE, 'js/basic.js' ],
@@ -212,23 +213,24 @@ class GenericPage
); );
// private vars don't get cached // private vars don't get cached
private $time = 0; private $time = 0;
private $cacheDir = 'cache/template/'; private $cacheDir = 'cache/template/';
private $jsgBuffer = []; private $jsgBuffer = [];
private $gPageInfo = []; private $gPageInfo = [];
private $gUser = []; private $gUser = [];
private $pageTemplate = []; private $gFavorites = [];
private $community = ['co' => [], 'sc' => [], 'vi' => []]; private $community = ['co' => [], 'sc' => [], 'vi' => []];
private $announcements = [];
private $cacheLoaded = []; private $cacheLoaded = [];
private $skipCache = 0x0; private $skipCache = 0x0;
private $memcached = null; private $memcached = null;
private $mysql = ['time' => 0, 'count' => 0]; private $mysql = ['time' => 0, 'count' => 0];
private $js = []; private $js = [];
private $css = []; private $css = [];
private $headerLogo = ''; private $headerLogo = '';
private $fullParams = ''; private $fullParams = '';
private $lvTemplates = array( private $lvTemplates = array(
'achievement' => ['template' => 'achievement', 'id' => 'achievements', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_achievements' ], 'achievement' => ['template' => 'achievement', 'id' => 'achievements', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_achievements' ],
@@ -274,9 +276,6 @@ class GenericPage
$this->title[] = Cfg::get('NAME'); $this->title[] = Cfg::get('NAME');
if (!isset($this->contribute))
$this->contribute = CONTRIBUTE_NONE;
$this->fullParams = $pageCall; $this->fullParams = $pageCall;
if ($pageParam) if ($pageParam)
$this->fullParams .= '='.$pageParam; $this->fullParams .= '='.$pageParam;
@@ -439,7 +438,7 @@ class GenericPage
{ {
$this->gPageInfo = array( $this->gPageInfo = array(
'articleUrl' => $this->fullParams, // is actually be the url-param '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(); $this->postCache();
// determine contribute tabs // determine contribute tabs
if (isset($this->subject) && !isset($this->contribute)) if (isset($this->subject))
{ {
$x = get_class($this->subject); $x = get_class($this->subject);
$this->contribute = $x::$contribute; $this->contribute = $x::$contribute;
@@ -469,7 +468,7 @@ class GenericPage
$this->community['vi'] = CommunityContent::getVideos($this->type, $this->typeId); $this->community['vi'] = CommunityContent::getVideos($this->type, $this->typeId);
// as comments are not cached, those globals cant be either // as comments are not cached, those globals cant be either
if ($this->contribute) if ($this->contribute != CONTRIBUTE_NONE)
{ {
$this->extendGlobalData(CommunityContent::getJSGlobals()); $this->extendGlobalData(CommunityContent::getJSGlobals());
$this->applyGlobals(); $this->applyGlobals();
@@ -716,12 +715,12 @@ class GenericPage
// unknown page // unknown page
public function error() : void public function error() : void
{ {
$this->path = null; // $this->path = null;
$this->tabId = null; // $this->tabId = null;
$this->articleUrl = 'page-not-found'; $this->articleUrl = 'page-not-found';
$this->title[] = Lang::main('errPageTitle'); $this->title[] = Lang::main('errPageTitle');
$this->name = Lang::main('errPageTitle'); $this->name = Lang::main('errPageTitle');
$this->lvTabs = []; // $this->lvTabs = [];
$this->addArticle(); $this->addArticle();

View File

@@ -30,7 +30,6 @@ class GuidePage extends GenericPage
protected /* string */ $author = ''; protected /* string */ $author = '';
protected /* array */ $gPageInfo = []; protected /* array */ $gPageInfo = [];
protected /* int */ $show = self::SHOW_GUIDE; protected /* int */ $show = self::SHOW_GUIDE;
protected /* int */ $articleUrl = '';
private /* array */ $validCats = [1, 2, 3, 4, 5, 6, 7, 8, 9]; private /* array */ $validCats = [1, 2, 3, 4, 5, 6, 7, 8, 9];
private /* string */ $extra = ''; private /* string */ $extra = '';
@@ -59,8 +58,6 @@ class GuidePage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
$this->contribute = CONTRIBUTE_CO;
$guide = explode( "&", $pageParam, 2); $guide = explode( "&", $pageParam, 2);
parent::__construct($pageCall, $pageParam); parent::__construct($pageCall, $pageParam);

View File

@@ -10,7 +10,6 @@ if (!defined('AOWOW_REVISION'))
class MorePage extends GenericPage class MorePage extends GenericPage
{ {
protected $articleUrl = '';
protected $tabsTitle = ''; protected $tabsTitle = '';
protected $privReqPoints = ''; protected $privReqPoints = '';
protected $forceTabs = true; protected $forceTabs = true;

View File

@@ -10,8 +10,6 @@ class SoundPage extends GenericPage
{ {
use TrDetailPage; use TrDetailPage;
protected $articleUrl = '';
protected $type = Type::SOUND; protected $type = Type::SOUND;
protected $typeId = 0; protected $typeId = 0;
protected $tpl = 'sound'; protected $tpl = 'sound';

View File

@@ -9,7 +9,7 @@
$this->brick('pageTemplate'); $this->brick('pageTemplate');
if (isset($this->notFound)): if ($this->notFound):
?> ?>
<div class="pad3"></div> <div class="pad3"></div>