Răsfoiți Sursa

Comments API: build embed from the comment text, not an undefined variable (#5755)

_getStructureAPI passed $aData['cmt_text'] to bx_linkify_embeded() while
$aData was still being assigned, so it was always null. Comment link
embeds were never produced, and PHP 8.x raised a preg_match_all()
'Passing null' deprecation on every comment rendered through the API.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 2 săptămâni în urmă
părinte
comite
ca433764dc
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      inc/classes/BxDolCmts.php

+ 3 - 2
inc/classes/BxDolCmts.php

@@ -2600,8 +2600,9 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
             }
 
             bx_import('BxDolEmbed');
-            $aData = $this->getDataAPI(array_merge($this->getCommentSimple($iCmtId), [
-                'embed' => bx_linkify_embeded($aData['cmt_text']),
+            $aCmt = $this->getCommentSimple($iCmtId);
+            $aData = $this->getDataAPI(array_merge($aCmt, [
+                'embed' => bx_linkify_embeded($aCmt['cmt_text'] ?? ''),
                 'menu_actions' => $aMenuActions,
                 'menu_manage' => $aMenuManage,
             ]));