[!!!][TASK] Remove option "compat_version" 84/35684/6
authorBenjamin Mack <benni@typo3.org>
Tue, 30 Dec 2014 23:26:10 +0000 (00:26 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 10 Jan 2015 21:49:24 +0000 (22:49 +0100)
The global option
$TYPO3_CONF_VARS[SYS][compat_version]
was introduced for having old frontend output
while upgrading an installation to a newer version.

For example, it was used for conditions within
CSS Styled Content before separate TS templates
for different versions were introduced.

The option mainly works within
GeneralUtility::compat_version, which
is used in several places.

In a normal installation the value equals the
constant TYPO3_branch.

The according update wizard for updating
the option is not needed anymore and is
removed without substitution.

Resolves: #24900
Releases: master
Change-Id: Id3fef21122ad92a9a5a9e90f60179b50d42b6a11
Reviewed-on: http://review.typo3.org/35684
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Configuration/FactoryConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-24900-CompatVersion-Setting-Removed.rst [new file with mode: 0644]
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/install/Classes/Report/InstallStatusReport.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
typo3/sysext/install/Classes/Updates/CompatVersionUpdate.php [deleted file]
typo3/sysext/install/ext_localconf.php

index ac85246..22f1e18 100644 (file)
@@ -769,35 +769,32 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionMatchesOlderRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertTrue($this->matchCondition->match('[compatVersion = 4.0]'));
+               $this->assertTrue($this->matchCondition->match('[compatVersion = 7.0]'));
        }
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionMatchesSameRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertTrue($this->matchCondition->match('[compatVersion = 4.9]'));
+               $this->assertTrue($this->matchCondition->match('[compatVersion = ' . TYPO3_branch . ']'));
        }
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionDoesNotMatchNewerRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertFalse($this->matchCondition->match('[compatVersion = 5.0]'));
+               $this->assertFalse($this->matchCondition->match('[compatVersion = 15.0]'));
        }
 
        /**
index 8f68b64..32929a7 100755 (executable)
@@ -780,8 +780,7 @@ class GeneralUtility {
         * @todo Still needs a function to convert versions to branches
         */
        static public function compat_version($verNumberStr) {
-               $currVersionStr = $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] ?: TYPO3_branch;
-               return VersionNumberUtility::convertVersionNumberToInteger($currVersionStr) >= VersionNumberUtility::convertVersionNumberToInteger($verNumberStr);
+               return VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) >= VersionNumberUtility::convertVersionNumberToInteger($verNumberStr);
        }
 
        /**
index 13ed802..13d2d17 100644 (file)
@@ -56,7 +56,6 @@ return array(
                        )
                ),
                'sitename' => 'TYPO3',                                  // Name of the base-site. This title shows up in the root of the tree structure if you're an 'admin' backend user.
-               'compat_version' => '3.8',                              // Compatibility version. TYPO3 behavior will try to be compatible with the output from the TYPO3 version set here. It is recommended to change this setting with the Upgrade Wizard.
                'encryptionKey' => '',                                  // This is a "salt" used for various kinds of encryption, CRC checksums and validations. You can enter any rubbish string here but try to keep it secret. You should notice that a change to this value might invalidate temporary information, URLs etc. At least, clear all cache if you change this so any such information can be rebuild with the new key.
                'cookieDomain' => '',                                   // Restricts the domain name for FE and BE session cookies. When setting the value to ".domain.com" (replace domain.com with your domain!), login sessions will be shared across subdomains. Alternatively, if you have more than one domain with sub-domains, you can set the value to a regular expression to match against the domain of the HTTP request. The result of the match is used as the domain for the cookie. eg. /\.(example1|example2)\.com$/ or /\.(example1\.com)|(example2\.net)$/. Separate domains for FE and BE can be set using <a href="#FE-cookieDomain">$TYPO3_CONF_VARS['FE']['cookieDomain']</a> and <a href="#BE-cookieDomain">$TYPO3_CONF_VARS['BE']['cookieDomain']</a> respectively.
                'cookieSecure' => 0,                                    // <p>Integer (0, 1, 2): Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client.</p><dl><dt>0</dt><dd>always send cookie</dd><dt>1 (force HTTPS)</dt><dd>the cookie will only be set if a secure (HTTPS) connection exists - use this in combination with lockSSL since otherwise the application will fail and throw an exception</dd><dt>2</dt><dd>the cookie will be set in each case, but uses the secure flag if a secure (HTTPS) connection exists.</dd></dl>
index ca8b48a..8f142a3 100644 (file)
@@ -41,7 +41,6 @@ return array(
                'jpg_quality' => '80',
        ),
        'SYS' => array(
-               'compat_version' => '7.0',
                'isInitialInstallationInProgress' => TRUE,
                'sitename' => 'New TYPO3 site',
        ),
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-24900-CompatVersion-Setting-Removed.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-24900-CompatVersion-Setting-Removed.rst
new file mode 100644 (file)
index 0000000..9c3667b
--- /dev/null
@@ -0,0 +1,34 @@
+======================================================================
+Breaking: #24900 - Remove $TYPO3_CONF_VARS[SYS][compat_version] option
+======================================================================
+
+Description
+===========
+
+The option ``$TYPO3_CONF_VARS[SYS][compat_version]``, which was modified on update in the Install Tool wizard,
+is removed.
+
+Any checks on ``GeneralUtility::compat_version`` are now made against the common constant ``TYPO3_branch`` instead of
+the former TYPO3_CONF_VARS option.
+
+Impact
+======
+
+Any usage of ``$TYPO3_CONF_VARS[SYS][compat_version]`` where the value is different than ``TYPO3_branch`` will result
+in unexpected behaviour.
+
+TypoScript conditions which check for older compat_version will have different behaviour now.
+
+Affected installations
+======================
+
+Any installation where ``$TYPO3_CONF_VARS[SYS][compat_version]`` was not set to the currently running version
+or where the value of compat_version was used to simulate behaviour of an older version.
+E.g. TypoScript conditions or ``GeneralUtility::compat_version`` in extensions.
+
+
+Migration
+=========
+
+Remove any direct usage of the option, and use the "compat_version" method within GeneralUtility as well as the
+TypoScript condition "compat_version" which gives more accurate results.
index d69503e..4d20d29 100644 (file)
@@ -613,35 +613,32 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionMatchesOlderRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertTrue($this->matchCondition->match('[compatVersion = 4.0]'));
+               $this->assertTrue($this->matchCondition->match('[compatVersion = 7.0]'));
        }
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionMatchesSameRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertTrue($this->matchCondition->match('[compatVersion = 4.9]'));
+               $this->assertTrue($this->matchCondition->match('[compatVersion = ' . TYPO3_branch . ']'));
        }
 
        /**
         * Tests whether the compatibility version can be evaluated.
-        * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
+        * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
         *
         * @test
         */
        public function compatVersionConditionDoesNotMatchNewerRelease() {
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
-               $this->assertFalse($this->matchCondition->match('[compatVersion = 5.0]'));
+               $this->assertFalse($this->matchCondition->match('[compatVersion = 15.0]'));
        }
 
        /**
index 2015966..6c37eb0 100644 (file)
@@ -127,12 +127,23 @@ class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
                $value = $GLOBALS['LANG']->getLL('status_updateComplete');
                $message = '';
                $severity = Status::OK;
-               if (!GeneralUtility::compat_version(TYPO3_branch)) {
-                       $value = $GLOBALS['LANG']->getLL('status_updateIncomplete');
-                       $severity = Status::WARNING;
-                       $url = BackendUtility::getModuleUrl('system_InstallInstall');
-                       $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
+
+               // check if there are update wizards left to perform
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $className) {
+                               $versionAsInt = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
+                               $updateObject = GeneralUtility::makeInstance($className, $identifier, $versionAsInt, NULL, $this);
+                               if ($updateObject->shouldRenderWizard()) {
+                                       // at least one wizard was found
+                                       $value = $GLOBALS['LANG']->getLL('status_updateIncomplete');
+                                       $severity = Status::WARNING;
+                                       $url = BackendUtility::getModuleUrl('system_InstallInstall');
+                                       $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
+                                       break;
+                               }
+                       }
                }
+
                return GeneralUtility::makeInstance(Status::class, $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remainingUpdates'), $value, $message, $severity);
        }
 
index c2ca05b..a771d8d 100644 (file)
@@ -69,7 +69,9 @@ class SilentConfigurationUpgradeService {
                // #63818
                'BE/staticFileEditPath',
                // #64226
-               'BE/accessListRenderMode'
+               'BE/accessListRenderMode',
+               // #24900
+               'SYS/compat_version'
        );
 
        /**
diff --git a/typo3/sysext/install/Classes/Updates/CompatVersionUpdate.php b/typo3/sysext/install/Classes/Updates/CompatVersionUpdate.php
deleted file mode 100644 (file)
index 9a9ef3d..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\Updates;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\VersionNumberUtility;
-
-/**
- * Contains the update class for the compatibility version.
- * Used by the update wizard in the install tool.
- *
- * The various checks are defined in ext_localconf.php with the following syntax
- * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version']['<internalName>'] = [
- *      'title' => '',
- *      'version' => '700000000',
- *      'description' => '',
- *      'description_acknowledge' => ''
- * ];
- *
- * @author Sebastian Kurf├╝rst <sebastian@garbage-group.de
- */
-class CompatVersionUpdate extends AbstractUpdate {
-
-       /**
-        * @var string
-        */
-       protected $title = 'Version Compatibility';
-
-       /**
-        * Function which checks if update is needed. Called in the beginning of an update process.
-        *
-        * @param string &$description Pointer to description for the update
-        * @return bool TRUE if update is needs to be performed, FALSE otherwise.
-        */
-       public function checkForUpdate(&$description) {
-               if (!$this->compatVersionIsCurrent()) {
-                       $description = '
-                               <p>
-                                       Your current TYPO3 installation is configured to
-                                       <strong>behave like version
-                                       ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']) . '
-                                       </strong> of TYPO3. If you just upgraded from this version,
-                                       you most likely want to <strong>use new features</strong> as
-                                       well.
-                               </p>
-                               <p>
-                                       In the next step, you will see the things that need to be
-                                       adjusted to make your installation compatible with the new
-                                       features.
-                               </p>
-                       ';
-                       return TRUE;
-               }
-               return FALSE;
-       }
-
-       /**
-        * Second step: get user input if needed
-        *
-        * @param string $inputPrefix All names of form fields have to start with this. Append custom name in [ ... ]
-        * @return string HTML output
-        */
-       public function getUserInput($inputPrefix) {
-               if ($this->compatVersionIsCurrent()) {
-                       $content = '
-                               <fieldset>
-                                       <ol>
-                                               <li>
-                                                       <strong>You updated from an older version of TYPO3</strong>:
-                                               </li>
-                                               <li>
-                                                       <label for="version">Select the version where you have upgraded from:</label>
-                                                       <select name="' . $inputPrefix . '[version]" id="version">
-                       ';
-                       $versions = array(
-                               '6.2' => '<= 6.2'
-                       );
-                       foreach ($versions as $singleVersion => $caption) {
-                               $content .= '
-                                                               <option value="' . $singleVersion . '">' . $caption . '</option>
-                               ';
-                       }
-                       $content .= '
-                                                       </select>
-                                               </li>
-                                       </ol>
-                               </fieldset>
-                       ';
-               } else {
-                       $content = '
-                               <p>
-                                       TYPO3 output is currently compatible to version ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']) . '.
-                                       To use all the new features in the current TYPO3 version,
-                                       make sure you follow the guidelines below to upgrade without
-                                       problems.
-                               </p>
-                               <p>
-                                       <strong>
-                                               Follow the steps below carefully and confirm every step!
-                                       </strong>
-                                       <br />
-                                       You will see this list again after you performed the update.
-                               </p>
-                       ';
-                       $content .= $this->showChangesNeeded($inputPrefix);
-                       $content .= '
-                               <fieldset>
-                                       <ol>
-                                               <li class="labelAfter">
-                                                       <input type="checkbox" name="' . $inputPrefix . '[compatVersion][all]" id="compatVersionAll" value="1" />
-                                                       <label for="compatVersionAll">Check all (ignore selection above)</label>
-                                               </li>
-                                               <li>
-                                                       WARNING: this might break the output of your website.
-                                               </li>
-                                       </ol>
-                               </fieldset>
-                       ';
-               }
-               return $content;
-       }
-
-       /**
-        * Checks if user input is valid
-        *
-        * @param string $customMessages Pointer to output custom messages
-        * @return bool TRUE if user input is correct, then the update is performed. When FALSE, return to getUserInput
-        */
-       public function checkUserInput(&$customMessages) {
-               if ($this->compatVersionIsCurrent()) {
-                       return TRUE;
-               }
-               if ($this->userInput['compatVersion']['all']) {
-                       return TRUE;
-               }
-
-               if (
-                       !isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'])
-                       || !is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'])
-               ) {
-                       return TRUE;
-               }
-
-               $performUpdate = TRUE;
-               $oldVersion = VersionNumberUtility::convertVersionNumberToInteger($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']);
-               $newVersion = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch);
-               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) {
-                       if ($details['version'] > $oldVersion && $details['version'] <= $newVersion) {
-                               if (!$this->userInput['compatVersion'][$internalName]) {
-                                       $performUpdate = FALSE;
-                                       $customMessages = 'If you want to update the compatibility version, you need to confirm all checkboxes on the previous page.';
-                                       break;
-                               }
-                       }
-               }
-               return $performUpdate;
-       }
-
-       /**
-        * Performs the update itself
-        *
-        * @param array $dbQueries where to insert all DB queries made, so they can be shown to the user if wanted
-        * @param string $customMessages to output custom messages
-        * @return bool TRUE if update succeeded, FALSE otherwise
-        */
-       public function performUpdate(array &$dbQueries, &$customMessages) {
-               $customMessages = '';
-               // If we just set it to an older version
-               if ($this->userInput['version']) {
-                       $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!';
-               }
-               $version = $this->userInput['version'] ? $this->userInput['version'] : TYPO3_branch;
-               GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class)->setLocalConfigurationValueByPath('SYS/compat_version', $version);
-               $customMessages .= '<br />The compatibility version has been set to ' . $version . '.';
-               return TRUE;
-       }
-
-       /**
-        * Checks if compatibility version is set to current version
-        *
-        * @return bool TRUE if compat version is equal the current version
-        */
-       protected function compatVersionIsCurrent() {
-               return TYPO3_branch == $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'];
-       }
-
-       /**
-        * Show changes needed
-        *
-        * @param string $inputPrefix Input prefix to prepend all form fields with
-        * @return string HTML output
-        */
-       protected function showChangesNeeded($inputPrefix = '') {
-               if (
-                       !isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'])
-                       || !is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'])
-               ) {
-                       return '';
-               }
-
-               $oldVersion = VersionNumberUtility::convertVersionNumberToInteger($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']);
-               $newVersion = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch);
-
-               $upgradeWizardBoxes = '';
-               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) {
-                       if ($details['version'] > $oldVersion && $details['version'] <= $newVersion) {
-                               $description = str_replace(LF, '<br />', $details['description']);
-                               $description_acknowledge = isset($details['description_acknowledge']) ? str_replace(LF, '<br />', $details['description_acknowledge']) : '';
-                               $upgradeWizardBoxes .= '
-                                       <div style="border: 1px solid; padding: 0 10px 10px 10px; margin: 10px; width: 500px;">
-                                               <h3>' . (isset($details['title']) ? $details['title'] : $internalName) . '</h3>
-                                               ' . $description . ($description_acknowledge !== '' ? '<p>' . $description_acknowledge . '</p>' : '') . ($inputPrefix !== '' ? '
-                                                       <fieldset>
-                                                               <ol>
-                                                                       <li class="labelAfter">
-                                                                               <input type="checkbox" name="' . $inputPrefix . '[compatVersion][' . $internalName . ']" id="compatVersion' . $internalName . '" value="1" />
-                                                                               <label for="compatVersion' . $internalName . '">Acknowledged</label>
-                                                                       </li>
-                                                               </ol>
-                                                       </fieldset>
-                                               ' : '') . '
-                                       </div>';
-                       }
-               }
-               return $upgradeWizardBoxes;
-       }
-
-}
index 097888f..e7c460e 100644 (file)
@@ -1,9 +1,6 @@
 <?php
 defined('TYPO3_MODE') or die();
 
-// All versions
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['changeCompatibilityVersion'] = \TYPO3\CMS\Install\Updates\CompatVersionUpdate::class;
-
 // TYPO3 CMS 7
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['backendUserStartModule'] = \TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate::class;
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['languageIsoCode'] = \TYPO3\CMS\Install\Updates\LanguageIsoCodeUpdate::class;