Bug #7138

Changes to ObjectAccessor break usage with fluid conditions

Added by Falk Kühnel over 11 years ago. Updated over 10 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
Core
Target version:
-
Start date:
2010-04-06
Due date:
% Done:

0%

Estimated time:
Has patch:
No

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.


Files

#1

Updated by Jochen Rau over 11 years ago

  • Category set to 431
  • Status changed from New to Needs Feedback
  • Assignee 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 11 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 11 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 11 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 11 years ago

  • Status changed from Closed to Accepted
  • Assignee changed from Jochen Rau to Sebastian Kurfuerst
  • Priority changed from Should have to Must have
#6

Updated by Sebastian Kurfuerst over 11 years ago

  • Status changed from Accepted to New
  • Assignee deleted (Sebastian Kurfuerst)
#7

Updated by Sebastian Kurfuerst over 11 years ago

  • Project changed from 534 to TYPO3.Fluid
  • Category deleted (431)
#8

Updated by Sebastian Kurfuerst over 11 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 over 10 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 over 10 years ago

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

Updated by Sebastian Kurfuerst over 10 years ago

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

Updated by Sebastian Kurfuerst over 10 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