Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-2896

FragmentRenderer always expects controller to be array, throws exception if object implementing __invoke() is passed

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.0.0-beta4, 2.5.8
    • 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.5.6
    • Page Builder
    • None

    Description

      PageBuilder

      In EzSystems\EzPlatformPageBuilder\HTTP\Kernel\Fragment\DecoratedFragmentRenderer:

      private function doesReferenceBlockRender(ControllerReference $controllerReference): bool
      {
          $controllerCallable = $this->controllerResolver->getCallableFromControllerReference($controllerReference);
      
          return $controllerCallable[0] instanceof BlockController && 'renderAction' === $controllerCallable[1];
      }

      If the $controllerCallable is an object implementing __invoke() method (which is a valid callable type), the exception will be thrown on the return line (cannot use object as an array).

      Page Field type

      In EzSystems\EzPlatformPageFieldType\FragmentRenderer\BlockRenderOptionsFragmentRenderer:

      private function isBlockRenderRequest(ControllerReference $controllerReference): bool
      {
          $mockRequest = $this->mockRequest($controllerReference);
          $controller = $this->controllerResolver->getController($mockRequest);
      
          if (!\is_callable($controller)) {
              return false;
          }
      
          return $controller[0] instanceof BlockController && 'renderAction' === $controller[1];
      } 

      Same type of error as in the first example.

      In both methods, there should be additional check before the return statement - if the given callable is not an array, return false.

      Attachments

        Activity

          People

            Unassigned Unassigned
            fc262394-a899-48af-9188-9148599aa871@accounts.ibexa.co Hrvoje Knežević
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: