From 75dbad7406acb62fa3064a2113b79e7bfc449153 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 14:57:43 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat:=20Fix=20"Depr?= =?UTF-8?q?ecated:=20=20Required=20parameter=20...=20follows=20optional=20?= =?UTF-8?q?parameter=20..."=20*=20\SQLObjectQuery::PrepareSingleTable=20*?= =?UTF-8?q?=20\HistoryBlock::GetRenderContent=20*=20\MenuBlock::GetRenderC?= =?UTF-8?q?ontent=20*=20\UILinksWidgetDirect::DisplayAsBlock=20*=20\UILink?= =?UTF-8?q?sWidgetDirect::Display=20*=20\UILinksWidgetDirect::DisplayEditI?= =?UTF-8?q?nPlace=20*=20\UIExtKeyWidget::AutoComplete=20*=20\UIExtKeyWidge?= =?UTF-8?q?t::DisplayFromAttCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/displayblock.class.inc.php | 28 +++++++++++++++++-- application/ui.extkeywidget.class.inc.php | 10 +++++-- .../ui.linksdirectwidget.class.inc.php | 16 +++++++++-- core/sqlobjectquery.class.inc.php | 13 ++++++++- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 9a21f9db7..c27996848 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -1418,8 +1418,24 @@ class HistoryBlock extends DisplayBlock $this->iLimitStart = $iStart; $this->iLimitCount = $iCount; } - - public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) + + /** + * @param \WebPage $oPage + * @param array $aExtraParams + * @param string $sId + * + * @return string + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \DictExceptionMissingString + * @throws \MissingQueryArgument + * @throws \MySQLException + * @throws \MySQLHasGoneAwayException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (var is unused, and all calls were already made using a default value) + */ + public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) { $sHtml = ''; $bTruncated = false; @@ -1558,9 +1574,15 @@ class MenuBlock extends DisplayBlock * @throws \Exception * @throws \MissingQueryArgument * @throws \MySQLException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (added a test at function start to handle wrong values) */ - public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) + public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) { + if (empty($aExtraParams)) { + $aExtraParams = []; + } + if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility { $this->m_sStyle = 'list'; diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 121c91a7b..465f53c03 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -71,7 +71,11 @@ class UIExtKeyWidget protected $bSearchMode; //public function __construct($sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sNameSuffix = '', $sFieldPrefix = '', $sFormPrefix = '') - static public function DisplayFromAttCode($oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs, $bSearchMode = false) + + /** + * @since 2.7.7 3.0.1 3.1.0 N°3129 Add default value for $aArgs for PHP 8.0 compat + */ + public static function DisplayFromAttCode($oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs = [], $bSearchMode = false) { $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); $sTargetClass = $oAttDef->GetTargetClass(); @@ -426,8 +430,10 @@ EOF * * @throws CoreException * @throws OQLException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility (a null default value is awkward ?!??) */ - public function AutoComplete(WebPage $oP, $sFilter, $oObj = null, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) + public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) { if (is_null($sFilter)) { diff --git a/application/ui.linksdirectwidget.class.inc.php b/application/ui.linksdirectwidget.class.inc.php index 1fb41501b..e99a74898 100644 --- a/application/ui.linksdirectwidget.class.inc.php +++ b/application/ui.linksdirectwidget.class.inc.php @@ -85,9 +85,15 @@ class UILinksWidgetDirect * @param array $aArgs * @param string $sFormPrefix * @param DBObject $oCurrentObj + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (handling wrong values at method start) */ - public function Display(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj) + public function Display(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj) { + if (empty($aArgs)) { + $aArgs = []; + } + $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); switch($oLinksetDef->GetEditMode()) { @@ -137,8 +143,10 @@ class UILinksWidgetDirect * @param string $sFormPrefix * @param DBObject $oCurrentObj * @param bool $bDisplayMenu + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (protected method, always called with default value) */ - protected function DisplayAsBlock(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $bDisplayMenu) + protected function DisplayAsBlock(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $bDisplayMenu) { $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); $sTargetClass = $oLinksetDef->GetLinkedClass(); @@ -239,8 +247,10 @@ class UILinksWidgetDirect * @param string $sFormPrefix * @param DBObject $oCurrentObj * @param array $aButtons + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (protected method, caller already handles it) */ - protected function DisplayEditInPlace(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $aButtons = array('create', 'delete')) + protected function DisplayEditInPlace(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $aButtons = array('create', 'delete')) { $aAttribs = $this->GetTableConfig(); diff --git a/core/sqlobjectquery.class.inc.php b/core/sqlobjectquery.class.inc.php index d7a59fcbb..8ce9a0ff2 100644 --- a/core/sqlobjectquery.class.inc.php +++ b/core/sqlobjectquery.class.inc.php @@ -491,7 +491,17 @@ class SQLObjectQuery extends SQLQuery } } - private function PrepareSingleTable(SQLObjectQuery $oRootQuery, &$aFrom, $sCallerAlias = '', $aJoinData) + /** + * @param \SQLObjectQuery $oRootQuery + * @param $aFrom + * @param $sCallerAlias + * @param $aJoinData + * + * @return string + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $sCallerAlias for PHP 8.0 compat (Private method with only 2 calls in the class, both providing the optional parameter) + */ + private function PrepareSingleTable(SQLObjectQuery $oRootQuery, &$aFrom, $sCallerAlias, $aJoinData) { $aTranslationTable[$this->m_sTable]['*'] = $this->m_sTableAlias; $sJoinCond = ''; @@ -610,6 +620,7 @@ class SQLObjectQuery extends SQLQuery $aTempFrom = array(); // temporary subset of 'from' specs, to be grouped in the final query foreach ($this->m_aJoinSelects as $aJoinData) { + /** @var \SQLObjectQuery $oRightSelect */ $oRightSelect = $aJoinData["select"]; $oRightSelect->PrepareSingleTable($oRootQuery, $aTempFrom, $this->m_sTableAlias, $aJoinData);