From 1768274aaff3ca34bc25d6c009356b525a8faaeb Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 2 Feb 2023 16:59:54 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05943=20-=20Fix=20undefined=20array=20key?= =?UTF-8?q?=20"Remote"=20in=20AjaxRenderController.php=20with=20DokuWiki?= =?UTF-8?q?=20extension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/log.class.inc.php | 14 ++++++++++++-- sources/Controller/AjaxRenderController.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/core/log.class.inc.php b/core/log.class.inc.php index 07d88fbe4..7314202f6 100644 --- a/core/log.class.inc.php +++ b/core/log.class.inc.php @@ -570,6 +570,12 @@ class LogChannels public const CORE = 'core'; + /** + * @var string Everything related to the datatable component + * @since 3.1.0 + */ + public const DATATABLE = 'Datatable'; + public const DEADLOCK = 'DeadLock'; public const INLINE_IMAGE = 'InlineImage'; @@ -577,11 +583,15 @@ class LogChannels public const PORTAL = 'portal'; /** - * @var string - * @since 3.1.0 specific channel for event service + * @var string Everything related to the event service + * @since 3.1.0 */ public const EVENT_SERVICE = 'EventService'; + /** + * @var string Everything related to the datamodel CRUD + * @since 3.1.0 + */ public const DM_CRUD = 'DMCRUD'; } diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index 9ceb061b9..c44005314 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -29,9 +29,11 @@ use ExecutionKPI; use Expression; use FieldExpression; use FunctionExpression; +use IssueLog; use iTopExtension; use iTopExtensionsMap; use JsonPage; +use LogChannels; use MetaModel; use ormSet; use RunTimeEnvironment; @@ -78,6 +80,18 @@ class AjaxRenderController $aObj[$sAlias."/_key_"] = $aObject[$sAlias]->GetKey(); $aObj[$sAlias."/_key_/raw"] = $aObject[$sAlias]->GetKey(); $aObj[$sAlias."/hyperlink"] = $aObject[$sAlias]->GetHyperlink(); + + // N°5943 Protection against $aColumnsLoad having less class aliases than $aClassAliases, this is in case the method's consumer isn't passing data correctly + if (false === array_key_exists($sAlias, $aColumnsLoad)) { + IssueLog::Debug("Datatable: Attribute omitted as it was in \$aClassAliases but not among the loaded attributes (\$aColumnsLoad)", LogChannels::DATATABLE, [ + 'sClass' => $sClass, + 'sAlias' => $sAlias, + 'aClassAliases' => $aClassAliases, + 'aColumnsLoad' => $aColumnsLoad, + ]); + continue; + } + foreach ($aColumnsLoad[$sAlias] as $sAttCode) { $aObj[$sAlias."/".$sAttCode] = $aObject[$sAlias]->GetAsHTML($sAttCode); $bExcludeRawValue = false;