[BUGFIX] Avoid exceptions in backend list, if there are wrong uids 75/46675/2
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 15 Feb 2016 16:24:27 +0000 (11:24 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 15 Feb 2016 16:27:09 +0000 (17:27 +0100)
Note: Thanks to Tim Lochm├╝ller
Resolves: #72828
Change-Id: Ic7c2ac5d9368e82daa659d1297268acfbdf86416
Reviewed-on: https://review.typo3.org/46675
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
ChangeLog
Classes/Hook/Backend/Form/FormDataProvider/TcaLabelProcessor.php

index 35bfa20..ed19037 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * Resolves #72260: SelectViewHelper should honour TypoScript settings
        * Update the manual
+       * Resolves #72828: Avoid exceptions in backend list, if there are elements with wrong uids (Thanks to Tim Lochm├╝ller)
 
 2016-02-14  Stanislas Rolland  <typo3(arobas)sjbr.ca>
 
index b874642..8c0e6c9 100644 (file)
@@ -1,35 +1,35 @@
 <?php
 namespace SJBR\StaticInfoTables\Hook\Backend\Form\FormDataProvider;
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2013-2015 Stanislas Rolland <typo3(arobas)sjbr.ca>
-*  All rights reserved
-*
-*  This script is part of the Typo3 project. The Typo3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-/**
- * Processor for TCA select items
+
+/*
+ *  Copyright notice
+ *
+ *  (c) 2013-2016 Stanislas Rolland <typo3(arobas)sjbr.ca>
+ *  All rights reserved
+ *
+ *  This script is part of the Typo3 project. The Typo3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
-class TcaLabelProcessor {
-
+/**
+ * Processor for TCA select items
+ */
+class TcaLabelProcessor
+{
        /**
         * Add ISO codes to the label of entities
         *
@@ -37,7 +37,8 @@ class TcaLabelProcessor {
         * @param DataPreprocessor $fObj
         * @return void
         */
-       public function addIsoCodeToLabel (&$PA) {
+       public function addIsoCodeToLabel(&$PA)
+       {
                $PA['title'] = $PA['row'][$GLOBALS['TCA'][$PA['table']]['ctrl']['label']];
                if (TYPO3_MODE == 'BE') {
                        /** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
@@ -50,7 +51,9 @@ class TcaLabelProcessor {
                                                $territoryRepository = $objectManager->get('SJBR\\StaticInfoTables\\Domain\\Repository\\TerritoryRepository');
                                                /** @var $territory SJBR\StaticInfoTables\Domain\Model\Territory */
                                                $territory = $territoryRepository->findByUid($PA['row']['uid']);
-                                               $isoCode = $territory->getUnCodeNumber();
+                                               if (is_object($territory)) {
+                                                       $isoCode = $territory->getUnCodeNumber();
+                                               }
                                        }
                                        if ($isoCode) {
                                                $PA['title'] = $PA['title'] . ' (' . $isoCode . ')';
@@ -63,7 +66,9 @@ class TcaLabelProcessor {
                                                $countryRepository = $objectManager->get('SJBR\\StaticInfoTables\\Domain\\Repository\\CountryRepository');
                                                /** @var $country SJBR\StaticInfoTables\Domain\Model\Country */
                                                $country = $countryRepository->findByUid($PA['row']['uid']);
-                                               $isoCode = $country->getIsoCodeA2();
+                                               if (is_object($country)) {
+                                                       $isoCode = $country->getIsoCodeA2();
+                                               }
                                        }
                                        if ($isoCode) {
                                                $PA['title'] = $PA['title'] . ' (' . $isoCode . ')';
@@ -80,11 +85,13 @@ class TcaLabelProcessor {
                                                $languageRepository = $objectManager->get('SJBR\\StaticInfoTables\\Domain\\Repository\\LanguageRepository');
                                                /** @var $language SJBR\StaticInfoTables\Domain\Model\Language */
                                                $language = $languageRepository->findByUid($PA['row']['uid']);
-                                               $isoCodes = array($language->getIsoCodeA2());
-                                               if ($language->getCountryIsoCodeA2()) {
-                                                       $isoCodes[] = $language->getCountryIsoCodeA2();
-                                               }
-                                               $isoCode = implode('_', $isoCodes);
+                                               if (is_object($language)) {
+                                                       $isoCodes = array($language->getIsoCodeA2());
+                                                       if ($language->getCountryIsoCodeA2()) {
+                                                               $isoCodes[] = $language->getCountryIsoCodeA2();
+                                                       }
+                                                       $isoCode = implode('_', $isoCodes);
+                                               }
                                        }
                                        if ($isoCode) {
                                                $PA['title'] = $PA['title'] . ' (' . $isoCode . ')';
@@ -97,7 +104,9 @@ class TcaLabelProcessor {
                                                $currencyRepository = $objectManager->get('SJBR\\StaticInfoTables\\Domain\\Repository\\CurrencyRepository');
                                                /** @var $currency SJBR\StaticInfoTables\Domain\Model\Currency */
                                                $currency = $currencyRepository->findByUid($PA['row']['uid']);
-                                               $isoCode = $currency->getIsoCodeA3();
+                                               if (is_object($currency)) {
+                                                       $isoCode = $currency->getIsoCodeA3();
+                                               }
                                        }
                                        if ($isoCode) {
                                                $PA['title'] = $PA['title'] . ' (' . $isoCode . ')';