Bug #43504

Flexform internal_type=folder doesn't work and breaks Element Browser

Added by Manuel Soehner almost 7 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Must have
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2012-12-01
Due date:
% Done:

0%

TYPO3 Version:
6.0
PHP Version:
5.4
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

My slideshow extension uses a flexform (for plugin configuration in the backend) with following snippet:

<folder>
 <TCEforms>
  <label>Folder with images to display</label>
  <config>
   <type>group</type>
   <internal_type>folder</internal_type>
   <maxitems>1</maxitems>
   <size>1</size>
  </config>
 </TCEforms>
</folder>

This causes several problems, depending on the user's state or something like that.

Normally I see the following exception when opening the element browser:

#1: PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Recordlist\Browser\ElementBrowser::TBE_expandSubFolders() must be an instance of TYPO3\CMS\Core\Resource\Folder, null given, called in /../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php on line 1252 and defined in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1427

My test user (no admin) also runs into this message but when I managed to open the element browser somewhere else in the backend and have expanded a folder, the element browser opens as expected.
Unfortunately, after clicking on the folder name, the element browser closes and nothing is selected (the expected value would have been the path to the folder).

After that, the syslog contains these error messages (ordered by descending timestamp):

Core: Error handler (BE): PHP Warning: basename() expects parameter 1 to be string, object given in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1673 

Core: Error handler (BE): PHP Warning: rawurlencode() expects parameter 1 to be string, object given in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1666 

Core: Error handler (BE): PHP Warning: strstr() expects parameter 1 to be string, object given in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1660 

Core: Error handler (BE): PHP Warning: Missing argument 2 for TYPO3\CMS\Recordlist\Browser\ElementBrowser::folderList(), called in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php on line 1430 and defined in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1653 

Core: Error handler (BE): PHP Warning: rtrim() expects parameter 1 to be string, object given in /.../typo3_src-6.0.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1867

If I change the "internal_type" to "file", everything works fine - but I'd like to select a folder.

I noticed this behavior after updating from version 4.7.7 to 6.0.0 in my production system.
In order to reproduce the error I set up a clean TYPO3 (blank package) and only installed my extension.

ElementBrowserPatch-201307141340.patch View (9.99 KB) Matthias Toscanelli, 2013-07-14 13:47

ElementBrowserPatch-v6.0.6.patch View (7.04 KB) Benjamin Schmidt, 2013-07-22 17:13

ElementBrowser.php View (96.8 KB) Benjamin Schmidt, 2013-07-22 17:13

T3X_flexform_folder_selection-0_0_0-z-201311221655.t3x (6.02 KB) Manuel Soehner, 2013-11-22 17:20


Related issues

Related to TYPO3 Core - Bug #63651: Group type 'Folder' broken for TCA Closed 2014-12-08
Duplicated by TYPO3 Core - Bug #54299: Flexform - type group, folder - Uncaught TYPO3 Exception Closed 2013-12-10
Precedes TYPO3 Core - Bug #55619: Replace folderList implementation in ElementBrowser Closed 2014-02-03

History

#1 Updated by Noel Bossart over 6 years ago

I have the same Issue. 'internal_type' => 'file', works, 'folder' breaks.

'folder' => array(
'exclude' => 1,
'label' => 'LLL:EXT:nbogallery/Resources/Private/Language/locallang_db.xml:tx_nbogallery_domain_model_gallery.folder',
'config' => array(
'type' => 'group',
'internal_type' => 'folder',
'show_thumbs' => '1',
'size' => '3',
'maxitems' => '200',
'minitems' => '0',
'autoSizeMax' => 40,
'disable_controls' => 'upload',
),
),

#2 Updated by Stefan Galinski over 6 years ago

  • Category set to File Abstraction Layer (FAL)
  • Status changed from New to Accepted

#3 Updated by Ina Heydecke over 6 years ago

Problem still exists in TYPO3 6.1 (found it in ke_search file indexer).

PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Recordlist\Browser\ElementBrowser::TBE_expandSubFolders() must be an instance of TYPO3\CMS\Core\Resource\Folder, null given, called in /html/typo3/typo3_src-6.1.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php on line 1278 and defined in /html/typo3/typo3_src-6.1.0/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1453

#4 Updated by Matthias Toscanelli about 6 years ago

Problem comes when no folder is given. (usually when a plugin or a record is initialized)

One solution would be to set the "selectedFolder" in user's default upload folder by default when no folder is given as it's done with "file".

Adding this at line 1269 in typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php solve the problem:

// Or get the user's default upload folder
if (!$this->selectedFolder) {
    $this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
}

#5 Updated by Matthias Toscanelli about 6 years ago

Well my solution solved only the exception.

The main problem is that function "folderList" has not been revritten.
I did a patch to correct the exception and rewrite the "folderList" function.

TYPO3 version 6.0 to 6.2 need this patch.

#6 Updated by Benjamin Schmidt about 6 years ago

Thanks Matthias for your patch. Finally there is a solution for this bug :)

Sadly I couldn't directly apply your patch to my typo3 6.0.6, so I had to do it manually :/
My patchfile and the updated ElementBrowser.php v6.0.6 is attached.

#7 Updated by Jürgen König about 6 years ago

Still got the error in 6.1.4 and ke-search. Your Patch solves the problem. Thanks Matthias and Benjamin!

#8 Updated by Marcos Fadul almost 6 years ago

Patch applies successfully on Typo3 6.1.5 and solves the issue. Thank you Matthias and Benjamin!
Regards

#9 Updated by Eric Chavaillaz almost 6 years ago

I got the same problem with TYPO3 6.1.5.
Can someone send a patch to gerrit and then the review process can begin?

#10 Updated by Eric Chavaillaz almost 6 years ago

The same in TYPO3 6.2...

#11 Updated by Alexander Opitz almost 6 years ago

  • Assignee set to Alexander Opitz
  • Is Regression set to No

Is there an extension on typo3.org which have this issue?

#12 Updated by Eric Chavaillaz almost 6 years ago

I don't know, personnaly I use it in a custom extension...

Thanks

#13 Updated by Manuel Soehner almost 6 years ago

I also don't know if there's an extension on typo3.org that uses that feature but I've created a simple demo extension (see attached t3x) that works fine on TYPO3 4.7.* but fails on TYPO3 6.*

Just install the extension, create a page content of type "plugin", choose that plugin and in the "Plugin Options" open the Element Browser and select a folder.

#14 Updated by Christian Buelter almost 6 years ago

ke_search uses this feature.

Error is still there with current master of TYPO3 CMS.

Test case:

  • Install TYPO3 CMS blank package
  • Install ke_search
  • [with ke_search 1.5] set compatibilty version to 6.2.99 in ext_emconf.php
  • Create a sysfolder
  • Create a record of type "indexer configuration", set the type to "file"
  • In the field "Directories" try to select a directory

Error message:

PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Recordlist\Browser\ElementBrowser::TBE_expandSubFolders() must be an instance of TYPO3\CMS\Core\Resource\Folder, null given,

#15 Updated by Maarten Mandemaker over 5 years ago

Confirmed ke_search uses this feature. Is there a patch for 6.2.0beta2 ?

#16 Updated by Gerrit Code Review over 5 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26720

#17 Updated by Gerrit Code Review over 5 years ago

Patch set 2 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26720

#18 Updated by Gerrit Code Review over 5 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#19 Updated by Gerrit Code Review over 5 years ago

Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27088

#20 Updated by Gerrit Code Review over 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#21 Updated by Gerrit Code Review over 5 years ago

Patch set 2 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27088

#22 Updated by Gerrit Code Review over 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#23 Updated by Markus Günther over 5 years ago

I create a small extension to test the behavior. So it is
easier to test for all of you.

You can find the extension on github.
https://github.com/markusguenther/internaltype

Only clone it in your typo3conf/ext folder.

cd typo3conf/ext
git clone https://github.com/markusguenther/internaltype.git

After clearing the cache you can create a new record from type test object and can use the element browser for the property album.

Thats all. Thanks for testing!

#24 Updated by Gerrit Code Review over 5 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#25 Updated by Gerrit Code Review over 5 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#26 Updated by Gerrit Code Review over 5 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#27 Updated by Gerrit Code Review over 5 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#28 Updated by Gerrit Code Review over 5 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#29 Updated by Gerrit Code Review over 5 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#30 Updated by Gerrit Code Review over 5 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27087

#31 Updated by Daniel Ostmann over 5 years ago

This patch did not solved it in 6.2.0.

I applied the last patch, then the folder tree appears. But now a can't select any folder without an exception:

#1392409507: Invalid form/module token detected. Access Denied! (More information)

UnexpectedValueException thrown in file
/<path>/typo3/mod.php in line 39.

#32 Updated by Jörg Leshel about 5 years ago

Bump!

<settings.flex_startingpoint>
  <TCEforms>
    <exclude>1</exclude>
    <label>LLL:EXT:dummy/Resources/Private/Language/locallang_db.xlf:settings.flex_startingpoint</label>
    <config>
      <type>group</type>
      <internal_type>folder</internal_type>
      <minitems>0</minitems>
      <maxitems>1</maxitems>
      <size>1</size>
    </config>
  </TCEforms>
</settings.flex_startingpoint>

PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Recordlist\Browser\ElementBrowser::TBE_expandSubFolders() must be an instance of TYPO3\CMS\Core\Resource\Folder, null given, called in /typo3_src-6.2.4/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php on line 1526 and defined in /typo3_src-6.2.4/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php line 1730

Update from 6.2.0 to 6.2.4 because of this issue - still same

Would be great if you could fix this in the short run

Need to finish an ext in the next few weeks in which the user has to be able to pic a folder as a starting point

#33 Updated by Rafael Kähm about 5 years ago

Some additional infos:

If using folder in FlexForms i get following error from error log:

PHP Fatal error: Call to a member function checkActionPermission() on a non-object in 
.../typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php 
on line 1732, 
referer: http://www.vagrant-typo3.dev/typo3/browser.php?mode=folder&bparams=data[tt_content][177][pi_flexform][data][sDEF][lDEF][settings.explorer.root][vDEF]||||"

By changing

<internal_type>folder</internal_type>

to
<internal_type>file</internal_type>

and choosing some file and save changes(***).

and then changing back to

<internal_type>folder</internal_type>

it is possible to create new entries and choose folders or change created above entries(^ ***).

But by relogin in Backend i get Fatal errors from above again.

#34 Updated by Alexander Rothmund almost 5 years ago

I can confirm that, using the current state of the patch, I am also getting the error message upon attempting to navigate through the tree on the left.

#1392409507: Invalid form/module token detected: Access Denied! (More information)

UnexpectedValueException thrown in file
.../www/typo3_src/typo3/mod.php in line 26.

However, selecting the folder displayed by default on the right works.

Tested in TYPO3 6.2.7.

#35 Updated by Ingo Schmitt over 4 years ago

  • Target version set to 7.1 (Cleanup)
  • TYPO3 Version changed from 6.0 to 6.2
  • Sprint Focus set to On Location Sprint

#36 Updated by Alexander Opitz over 4 years ago

  • TYPO3 Version changed from 6.2 to 6.0

This issue started with TYPO3 6.0, so please don't change this number.

#37 Updated by Alexander Opitz over 4 years ago

Is this issue fixed with latest git revision of TYPO3 7?

#38 Updated by Alexander Opitz over 4 years ago

  • Status changed from Under Review to Needs Feedback

#39 Updated by Josef F. Glatz (Old User) over 4 years ago

This issue is fixed in 6.2.10rc1!

#40 Updated by Wouter Wolters over 4 years ago

  • Status changed from Needs Feedback to Closed

#41 Updated by Markus Günther over 4 years ago

Big kudos and thanks to all involved developers :)

#42 Updated by Anja Leichsenring over 3 years ago

  • Sprint Focus deleted (On Location Sprint)

Also available in: Atom PDF