[TASK] Deprecate PhpOptionsUtility 71/57071/2
authorBenni Mack <benni@typo3.org>
Mon, 28 May 2018 18:20:07 +0000 (20:20 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 29 May 2018 06:08:43 +0000 (08:08 +0200)
The utility class was thinned out in the last TYPO3
versions and now is only used in EXT:install.

The functionality can be moved into EXT:install,
and PhpOptionsUtility can be deprecated, marked
as deprecated and awaiting removal in TYPO3 v10.0.

Resolves: #85102
Releases: master
Change-Id: Ie45720ad70cd2bdd2949553c94fcec15806cb458
Reviewed-on: https://review.typo3.org/57071
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Classes/Utility/PhpOptionsUtility.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85102-PhpOptionsUtility.rst [new file with mode: 0644]
typo3/sysext/install/Classes/Service/SessionService.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php

index 4d04233..ee6fc51 100644 (file)
@@ -23,9 +23,11 @@ class PhpOptionsUtility
      * Check if php session.auto_start is enabled
      *
      * @return bool TRUE if session.auto_start is enabled, FALSE if disabled
+     * @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0. Use custom filter_var()/ini_get() functionality yourself.
      */
     public static function isSessionAutoStartEnabled()
     {
+        trigger_error('The PhpOptionsUtility class will be removed in TYPO3 v10.0. Use custom filter_var()/ini_get() functionality yourself.', E_USER_DEPRECATED);
         return self::getIniValueBoolean('session.auto_start');
     }
 
@@ -34,9 +36,11 @@ class PhpOptionsUtility
      *
      * @param string $configOption
      * @return bool TRUE if the given option is enabled, FALSE if disabled
+     * @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0. Use custom filter_var()/ini_get() functionality yourself.
      */
     public static function getIniValueBoolean($configOption)
     {
+        trigger_error('The PhpOptionsUtility class will be removed in TYPO3 v10.0. Use custom filter_va()/ini_get() functionality yourself.', E_USER_DEPRECATED);
         return filter_var(ini_get($configOption), FILTER_VALIDATE_BOOLEAN, [FILTER_REQUIRE_SCALAR, FILTER_NULL_ON_FAILURE]);
     }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85102-PhpOptionsUtility.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85102-PhpOptionsUtility.rst
new file mode 100644 (file)
index 0000000..f3e9092
--- /dev/null
@@ -0,0 +1,34 @@
+.. include:: ../../Includes.txt
+
+=======================================
+Deprecation: #85102 - PhpOptionsUtility
+=======================================
+
+See :issue:`85102`
+
+Description
+===========
+
+The PHP class :php:`\TYPO3\CMS\Core\Utility\PhpOptionsUtility` has been marked as deprecated.
+
+The only purpose for this class was to check for available session handling in the installer.
+
+
+Impact
+======
+
+Calling any method in this class will trigger deprecation warning.
+
+
+Affected Installations
+======================
+
+Installations checking for session handling in custom extensions.
+
+
+Migration
+=========
+
+Implement the :php:`filter_var()` and :php:`ini_get()` used in the PhpOptionsUtility wrapper yourself.
+
+.. index:: PHP-API, FullyScanned, ext:core
\ No newline at end of file
index 3bf7348..d5eec31 100644 (file)
@@ -80,7 +80,7 @@ class SessionService implements SingletonInterface
         ini_set('session.gc_probability', (string)100);
         ini_set('session.gc_divisor', (string)100);
         ini_set('session.gc_maxlifetime', (string)$this->expireTimeInMinutes * 2 * 60);
-        if (\TYPO3\CMS\Core\Utility\PhpOptionsUtility::isSessionAutoStartEnabled()) {
+        if ($this->isSessionAutoStartEnabled()) {
             $sessionCreationError = 'Error: session.auto-start is enabled.<br />';
             $sessionCreationError .= 'The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:<br />';
             $sessionCreationError .= '<pre>php_value session.auto_start Off</pre>';
@@ -523,4 +523,25 @@ class SessionService implements SingletonInterface
     {
         session_write_close();
     }
+
+    /**
+     * Check if php session.auto_start is enabled
+     *
+     * @return bool TRUE if session.auto_start is enabled, FALSE if disabled
+     */
+    protected function isSessionAutoStartEnabled()
+    {
+        return $this->getIniValueBoolean('session.auto_start');
+    }
+
+    /**
+     * Cast an on/off php ini value to boolean
+     *
+     * @param string $configOption
+     * @return bool TRUE if the given option is enabled, FALSE if disabled
+     */
+    protected function getIniValueBoolean($configOption)
+    {
+        return filter_var(ini_get($configOption), FILTER_VALIDATE_BOOLEAN, [FILTER_REQUIRE_SCALAR, FILTER_NULL_ON_FAILURE]);
+    }
 }
index f4288c1..691ff43 100644 (file)
@@ -674,4 +674,9 @@ return [
             'Deprecation-84411-TypoScriptReferenceLoaderRenamedToTypoScriptReferenceController.rst',
         ],
     ],
+    'TYPO3\CMS\Core\Utility\PhpOptionsUtility' => [
+        'restFiles' => [
+            'Deprecation-85102-PhpOptionsUtility.rst',
+        ],
+    ],
 ];
index 580413c..a47d5fa 100644 (file)
@@ -582,4 +582,18 @@ return [
             'Deprecation-85086-GeneralUtilityArrayToLogString.rst',
         ],
     ],
+    'TYPO3\CMS\Core\Utility\PhpOptionsUtility::isSessionAutoStartEnabled' => [
+        'numberOfMandatoryArguments' => 0,
+        'maximumNumberOfArguments' => 0,
+        'restFiles' => [
+            'Deprecation-85102-PhpOptionsUtility.rst',
+        ],
+    ],
+    'TYPO3\CMS\Core\Utility\PhpOptionsUtility::getIniValueBoolean' => [
+        'numberOfMandatoryArguments' => 1,
+        'maximumNumberOfArguments' => 1,
+        'restFiles' => [
+            'Deprecation-85102-PhpOptionsUtility.rst',
+        ],
+    ],
 ];