[BUG] FAL AdapterService fails with Fluid
authorBenjamin Mack <benni@typo3.org>
Mon, 16 Jul 2012 08:23:01 +0000 (10:23 +0200)
committerIngmar Schlecht <ingmar@typo3.org>
Wed, 18 Jul 2012 09:41:08 +0000 (11:41 +0200)
FAL introduced an adapterservice to migrate certain
fields to FAL style. The adapterservice uses type hinting
to suggest $row of tslib_content always to be an array.
However, when e.g. calling tslib_content from an
extension or Fluid, it is common to have $row
as NULL or empty, so the additional check
is removed.

Change-Id: I4b5f0231d3c8c2d9f3ec6d2f6a7a3a1b85775673
Resolves: #38977
Reviewed-on: http://review.typo3.org/12813
Reviewed-by: Michael Staatz
Tested-by: Michael Staatz
Reviewed-by: Ingmar Schlecht
Tested-by: Ingmar Schlecht
t3lib/file/Service/BackwardsCompatibility/TslibContentAdapterService.php

index 61290d9..0a8944f 100644 (file)
@@ -65,14 +65,14 @@ class t3lib_file_Service_BackwardsCompatibility_TslibContentAdapterService {
         *
         * This method is called by the render() method of tslib_content_Content.
         *
-        * @param $row
-        * @param $table
+        * @param $row typically an array, but can also be null (in extensions or e.g. FLUID viewhelpers)
+        * @param $table the database table where the record is from
         * @return      void
         */
-       public static function modifyDBRow(array &$row, $table) {
+       public static function modifyDBRow(&$row, $table) {
                if (array_key_exists($table, static::$migrateFields)) {
                        foreach (static::$migrateFields[$table] as $migrateFieldName => $oldFieldNames) {
-                               if (isset($row[$migrateFieldName])) {
+                               if ($row !== NULL && isset($row[$migrateFieldName])) {
                                        /** @var $fileRepository t3lib_file_Repository_FileRepository */
                                        $fileRepository = t3lib_div::makeInstance('t3lib_file_Repository_FileRepository');
                                        $files = $fileRepository->findByRelation($table, $migrateFieldName, $row['uid']);