[BUGFIX] Show flash message if package states are not writable 75/24975/4
authorStefan Rotsch <stefan.rotsch@aoemedia.de>
Wed, 23 Oct 2013 13:14:45 +0000 (15:14 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 6 Nov 2013 23:12:44 +0000 (00:12 +0100)
When trying to install/uninstall an extension and PackageStates.php
is not writable, an error flash message is shown.

Resolves: #53077
Releases: 6.2
Change-Id: I71bba56361a4cc85fb253199acbfee5829defa29
Reviewed-on: https://review.typo3.org/24975
Reviewed-by: Steffen Müller
Tested-by: Steffen Müller
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/Exception/PackageStatesFileNotWritableException.php [new file with mode: 0644]
typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/PackageManager.php
typo3/sysext/core/ext_autoload.php
typo3/sysext/extensionmanager/Classes/Controller/ActionController.php

diff --git a/typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/Exception/PackageStatesFileNotWritableException.php b/typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/Exception/PackageStatesFileNotWritableException.php
new file mode 100644 (file)
index 0000000..f00355e
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace TYPO3\Flow\Package\Exception;
+
+/*                                                                        *
+ * This script belongs to the TYPO3 Flow framework.                       *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License, either version 3   *
+ * of the License, or (at your option) any later version.                 *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * "Package states file not writable" Exception
+ *
+ */
+class PackageStatesFileNotWritableException extends \TYPO3\Flow\Package\Exception {
+
+}
+?>
\ No newline at end of file
index 631122f..c71dac4 100644 (file)
@@ -929,6 +929,12 @@ class PackageManager implements \TYPO3\Flow\Package\PackageManagerInterface {
                                unset($packageConfiguration['dependencies']);
                        }
                }
+               if (!@is_writable($this->packageStatesPathAndFilename)) {
+                       throw new \TYPO3\Flow\Package\Exception\PackageStatesFileNotWritableException(
+                               sprintf('We could not update the list of installed packages because the file %s is not writable. Please, check the file system permissions for this file and make sure that the web server can update it.', $this->packageStatesPathAndFilename),
+                               1382449759
+                       );
+               }
                $packageStatesCode = "<?php\n$fileDescription\nreturn " . var_export($this->packageStatesConfiguration, TRUE) . "\n ?>";
                @file_put_contents($this->packageStatesPathAndFilename, $packageStatesCode);
        }
index 5c0b8b2..b452e1d 100644 (file)
@@ -26,6 +26,7 @@ $flowClasses = array(
        'typo3\flow\package\exception\missingpackagemanifestexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/MissingPackageManifestException.php',
        'typo3\flow\package\exception\packagekeyalreadyexistsexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/PackageKeyAlreadyExistsException.php',
        'typo3\flow\package\exception\packagerepositoryexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/PackageRepositoryException.php',
+       'typo3\flow\package\exception\packagestatesfilenotwritableexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/PackageStatesFileNotWritableException.php',
        'typo3\flow\package\exception\protectedpackagekeyexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/ProtectedPackageKeyException.php',
        'typo3\flow\package\exception\unknownpackageexception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception/UnknownPackageException.php',
        'typo3\flow\package\exception' => $flowClassesPath . 'TYPO3/Flow/Package/Exception.php',
index ee07af6..c9960c8 100644 (file)
@@ -85,6 +85,14 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
                                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
                                TRUE
                        );
+               } catch (\TYPO3\Flow\Package\Exception\PackageStatesFileNotWritableException $e) {
+                       $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                               htmlspecialchars($e->getMessage()),
+                               '',
+                               \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
+                               TRUE
+                       );
                        $this->getControllerContext()->getFlashMessageQueue()->enqueue($flashMessage);
                }
                $this->redirect('index', 'List', NULL, array(self::TRIGGER_RefreshModuleMenu => TRUE));