diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index fd295beca6e1487b25b089250c8a0dd7e0d649a7..73c72291ece604c80bdb2a0979a5b02910e906ff 100755 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -3690,7 +3690,7 @@ class GeneralUtility * Calls a user-defined function/method in class * Such a function/method should look like this: "function proc(&$params, &$ref) {...}" * - * @param string $funcName Function/Method reference or Closure, '[file-reference":"]["&"]class/function["->"method-name]'. You can prefix this reference with "[file-reference]:" and \TYPO3\CMS\Core\Utility\GeneralUtility::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 string $funcName Function/Method reference or Closure, '[file-reference":"]["&"]class/function["->"method-name]'. You can prefix this reference with "[file-reference]:" and \TYPO3\CMS\Core\Utility\GeneralUtility::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". However, using file references has been marked as deprecated and should be avoided, instead use the autoloading mechanism in place directly. 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 $_ Not used anymore since 6.0 @@ -3714,6 +3714,10 @@ class GeneralUtility } // Check file-reference prefix; if found, require_once() the file (should be library of code) if (strpos($funcName, ':') !== false) { + // @deprecated since TYPO3 v8, will be removed in v9 + self::deprecationLog('Using file references to resolve "' . $funcName . '" has been deprecated in TYPO3 v8 ' + . 'when calling GeneralUtility::callUserFunction(), make sure the class is available via the class loader. ' + . 'This functionality will be removed in TYPO3 v9.'); list($file, $funcRef) = self::revExplode(':', $funcName, 2); $requireFile = self::getFileAbsFileName($file); if ($requireFile) { @@ -3794,14 +3798,24 @@ class GeneralUtility * Creates and returns reference to a user defined object. * This function can return an object reference if you like. * - * @param string $classRef Class reference, '[file-reference":"]class-name'. You can prefix the class name with "[file-reference]:" and \TYPO3\CMS\Core\Utility\GeneralUtility::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". - * @return object The instance of the class asked for. Instance is created with \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance + * @param string $classRef Class reference, '[file-reference":"]class-name'. + * You can prefix the class name with "[file-reference]:" and + * GeneralUtility::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". + * However, the file reference part is marked as deprecated as the class loading mechanism + * via composer or the autoloading part of TYPO3 should be used instead. + * @return object The instance of the class asked for. Instance is created with GeneralUtility::makeInstance * @see callUserFunction() */ public static function getUserObj($classRef) { // Check file-reference prefix; if found, require_once() the file (should be library of code) if (strpos($classRef, ':') !== false) { + // @deprecated since TYPO3 v8, will be removed in v9 + self::deprecationLog('Using file references to resolve "' . $classRef . '" has been deprecated in TYPO3 v8 ' + . 'when calling GeneralUtility::getUserObj(), make sure the class is available via the class loader. ' + . 'This functionality will be removed in TYPO3 v9.'); list($file, $class) = self::revExplode(':', $classRef, 2); $requireFile = self::getFileAbsFileName($file); if ($requireFile) { diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-76345-PathPrefixesInCallUserFunctionAndGetUserObj.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-76345-PathPrefixesInCallUserFunctionAndGetUserObj.rst new file mode 100644 index 0000000000000000000000000000000000000000..e33d5de71075ae4aab7a3260e661b590054cd046 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-76345-PathPrefixesInCallUserFunctionAndGetUserObj.rst @@ -0,0 +1,34 @@ +====================================================================== +Deprecation: #76345 - Path prefixes in callUserFunction and getUserObj +====================================================================== + +Description +=========== + +The two methods ``GeneralUtility::callUserFunc()`` and ``GeneralUtility::getUserObj()`` allow the first parameter to +contain a file reference to the function/class to be called if prefixed with a colon. + +An example would be ``EXT:myext/Classes/MyClass.php:Benni\Myext\MyClass`` for including the class. + +Having the reference to the actual file is not needed since the composer autoloading mechanism takes care +of loading everything properly already since TYPO3 6.2.9. + + +Impact +====== + +Calling one of the methods above with a file reference prepended to the class name / function name will +trigger a deprecation log entry. + + +Affected Installations +====================== + +Any installation with a hook that is registered with the file prefix functionality. + + +Migration +========= + +Remove the file prefix when registering a hook and make use of the common autoloading functionality of +composer or via the fallback autoloader by TYPO3 to achieve the same functionality automatically. \ No newline at end of file diff --git a/typo3/sysext/dbal/ext_conf_template.txt b/typo3/sysext/dbal/ext_conf_template.txt index 998831596ebd3134983c66364aa84ebf1679a79c..8860dcb553a2a0e52a1e2bc5de2bf5d67b2662b4 100644 --- a/typo3/sysext/dbal/ext_conf_template.txt +++ b/typo3/sysext/dbal/ext_conf_template.txt @@ -1,6 +1,6 @@ # cat=basic; type=boolean; label=LLL:EXT:dbal/Resources/Private/Language/locallang_em.xlf:dbal.config.sql_query.passthrough sql_query.passthrough=1 - # cat=basic; type=user[EXT:dbal/Classes/ExtensionManager/MessageDisplay.php:TYPO3\CMS\Dbal\ExtensionManager\MessageDisplay->displayMessage]; + # cat=basic; type=user[TYPO3\CMS\Dbal\ExtensionManager\MessageDisplay->displayMessage]; Compatibility= diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/ConfigurationItemRepositoryTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/ConfigurationItemRepositoryTest.php index d8a80abfa4275e50221933aa9c5962718c76755a..d600dd12721224ec1cf9c39570801eb0964cbadf 100644 --- a/typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/ConfigurationItemRepositoryTest.php +++ b/typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/ConfigurationItemRepositoryTest.php @@ -214,12 +214,12 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase 'cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/z', - 'type' => 'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]', + 'type' => 'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]', 'label' => 'Frontend configuration check', 'name' => 'checkConfigurationFE', 'value' => 0, 'default_value' => 0, - 'comparisonGeneric' => 'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend' + 'comparisonGeneric' => 'TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend' ) ), array( @@ -227,12 +227,12 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase 'cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/z', - 'type' => 'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend]', + 'type' => 'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend]', 'label' => 'Backend configuration check', 'name' => 'checkConfigurationBE', 'value' => 0, 'default_value' => 0, - 'comparisonGeneric' => 'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend' + 'comparisonGeneric' => 'TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend' ) ), array( @@ -240,12 +240,12 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase 'cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/z', - 'type' => 'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE]', + 'type' => 'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE]', 'label' => 'Hashing method for the frontend: Defines salted hashing method to use. Choose "Portable PHP password hashing" to stay compatible with other CMS (e.g. Drupal, Wordpress). Choose "MD5 salted hashing" to reuse TYPO3 passwords for OS level authentication (other servers could use TYPO3 passwords). Choose "Blowfish salted hashing" for advanced security to reuse passwords on OS level (Blowfish might not be supported on your system TODO).', 'name' => 'FE.saltedPWHashingMethod', 'value' => \TYPO3\CMS\Saltedpasswords\Salt\PhpassSalt::class, 'default_value' => \TYPO3\CMS\Saltedpasswords\Salt\PhpassSalt::class, - 'comparisonGeneric' => 'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE' + 'comparisonGeneric' => 'TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE' ) ) ); diff --git a/typo3/sysext/saltedpasswords/ext_conf_template.txt b/typo3/sysext/saltedpasswords/ext_conf_template.txt index 8249fc316e87a2d087140fef1673898a99941eb9..e6a1cc795cd5a186d6d405b19e4702f304e88264 100644 --- a/typo3/sysext/saltedpasswords/ext_conf_template.txt +++ b/typo3/sysext/saltedpasswords/ext_conf_template.txt @@ -1,19 +1,19 @@ -# cat=Basic/enable; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationFE +# cat=Basic/enable; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationFE checkConfigurationFE=0 -# cat=Basic/enable; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationBackend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationBE +# cat=Basic/enable; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationBackend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationBE checkConfigurationBE=0 # cat=Basic/enable; type=boolean; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.FE.enabled FE.enabled = 1 -# cat=Basic/enable; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.FE.saltedPWHashingMethod +# cat=Basic/enable; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.FE.saltedPWHashingMethod FE.saltedPWHashingMethod = tx_saltedpasswords_salts_phpass -# cat=Basic/enable; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->buildHashMethodSelectorBE]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.BE.saltedPWHashingMethod +# cat=Basic/enable; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->buildHashMethodSelectorBE]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.BE.saltedPWHashingMethod BE.saltedPWHashingMethod = tx_saltedpasswords_salts_phpass -# cat=Frontend; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationFE2 +# cat=Frontend; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationFE2 checkConfigurationFE2=0 # cat=Frontend; type=boolean; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.FE.forceSalted @@ -25,7 +25,7 @@ FE.onlyAuthService = 0 # cat=Frontend; type=boolean; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.FE.updatePasswd FE.updatePasswd = 1 -# cat=Backend; type=user[EXT:saltedpasswords/Classes/Utility/ExtensionManagerConfigurationUtility.php:TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationBackend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationBE2 +# cat=Backend; type=user[TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility->checkConfigurationBackend]; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.checkConfigurationBE2 checkConfigurationBE2=0 # cat=Backend; type=boolean; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.BE.forceSalted @@ -35,4 +35,4 @@ BE.forceSalted = 0 BE.onlyAuthService = 0 # cat=Backend; type=boolean; label=LLL:EXT:saltedpasswords/Resources/Private/Language/locallang_em.xlf:saltedpasswords.config.BE.updatePasswd -BE.updatePasswd = 1 \ No newline at end of file +BE.updatePasswd = 1