[-FEATURE] Remove restricted class prefixes
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 21 Jul 2012 15:23:39 +0000 (17:23 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 21 Jul 2012 19:24:55 +0000 (21:24 +0200)
Sometimes the core enforces classes to be prefixed with special names
like 'tx_' or 'user_', especially if they are loaded as user functions.
This constraint is in the core for a long time, but was already weakened
by for example the extbase code, and was only required at some arbitrary
points. The constraint itself does not make much sense, and is now
fully removed with this patch.
As an additional advantage, this patch eases the transition to
namespaced class names.

Notes:
- Remove configuration Setting '[sys][additionalAllowedClassPrefixes]'
- Update t3lib_registry to accept every namespace at least 2 chars long
- Adapt tests
- Remove and deprecate calls to t3lib_div::hasValidClassPrefix

Change-Id: I0ba4fd41beb5f05bf87a14d735bb83922d62b247
Resolves: #39164
Releases: 6.0
Reviewed-on: http://review.typo3.org/12976
Reviewed-by: Daniel Lorenz
Tested-by: Daniel Lorenz
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_div.php
t3lib/class.t3lib_extmgm.php
t3lib/class.t3lib_registry.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tcemain.php
t3lib/matchcondition/class.t3lib_matchcondition_abstract.php
t3lib/stddb/DefaultConfiguration.php
tests/Unit/t3lib/class.t3lib_divTest.php
tests/Unit/t3lib/class.t3lib_registryTest.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/setup/mod/index.php

index e1b31a7..7aaa253 100644 (file)
@@ -4203,12 +4203,12 @@ final class t3lib_div {
         * @param string $funcName Function/Method reference, '[file-reference":"]["&"]class/function["->"method-name]'. You can prefix this reference with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:&tx_realurl->encodeSpURL". Finally; you can prefix the class name with "&" if you want to reuse a former instance of the same object call ("singleton").
         * @param mixed $params Parameters to be pass along (typically an array) (REFERENCE!)
         * @param mixed $ref Reference to be passed along (typically "$this" - being a reference to the calling object) (REFERENCE!)
-        * @param string $checkPrefix Alternative allowed prefix of class or function name
+        * @param string $checkPrefix Not used anymore
         * @param integer $errorMode Error mode (when class/function could not be found): 0 - call debug(), 1 - do nothing, 2 - raise an exception (allows to call a user function that may return FALSE)
         * @return mixed Content from method/function call or FALSE if the class/method/function was not found
         * @see getUserObj()
         */
-       public static function callUserFunction($funcName, &$params, &$ref, $checkPrefix = 'user_', $errorMode = 0) {
+       public static function callUserFunction($funcName, &$params, &$ref, $checkPrefix = '', $errorMode = 0) {
                $content = FALSE;
 
                        // Check persistent object and if found, call directly and exit.
@@ -4239,17 +4239,6 @@ final class t3lib_div {
                        $storePersistentObject = FALSE;
                }
 
-                       // Check prefix is valid:
-               if ($checkPrefix && !self::hasValidClassPrefix($funcRef, array($checkPrefix))) {
-                       $errorMsg = 'Function/class \'' . $funcRef . '\' was not prepended with \'' . $checkPrefix . '\'';
-                       if ($errorMode == 2) {
-                               throw new InvalidArgumentException($errorMsg, 1294585864);
-                       } elseif (!$errorMode) {
-                               debug($errorMsg, 't3lib_div::callUserFunction');
-                       }
-                       return FALSE;
-               }
-
                        // Call function or method:
                $parts = explode('->', $funcRef);
                if (count($parts) == 2) { // Class
@@ -4317,12 +4306,12 @@ final class t3lib_div {
         * This function can return an object reference if you like. Just prefix the function call with "&": "$objRef = &t3lib_div::getUserObj('EXT:myext/class.tx_myext_myclass.php:&tx_myext_myclass');". This will work ONLY if you prefix the class name with "&" as well. See description of function arguments.
         *
         * @param string $classRef Class reference, '[file-reference":"]["&"]class-name'. You can prefix the class name with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:&tx_realurl". Finally; for the class name you can prefix it with "&" and you will reuse the previous instance of the object identified by the full reference string (meaning; if you ask for the same $classRef later in another place in the code you will get a reference to the first created one!).
-        * @param string $checkPrefix Required prefix of class name. By default "tx_" and "Tx_" are allowed.
+        * @param string $checkPrefix Not used anymore
         * @param boolean $silent If set, no debug() error message is shown if class/function is not present.
         * @return object The instance of the class asked for. Instance is created with t3lib_div::makeInstance
         * @see callUserFunction()
         */
-       public static function getUserObj($classRef, $checkPrefix = 'user_', $silent = FALSE) {
+       public static function getUserObj($classRef, $checkPrefix = '', $silent = FALSE) {
                        // Check persistent object and if found, call directly and exit.
                if (is_object($GLOBALS['T3_VAR']['getUserObj'][$classRef])) {
                        return $GLOBALS['T3_VAR']['getUserObj'][$classRef];
@@ -4347,14 +4336,6 @@ final class t3lib_div {
                                $storePersistentObject = FALSE;
                        }
 
-                               // Check prefix is valid:
-                       if ($checkPrefix && !self::hasValidClassPrefix($class, array($checkPrefix))) {
-                               if (!$silent) {
-                                       debug("Class '" . $class . "' was not prepended with '" . $checkPrefix . "'", 't3lib_div::getUserObj');
-                               }
-                               return FALSE;
-                       }
-
                                // Check if class exists:
                        if (class_exists($class)) {
                                $classObj = self::makeInstance($class);
@@ -4379,47 +4360,22 @@ final class t3lib_div {
         * @param string $classRef The class or function to check
         * @param array $additionalPrefixes Additional allowed prefixes, mostly this will be user_
         * @return bool TRUE if name is allowed
+        * @deprecated since 6.0, will be removed two versions later
         */
        public static function hasValidClassPrefix($classRef, array $additionalPrefixes = array()) {
-               if (empty($classRef)) {
-                       return FALSE;
-               }
-               if (!is_string($classRef)) {
-                       throw new InvalidArgumentException('$classRef has to be of type string', 1313917992);
-               }
-               $hasValidPrefix = FALSE;
-               $validPrefixes = self::getValidClassPrefixes();
-               $classRef = trim($classRef);
-
-               if (count($additionalPrefixes)) {
-                       $validPrefixes = array_merge($validPrefixes, $additionalPrefixes);
-               }
-               foreach ($validPrefixes as $prefixToCheck) {
-                       if (self::isFirstPartOfStr($classRef, $prefixToCheck) || $prefixToCheck === '') {
-                               $hasValidPrefix = TRUE;
-                               break;
-                       }
-               }
-
-               return $hasValidPrefix;
+               self::logDeprecatedFunction();
+               return TRUE;
        }
 
        /**
         * Returns all valid class prefixes.
         *
         * @return array Array of valid prefixed of class names
+        * @deprecated since 6.0, will be removed two versions later
         */
        public static function getValidClassPrefixes() {
-               $validPrefixes = array('tx_', 'Tx_', 'user_', 'User_', 't3lib_');
-               if (
-                       isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'])
-                       && is_string($GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'])
-               ) {
-                       $validPrefixes = array_merge(
-                               $validPrefixes,
-                               self::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'])
-                       );
-               }
+               self::logDeprecatedFunction();
+               $validPrefixes = array('tx_', 'Tx_', 'user_', 'User_', 't3lib_', '');
                return $validPrefixes;
        }
 
index 5b866a5..77599a5 100644 (file)
@@ -1126,7 +1126,7 @@ class t3lib_extMgm {
         * @return void
         */
        public static function addService($extKey, $serviceType, $serviceKey, $info) {
-               if ($serviceType && t3lib_div::hasValidClassPrefix($serviceKey) && is_array($info)) {
+               if ($serviceType && is_array($info)) {
                        $info['priority'] = max(0, min(100, $info['priority']));
 
                        $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = $info;
index 526ce87..61d2960 100644 (file)
@@ -67,6 +67,12 @@ class t3lib_Registry implements t3lib_Singleton {
 
        /**
         * Sets a persistent entry.
+        *
+        * This is the main method that can be used to store a key-value. It is name spaced with
+        * a unique string. This name space should be chosen from extensions that it is unique.
+        * It is advised to use something like 'tx_extensionname'. The prefix 'core' is reserved
+        * for the TYPO3 core.
+        *
         * Do not store binary data into the registry, it's not build to do that,
         * instead use the proper way to store binary data: The filesystem.
         *
@@ -170,22 +176,20 @@ class t3lib_Registry implements t3lib_Singleton {
        }
 
        /**
-        * Checks the given namespace. If it does not have a valid format an
-        * exception is thrown.
-        * Allowed namespaces are 'core', 'tx_*', 'Tx_*' and 'user_*'
+        * Checks the given namespace.
+        * It must be at least two characters long. The word 'core' is reserved for
+        * TYPO3 core usage.
         *
-        * @param string $namespace Namespace. extension key for extensions or 'core' for core registry entries
+        * If it does not have a valid format an exception is thrown.
+        *
+        * @param string $namespace Namespace
         * @return void
         * @throws InvalidArgumentException Throws an exception if the given namespace is not valid
         */
        protected function validateNamespace($namespace) {
-               if (t3lib_div::hasValidClassPrefix($namespace)) {
-                       return;
-               }
-
-               if ($namespace !== 'core') {
+               if (strlen($namespace) < 2) {
                        throw new InvalidArgumentException(
-                               '"' . $namespace . '" is no valid Namespace. The namespace has to be prefixed with "tx_", "Tx_", "user_" or must be equal to "core"',
+                               'Given namespace must be longer than two characters.',
                                1249755131
                        );
                }
index 65d5985..dbef10c 100644 (file)
@@ -1073,15 +1073,13 @@ class t3lib_TCEforms {
                                        }
                                break;
                                default:
-                                       if (t3lib_div::hasValidClassPrefix($func)) {
-                                                       // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
-                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                               if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
-                                                       $_params = array(
-                                                               'value' => $PA['itemFormElValue']
-                                                       );
-                                                       $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
-                                               }
+                                               // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval()
+                                       $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
+                                       if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
+                                               $_params = array(
+                                                       'value' => $PA['itemFormElValue']
+                                               );
+                                               $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                                        }
                                break;
                        }
@@ -1131,11 +1129,9 @@ class t3lib_TCEforms {
 
                        // Going through all custom evaluations configured for this field
                foreach ($evalList as $evalData) {
-                       if (t3lib_div::hasValidClassPrefix($evalData)) {
-                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
-                               if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
-                                       $this->extJSCODE .= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
-                               }
+                       $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
+                       if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
+                               $this->extJSCODE .= "\n\nfunction " . $evalData . "(value) {\n" . $evalObj->returnFieldJS() . "\n}\n";
                        }
                }
 
@@ -1290,15 +1286,13 @@ class t3lib_TCEforms {
                                                        $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
                                                break;
                                                default:
-                                                       if (t3lib_div::hasValidClassPrefix($func)) {
-                                                                       // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
-                                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                                               if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
-                                                                       $_params = array(
-                                                                               'value' => $PA['itemFormElValue']
-                                                                       );
-                                                                       $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
-                                                               }
+                                                               // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
+                                                       $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
+                                                       if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
+                                                               $_params = array(
+                                                                       'value' => $PA['itemFormElValue']
+                                                               );
+                                                               $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                                                        }
                                                break;
                                        }
index b544074..cd23e6d 100644 (file)
@@ -2074,11 +2074,9 @@ class t3lib_TCEmain {
                                        }
                                break;
                                default:
-                                       if (t3lib_div::hasValidClassPrefix($func)) {
-                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                               if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
-                                                       $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
-                                               }
+                                       $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
+                                       if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
+                                               $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
                                        }
                                break;
                        }
@@ -2189,11 +2187,9 @@ class t3lib_TCEmain {
                                        }
                                break;
                                default:
-                                       if (t3lib_div::hasValidClassPrefix($func)) {
-                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                               if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
-                                                       $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
-                                               }
+                                       $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
+                                       if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
+                                               $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
                                        }
                                break;
                        }
index f1a66b4..2765f43 100644 (file)
@@ -406,11 +406,6 @@ abstract class t3lib_matchCondition_abstract {
                                $values = preg_split('/\(|\)/', $value);
                                $funcName = trim($values[0]);
                                $funcValue = t3lib_div::trimExplode(',', $values[1]);
-                               if (!t3lib_div::hasValidClassPrefix($funcName)
-                               ) {
-                                       $this->log('Match condition: Function "' . $funcName . '" was not prepended with one of "' . implode(', ', t3lib_div::getValidClassPrefixes()) . '"');
-                                       return FALSE;
-                               }
                                if (function_exists($funcName) && call_user_func($funcName, $funcValue[0])) {
                                        return TRUE;
                                }
index a7ecf69..11faf60 100644 (file)
@@ -162,7 +162,6 @@ return array(
                                ),
                        ),
                ),
-               'additionalAllowedClassPrefixes' => NULL,       // Class names in TYPO3 must usually start with tx_, Tx, user_ or User_. This setting allows to register additional prefixes in a comma separated list.
                'displayErrors' => -1,                                  // <p>Integer (-1, 0, 1, 2). Configures whether PHP errors should be displayed.</p><dl><dt>0</dt><dd>Do not display any PHP error messages. Overrides the value of "exceptionalErrors" and sets it to 0 (= no errors are turned into exceptions), the configured "productionExceptionHandler" is used as exception handler</dd><dt>1</dt><dd>Display error messages with the registered errorhandler. The configured "debugExceptionHandler" is used as exception handler</dd><dt>2</dt><dd>Display errors only if client matches <a href="#SYS-devIPmask">[SYS][devIPmask]</a>. If devIPmask matches the users IP address  the configured "debugExceptionHandler" is used  for exceptions, if not "productionExceptionHandler" will be used</dd><dt>-1</dt><dd>Default setting. With this option, you can override the PHP setting "display_errors". If devIPmask matches the users IP address  the configured "debugExceptionHandler" is used  for exceptions, if not "productionExceptionHandler" will be used.</dd></dl>
                'productionExceptionHandler'  => 't3lib_error_ProductionExceptionHandler',      // String: Classname to handle exceptions that might happen in the TYPO3-code. Leave empty to disable exception handling. Default: "t3lib_error_ProductionExceptionHandler". This exception handler displays a nice error message when something went wrong. The error message is logged to the configured logs. Note: The configured "productionExceptionHandler" is used if displayErrors is set to "0" or to "-1" and devIPmask doesn't match the users IP.
                'debugExceptionHandler' => 't3lib_error_DebugExceptionHandler',                         // String: Classname to handle exceptions that might happen in the TYPO3-code. Leave empty to disable exception handling. Default: "t3lib_error_DebugExceptionHandler". This exception handler displays the complete stack trace of any encountered exception. The error message and the stack trace  is logged to the configured logs. Note: The configured "debugExceptionHandler" is used if displayErrors is set to "1" and if displayErrors is "-1"  or "2" and the devIPmask matches the users IP.
index 39ac342..03512e1 100644 (file)
@@ -4161,7 +4161,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $params['called'][spl_object_hash($this)]++;
        }
 
-
        ///////////////////////////////////////////////////
        // Tests concerning hasValidClassPrefix
        ///////////////////////////////////////////////////
@@ -4175,6 +4174,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        'normal long prefix' => array('tx_foo_bar'),
                        'extbase named prefix' => array('Tx_foo'),
                        'user func named prefix' => array('user_foo'),
+                       'empty string' => array(''),
                );
        }
 
@@ -4184,113 +4184,12 @@ class t3lib_divTest extends tx_phpunit_testcase {
         * @param string $className Class name to test
         */
        public function hasValidClassPrefixAcceptsValidPrefixes($className) {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'] = 'foo_';
-               $this->assertTrue(
-                       t3lib_div::hasValidClassPrefix($className)
-               );
-       }
-
-       /**
-        * @return array
-        */
-       public function invalidClassPrefixDataProvider() {
-               return array(
-                       array('ab_c'),
-                       array('txfoo'),
-                       array('Txfoo'),
-                       array('userfoo'),
-                       array('aser_foo'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidClassPrefixDataProvider
-        * @param string $className Class name to test
-        */
-       public function hasValidClassPrefixRefusesInvalidPrefixes($className) {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'] = 'foo_';
-               $this->assertFalse(
-                       t3lib_div::hasValidClassPrefix($className)
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function hasValidClassPrefixReturnsFalseIfEmptyClassNameGiven() {
-               $this->assertFalse(
-                       t3lib_div::hasValidClassPrefix('')
-               );
-       }
-
-       /**
-        * @return array
-        */
-       public function invalidClassReferenceDataTypeDataProvider() {
-               return array(
-                       'array' => array(array('someClassArray')),
-                       'integer' => array(123),
-                       'boolean' => array(TRUE),
-                       'object' => array(new stdClass()),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidClassReferenceDataTypeDataProvider
-        * @param string $className Class name to test
-        * @expectedException \InvalidArgumentException
-        */
-       public function hasValidClassPrefixThrowsExceptionForInvalidClassReferenceDataType($className) {
-               t3lib_div::hasValidClassPrefix($className);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidClassPrefixDataProvider
-        * @param string $className Class name to test
-        */
-       public function hasValidClassPrefixAllowsEmptyPrefix($className) {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'] = '';
-               $this->assertTrue(
-                       t3lib_div::hasValidClassPrefix($className)
-               );
-       }
-
-       /**
-        * @return array
-        */
-       public function getValidClassPrefixesReturnsListOfValidClassPrefixesDataProvider() {
-               return array(
-                       array('user_'),
-                       array('User_'),
-                       array('Tx_'),
-                       array('tx_'),
-                       array('foo_'),
-                       array('bar_'),
-                       array('BAZ_')
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider getValidClassPrefixesReturnsListOfValidClassPrefixesDataProvider
-        * @param string $prefix prefix to test
-        */
-       public function getValidClassPrefixesReturnsListOfValidClassPrefixes($prefix) {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['additionalAllowedClassPrefixes'] = 'foo_,bar_,BAZ_';
-               $this->assertTrue(in_array($prefix, t3lib_div::getValidClassPrefixes()));
+               $this->assertTrue(t3lib_div::hasValidClassPrefix($className));
        }
 
-       /**
-        * @test
-        */
-       public function hasValidClassPrefixAcceptsAdditionalPrefixes() {
-               $this->assertTrue(
-                       t3lib_div::hasValidClassPrefix('customPrefix_foo', array('customPrefix_'))
-               );
-       }
+       ///////////////////////////////////////////////////
+       // Tests concerning generateRandomBytes
+       ///////////////////////////////////////////////////
 
        /**
         * @test
index 8ae4700..1b3bb1e 100644 (file)
@@ -66,8 +66,16 @@ class t3lib_RegistryTest extends tx_phpunit_testcase {
         * @test
         * @expectedException InvalidArgumentException
         */
-       public function getThrowsExceptionForInvalidNamespaces() {
-               $this->registry->get('invalidNamespace', 'someKey');
+       public function getThrowsExceptionForInvalidNamespacesUsingNoNamespace() {
+               $this->registry->get('', 'someKey');
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function getThrowsExceptionForInvalidNamespacesUsingTooShortNamespace() {
+               $this->registry->get('t', 'someKey');
        }
 
        /**
@@ -165,7 +173,7 @@ class t3lib_RegistryTest extends tx_phpunit_testcase {
         * @expectedException InvalidArgumentException
         */
        public function setThrowsAnExceptionOnWrongNamespace() {
-               $this->registry->set('invalidNamespace', 'someKey', 'someValue');
+               $this->registry->set('t', 'someKey', 'someValue');
        }
 
        /**
@@ -173,6 +181,7 @@ class t3lib_RegistryTest extends tx_phpunit_testcase {
         */
        public function setAllowsValidNamespaces() {
                $this->registry->set('tx_thisIsValid', 'someKey', 'someValue');
+               $this->registry->set('thisIsValid', 'someKey', 'someValue');
                $this->registry->set('user_soIsThis', 'someKey', 'someValue');
                $this->registry->set('core', 'someKey', 'someValue');
        }
@@ -255,7 +264,7 @@ class t3lib_RegistryTest extends tx_phpunit_testcase {
         * @expectedException InvalidArgumentException
         */
        public function removeThrowsAnExceptionOnWrongNamespace() {
-               $this->registry->remove('coreInvalid', 'someKey');
+               $this->registry->remove('t', 'someKey');
        }
 
        /**
index 7dce1c3..f9cc646 100644 (file)
@@ -6661,10 +6661,6 @@ class tslib_cObj {
         * @see USER(), stdWrap(), typoLink(), _parseFunc()
         */
        function callUserFunction($funcName, $conf, $content) {
-               if (!t3lib_div::hasValidClassPrefix($funcName)) {
-                       $GLOBALS['TT']->setTSlogMessage('Function "' . $funcName . '" was not prepended with one of "' . implode(', ', t3lib_div::getValidClassPrefixes()) . '"', 3);
-                       return $content;
-               }
                        // Split parts
                $parts = explode('->', $funcName);
                if (count($parts) == 2) { // Class
index 506e591..3f5a58b 100755 (executable)
@@ -791,19 +791,15 @@ class SC_mod_user_setup_index {
        */
        protected function checkAccess(array $config) {
                $access = $config['access'];
+
                        // Check for hook
-               if (t3lib_div::hasValidClassPrefix($access)) {
-                       $accessObject = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['accessLevelCheck'][$access] . ':&' . $access);
-                       if (is_object($accessObject) && method_exists($accessObject, 'accessLevelCheck')) {
-                                       // Initialize vars. If method fails, $set will be set to FALSE
-                               return $accessObject->accessLevelCheck($config);
-                       }
-               } elseif ($access == 'admin') {
-                       return $this->isAdmin;
+               $accessObject = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['accessLevelCheck'][$access] . ':&' . $access);
+               if (is_object($accessObject) && method_exists($accessObject, 'accessLevelCheck')) {
+                               // Initialize vars. If method fails, $set will be set to FALSE
+                       return $accessObject->accessLevelCheck($config);
                }
        }
 
-
        /**
         * Returns the label $str from getLL() and grays out the value if the $str/$key is found in $this->overrideConf array
         *