[BUGFIX] Upgrade wizard to fill default EM repository
authorGeorg Ringer <mail@ringerge.org>
Mon, 10 Sep 2012 21:47:23 +0000 (23:47 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 12 Sep 2012 06:11:53 +0000 (08:11 +0200)
An upgrade wizard is needed to add the default
repository of the EM. Otherwise the EM crashes

Change-Id: I3d254fae0bc1e937fd18b84b42df13d99a1b9ddc
Fixes: #40508
Releases: 6.0
Reviewed-on: http://review.typo3.org/14506
Reviewed-by: Marcus Schwemer
Tested-by: Marcus Schwemer
Reviewed-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/install/Classes/CoreUpdates/ExtensionManagerRepositories.php [new file with mode: 0644]
typo3/sysext/install/ext_localconf.php

diff --git a/typo3/sysext/install/Classes/CoreUpdates/ExtensionManagerRepositories.php b/typo3/sysext/install/Classes/CoreUpdates/ExtensionManagerRepositories.php
new file mode 100644 (file)
index 0000000..52f8c9a
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace TYPO3\CMS\Install\CoreUpdates;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Georg Ringer <typo3@ringerge.org>
+ *  All rights reserved
+ *
+ *  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.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  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!
+ ***************************************************************/
+/**
+ * Contains the update class for filling the basic repository record of the extension manager
+ *
+ * @author Georg Ringer <typo3@ringerge.org>
+ */
+class ExtensionManagerRepositories extends \TYPO3\CMS\Install\Updates\AbstractUpdate {
+
+       protected $title = 'Add the default extension manager repository';
+
+       /**
+        * Checks if an update is needed
+        *
+        * @param string &$description: The description for the update
+        * @return boolean Whether an update is needed (TRUE) or not (FALSE)
+        */
+       public function checkForUpdate(&$description) {
+               $result = FALSE;
+               $description = 'Add the default extension manager repository to the database.';
+
+               $databaseTables = $GLOBALS['TYPO3_DB']->admin_get_tables();
+               if (!isset($databaseTables['tx_extensionmanager_domain_model_repository'])) {
+                       $result = TRUE;
+               } else {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'tx_extensionmanager_domain_model_repository');
+                       if ($count === 0) {
+                               $result = TRUE;
+                       }
+               }
+               return $result;
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param array &$dbQueries: queries done in this update
+        * @param mixed &$customMessages: custom messages
+        * @return boolean Whether it worked (TRUE) or not (FALSE)
+        */
+       public function performUpdate(array &$dbQueries, &$customMessages) {
+               $result = FALSE;
+               $sqlFile = \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . DIRECTORY_SEPARATOR . 'ext_tables_static+adt.sql';
+               $sqlStatements = explode(';', \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($sqlFile));
+
+               foreach ($sqlStatements as $sqlStatement) {
+                       if (trim($sqlStatement) !== '') {
+                               $res = $GLOBALS['TYPO3_DB']->sql_query($sqlStatement);
+                               $dbQueries[] = $sqlStatement;
+                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
+                                       $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
+                               } else {
+                                       $result = TRUE;
+                               }
+                       }
+               }
+               return $result;
+       }
+
+}
+
+?>
\ No newline at end of file
index dc0c27e..d390b7a 100644 (file)
@@ -46,6 +46,7 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_init'] = 'T
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_images'] = 'TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard';
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_uploads'] = 'TYPO3\\CMS\\Install\\Updates\\TtContentUploadsUpdateWizard';
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_filemounts'] = 'TYPO3\\CMS\\Install\\Updates\\FilemountUpdateWizard';
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_images'] = 'TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard';
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_uploads'] = 'TYPO3\\CMS\\Install\\Updates\\TtContentUploadsUpdateWizard';
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_filemounts'] = 'TYPO3\\CMS\\Install\\Updates\\FilemountUpdateWizard';
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['extensionManagerRepositories'] = 'TYPO3\\CMS\\Install\\CoreUpdates\\ExtensionManagerRepositories';
 // Version 4.7: Migrate the flexforms of MediaElement
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['mediaElementFlexform'] = 'TYPO3\\CMS\\Install\\CoreUpdates\\MediaFlexformUpdate';
 ?>
\ No newline at end of file
 // Version 4.7: Migrate the flexforms of MediaElement
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['mediaElementFlexform'] = 'TYPO3\\CMS\\Install\\CoreUpdates\\MediaFlexformUpdate';
 ?>
\ No newline at end of file