From ea3c37e410f805440722f633a1d9cc1735215a33 Mon Sep 17 00:00:00 2001 From: Marcin Gil Date: Wed, 13 Mar 2024 15:36:06 +0100 Subject: [PATCH] Fixes "Creation of dynamic property Zend_Controller_Action::$ajaxable is deprecated" --- .../library/Zend/Controller/Action.php | 6 +++++ .../Action/Helper/AjaxContextTest.php | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/packages/zend-controller/library/Zend/Controller/Action.php b/packages/zend-controller/library/Zend/Controller/Action.php index a7b4b953a..099b03b2d 100644 --- a/packages/zend-controller/library/Zend/Controller/Action.php +++ b/packages/zend-controller/library/Zend/Controller/Action.php @@ -103,6 +103,12 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interfac * @var array */ public $contexts; + + /** + * Controller's ajaxable, managed by Zend_Controller_Action_Helper_AjaxContext + * @var array + */ + public $ajaxable; /** * Class constructor diff --git a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php index 57d628825..1f2bfa6e6 100644 --- a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php +++ b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php @@ -159,6 +159,25 @@ public function tearDown() unset($_SERVER['HTTP_X_REQUESTED_WITH']); } } + + public function testAddActionContext() + { + // test covering PHP 8.2+ changes: + // Creation of dynamic property ::$ajaxable is deprecated + $controller = new Zend_Controller_Action_Helper_AjaxContextNoConfigTestController( + $this->request, + $this->response, + array() + ); + $this->helper->setActionController($controller); + + $this->helper + ->addActionContext('error', 'html') + ->initContext('html'); + + $actionContexts = $this->helper->getActionContexts('error'); + $this->assertEquals('html', $actionContexts[0]); + } public function testDefaultContextsIncludesHtml() { @@ -293,6 +312,10 @@ class Zend_Controller_Action_Helper_AjaxContextTestController extends Zend_Contr ); } +class Zend_Controller_Action_Helper_AjaxContextNoConfigTestController extends Zend_Controller_Action +{ +} + class Zend_Controller_Action_Helper_AjaxContextTest_LayoutOverride extends Zend_Layout { public static function resetMvcInstance()