[+BUGFIX] Throw exception if a class to be reflected does not exist
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Jun 2011 10:06:42 +0000 (12:06 +0200)
committerMarc Bastian Heinrichs <heinrichs@mbh-web.de>
Tue, 14 Jun 2011 11:42:18 +0000 (13:42 +0200)
avoid fatal PHP-errors by throwing an exception.
Thanks to Felix Oertel.

Change-Id: Id2f864947650920b61cf98c53de751bf18bb90b8
Fixes: #8718

typo3/sysext/extbase/Classes/Reflection/Exception/UnknownClass.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Reflection/Service.php
typo3/sysext/extbase/ext_autoload.php

diff --git a/typo3/sysext/extbase/Classes/Reflection/Exception/UnknownClass.php b/typo3/sysext/extbase/Classes/Reflection/Exception/UnknownClass.php
new file mode 100644 (file)
index 0000000..e46c5cc
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2010 Felix Oertel <oertel@networkteam.com>
+*  All rights reserved
+*
+*  This class is a backport of the corresponding class of FLOW3.
+*  All credits go to the v5 team.
+*
+*  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!
+***************************************************************/
+
+/**
+ * An "Unknown Class" exception
+ *
+ * @version $Id$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Extbase_Reflection_Exception_UnknownClass extends Tx_Extbase_Reflection_Exception {
+}
+
+?>
\ No newline at end of file
index a65480d..c2b0608 100644 (file)
@@ -392,7 +392,7 @@ class Tx_Extbase_Reflection_Service implements t3lib_Singleton {
         */
        protected function buildClassSchema($className) {
                if (!class_exists($className)) {
-                       return NULL;
+                       throw new Tx_Extbase_Reflection_Exception_UnknownClass('The classname "' . $className . '" was not found and thus can not be reflected.', 1278450972);
                }
                $classSchema = new Tx_Extbase_Reflection_ClassSchema($className);
                if (is_subclass_of($className, 'Tx_Extbase_DomainObject_AbstractEntity')) {
index 75b7604..19aa74d 100644 (file)
@@ -194,6 +194,7 @@ return array(
        'tx_extbase_reflection_service' => $extensionClassesPath . 'Reflection/Service.php',
        'tx_extbase_reflection_exception_invalidpropertytype' => $extensionClassesPath . 'Reflection/Exception/InvalidPropertyType.php',
        'tx_extbase_reflection_exception_propertynotaccessibleexception' => $extensionClassesPath . 'Reflection/Exception/PropertyNotAccessibleException.php',
+       'tx_extbase_reflection_exception_unknownclass' => $extensionClassesPath . 'Reflection/Exception/UnknownClass.php',
        'tx_extbase_security_exception' => $extensionClassesPath . 'Security/Exception.php',
        'tx_extbase_security_channel_requesthashservice' => $extensionClassesPath . 'Security/Channel/RequestHashService.php',
        'tx_extbase_security_cryptography_hashservice' => $extensionClassesPath . 'Security/Cryptography/HashService.php',