N°3129 PHP 8.0 compat: Fix "Deprecated: Required parameter ... follows optional parameter ..."

* \SQLObjectQuery::PrepareSingleTable
* \HistoryBlock::GetRenderContent
* \MenuBlock::GetRenderContent
* \UILinksWidgetDirect::DisplayAsBlock
* \UILinksWidgetDirect::Display
* \UILinksWidgetDirect::DisplayEditInPlace
* \UIExtKeyWidget::AutoComplete
* \UIExtKeyWidget::DisplayFromAttCode
This commit is contained in:
Pierre Goiffon
2022-01-28 14:57:43 +01:00
parent 3381c085f4
commit 75dbad7406
4 changed files with 58 additions and 9 deletions

View File

@@ -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';

View File

@@ -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))
{

View File

@@ -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();

View File

@@ -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);