Bug #7138

Changes to ObjectAccessor break usage with fluid conditions

Added by Falk Kühnel over 5 years ago. Updated almost 5 years ago.

Status:Rejected Start date:2010-04-06
Priority:Must have Due date:
Assigned To:- % Done:

0%

Category:Core
Target version:-
Has patch:No Affected Flow version:

Description

Since the Tx_Extbase_Reflection_ObjectAccess::getProperty has changed, conditions on Arrays dont work like they used to:

<f:if condition="{user.otheraddresses.0}">

will cause an Exception
#1263391473: The property "classes" on the subject was not accessible. 

if the array is empty.

I do not know, if this is intended behaviour. Should Fluid take care of this, or the Reflection class?
Also, any unset variables in an array, cause this error, instead of not being shown.

T3X_ux_extbasefluid_exceptiondemo-0_0_0-z-201004071653.t3x (6.9 kB) Falk Kühnel, 2010-04-07 16:56

extbase-fluid-missing-array-items.patch Magnifier (836 Bytes) Falk Kühnel, 2010-04-09 18:01

History

#1 Updated by Jochen Rau over 5 years ago

  • Category set to 431
  • Status changed from New to Needs Feedback
  • Assigned To set to Jochen Rau

I can't reproduce this behavior. Could you please provide further information about your setup?

#2 Updated by Falk Kühnel over 5 years ago

I am using Fluid with a pibase Extension.

The view is initialized like this:

    private function initializeView() {
        /* @var $this->view Tx_Fluid_View_TemplateView */
        $this->view = t3lib_div::makeInstance('Tx_Fluid_View_TemplateView');
        /* @var $controller Tx_Extbase_MVC_Controller_ControllerContext */
        $controller = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_ControllerContext');
        // 
        $this->flashMessages = t3lib_div::makeInstance('Tx_cogimemberindex_FlashMessages');
        $controller->setFlashMessages($this->flashMessages);
        $controller->setRequest(t3lib_div::makeInstance('Tx_Extbase_MVC_Request'));
        $controller->getRequest()->setControllerExtensionName($this->extKey);
        $controller->getRequest()->setFormat('html');
        $controller->setUriBuilder(t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Routing_UriBuilder'));

        $this->controller = $controller;
        if(is_array($this->sessionData['controllerErrors'])){
            $this->controller->getRequest()->setErrors($this->sessionData['controllerErrors']);
        }

        $this->view->setControllerContext($controller);
        $this->view->setTemplateRootPath(t3lib_extMgm::extPath($this->extKey).'/Resources/template');
        $this->view->setPartialRootPath(t3lib_extMgm::extPath($this->extKey).'/Resources/template/partials');
    }

Now, when i am rendering a view, the exception gets thrown when i use any undefined variable.

So calling

<f:if condition="{user.otheraddresses.0}">
...
</f:if>

on following variable

$this->view->assign('user', array ('otheraddresses' => array()));

Will throw the exception.

Same goes for any unset array part in an array.

I attached a sample extension, which throws an exception here on a current 4.4-dev installation

#3 Updated by Jochen Rau over 5 years ago

  • Status changed from Needs Feedback to Closed

Sorry, but this is out of bound of the "official" Extbase way. It might be a misconfiguration. I am not able to dig into this way deeper (lack of time) but have a look at

t3lib_extMgm::addPlugin(array(
    'LLL:EXT:ux_extbasefluid_exceptiondemo/locallang_db.xml:tt_content.list_type_pi1',
    $_EXTKEY . '_pi1',
    t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif'
),'list_type');

I close this issue for now.

Jochen

#4 Updated by Falk Kühnel over 5 years ago

Hi Jochen!

I do not understand your reply. What does that have to do with the problem at hand? I thought t3lib_extMgm::addPlugin is just for extbase extensions.
Calling the plugin that way will throw no error, since the view gets never rendered.

I have looked deeper into that issue and i do not know, who should be responsible. I made a patch for the Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode, but i am not satisfied with it, but this is mainly due to the reason, that the Exception that gets passed from Tx_Extbase_Reflection_ObjectAccess::getPropertyPath is a RuntimeException. That should probably be something more specific to inaccessible Object properties or array parts.

For not existent first level variables the Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode returns NULL, so i did the same in case of an exception.

Anyway, here is the patch.

Best regards
Falk

#5 Updated by Sebastian Kurfuerst over 5 years ago

  • Status changed from Closed to Accepted
  • Assigned To changed from Jochen Rau to Sebastian Kurfuerst
  • Priority changed from Should have to Must have

#6 Updated by Sebastian Kurfuerst about 5 years ago

  • Status changed from Accepted to New
  • Assigned To deleted (Sebastian Kurfuerst)

#7 Updated by Sebastian Kurfuerst about 5 years ago

  • Project changed from Extbase MVC Framework to TYPO3.Fluid
  • Category deleted (431)

#8 Updated by Sebastian Kurfuerst about 5 years ago

note to myself / whoever implements it: we definitely need Selenium Tests for the various ways object accessors can be used...

#9 Updated by Sebastian Kurfuerst about 4 years ago

  • Category set to Core
  • Target version set to 1.0 beta 1

Must be re-verified; and should have a testcase in Viewhelpertest.

#10 Updated by Sebastian Kurfuerst about 4 years ago

  • Parent task set to #26665
  • Has patch set to No

#11 Updated by Sebastian Kurfuerst about 4 years ago

  • Tracker changed from Task to Bug
  • Parent task deleted (#26665)

#12 Updated by Sebastian Kurfuerst almost 5 years ago

  • Status changed from New to Rejected
  • Target version deleted (1.0 beta 1)

rejecting because of missing feedback. please re-open if needed.

Also available in: Atom PDF