Bug #20489
closedloadPrototype() called in frontend editing without a valid doc instance.
0%
Description
When using frontend editing with the edit forms appearing directly on the page (and not in a popup) the following fatal error is generated.
PHP Fatal error: Call to a member function loadPrototype() on a non-object in /Users/jsegars/Sites/typo3_src/trunk/t3lib/class.t3lib_tceforms.php on line 5136
This was caused by RFC #20229: Use new JS-function for loading prototype/scriptaculous/extJS which references $GLOBALS['SOBE']->doc directly in tceforms, which may be used in the frontend or the backend. When edit forms appear directly on the page, $GLOBALS['SOBE']->doc does not exist at all.
The most obvious solution was to add wrapper for the offending calls in t3lib_tceforms_fe as we've done in the past to handle the different methods of loading Javascript in the frontend and backend. In this case, there's more logic in the actual loading so a simple wrapper isn't the best solution.
We've seen this sort of problem pop up several times now, so I think the best solution is create a dummy instance of $GLOBALS['SOBE']->doc in the frontend context so that we don't have to worry about frontend or backend when using tceforms. The attached patch adds a new tsfeDoc to typo3/template.php and creates a dummy version of $GLOBALS['SOBE'] within tceforms_fe.
The only potential compatibility issue is that tceforms no longer includes tceforms_fe. This inclusion was for compatibility reasons, as tceforms and tceforms_fe used to be a part of the same file. Keeping the inclusion meant tceforms_fe was always included in the backend context and defining $GLOBALS['SOBE'] there caused lots of errors. With the addition of the autoloader recently, this change may not even be the minor issue that I originally thought it was :)
(issue imported from #M11166)
Files
Updated by Jeff Segars over 15 years ago
Added v2 patch that applies cleanly to trunk. The concerns above about removing tceforms_fe inclusion within tceforms are no longer valid thanks to the autoloader.
Updated by Jeff Segars over 15 years ago
Committed Olly's v3 patch to trunk in r5513.