[BUGFIX] PackageManager initialize() signature is incompatible 95/28195/7
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 9 Mar 2014 15:22:23 +0000 (16:22 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 11 Mar 2014 18:12:21 +0000 (19:12 +0100)
PackageManagerInterface contains following method declaration:

 public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap);

however in the PackageManager the signature is:

  public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap,
    $packagesBasePath = FLOW_PATH_PACKAGES,
    $packageStatesPathAndFilename = '')

This will create a fatal error on some versions of php and when running
unit tests on hhvm (of CMS), see
http://php.net/manual/en/language.oop5.interfaces.php

"The class implementing the interface must use the exact same method
signatures as are defined in the interface. Not doing so will result
in a fatal error."

This change updates the method signature of the PackageManager to be in
line with the interface.

Resolves: #56660
Related: #56409
Releases: 6.2
Change-Id: Iab7ae0d6d9809abe7cb6f9b73adb77f06d2f0820
Reviewed-on: https://review.typo3.org/28195
Reviewed-by: Thomas Maroschik
Reviewed-by: Sebastian Müller
Reviewed-by: Sebastian Fischer
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/PackageManager.php
typo3/sysext/core/Resources/PHP/TYPO3.Flow/Classes/TYPO3/Flow/Package/PackageManagerInterface.php
typo3/sysext/core/Resources/PHP/TYPO3.Flow/README

index bdf2fe5..ef5a68b 100644 (file)
@@ -314,7 +314,7 @@ class Bootstrap {
                $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader'));
                $packageManager->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core'));
                $packageManager->injectDependencyResolver(Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\DependencyResolver'));
-               $packageManager->initialize($this, PATH_site);
+               $packageManager->initialize($this);
                Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager);
                $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
                return $this;
index 011e052..e8a0e4a 100644 (file)
@@ -67,6 +67,12 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         */
        protected $runtimeActivatedPackages = array();
 
+       /**
+        * Absolute path leading to the various package directories
+        * @var string
+        */
+       protected $packagesBasePath = PATH_site;
+
        /**
         * Constructor
         */
@@ -104,21 +110,18 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         * Initializes the package manager
         *
         * @param \TYPO3\CMS\Core\Core\Bootstrap|\TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap; Flow Bootstrap is here by intention to keep the PackageManager valid to the interface
-        * @param string $packagesBasePath Absolute path of the Packages directory
-        * @param string $packageStatesPathAndFilename
         * @return void
         */
-       public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap, $packagesBasePath = PATH_site, $packageStatesPathAndFilename = '') {
-
+       public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap) {
                $this->bootstrap = $bootstrap;
-               $this->packagesBasePath = $packagesBasePath;
-               $this->packageStatesPathAndFilename = ($packageStatesPathAndFilename === '') ? PATH_typo3conf . 'PackageStates.php' : $packageStatesPathAndFilename;
+               $this->packageStatesPathAndFilename = PATH_typo3conf . 'PackageStates.php';
                $this->packageFactory = new PackageFactory($this);
 
                $this->loadPackageStates();
 
                $requiredList = array();
                foreach ($this->packages as $packageKey => $package) {
+                       /** @var $package Package */
                        $protected = $package->isProtected();
                        if ($protected) {
                                $requiredList[$packageKey] = $package;
@@ -152,6 +155,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                $this->classLoader->setCacheIdentifier($cacheIdentifier)->setPackages($this->activePackages);
 
                foreach ($this->activePackages as $package) {
+                       /** @var $package Package */
                        $package->boot($bootstrap);
                }
 
@@ -287,7 +291,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        }
                        try {
                                $composerManifest = self::getComposerManifest($composerManifestPath);
-                               $packageKey = \TYPO3\CMS\Core\Package\PackageFactory::getPackageKeyFromManifest($composerManifest, $packagePath, $packagesBasePath);
+                               $packageKey = PackageFactory::getPackageKeyFromManifest($composerManifest, $packagePath, $packagesBasePath);
                                $this->composerNameToPackageKeyMap[strtolower($composerManifest->name)] = $packageKey;
                                $this->packageStatesConfiguration['packages'][$packageKey]['manifestPath'] = substr($composerManifestPath, strlen($packagePath)) ? : '';
                                $this->packageStatesConfiguration['packages'][$packageKey]['composerName'] = $composerManifest->name;
@@ -304,7 +308,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        $this->packageStatesConfiguration['packages'][$packageKey]['packagePath'] = str_replace($this->packagesBasePath, '', $packagePath);
 
                        // Change this to read the target from Composer or any other source
-                       $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = \TYPO3\Flow\Package\Package::DIRECTORY_CLASSES;
+                       $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = Package::DIRECTORY_CLASSES;
                }
 
                $registerOnlyNewPackages = !empty($this->packages);
@@ -399,7 +403,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        /**
         * Register a native Flow package
         *
-        * @param string $packageKey The Package to be registered
+        * @param \TYPO3\Flow\Package\PackageInterface $package The Package to be registered
         * @param boolean $sortAndSave allows for not saving packagestates when used in loops etc.
         * @return \TYPO3\Flow\Package\PackageInterface
         * @throws \TYPO3\Flow\Package\Exception\CorruptPackageException
@@ -566,10 +570,11 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
 
        /**
         * @param string $packageKey
+        * @return bool
         */
        public function isPackageFrozen($packageKey) {
                $package = $this->getPackage($packageKey);
-               parent::isPackageFrozen($package->getPackageKey());
+               return parent::isPackageFrozen($package->getPackageKey());
        }
 
        /**
index 1853040..3ce66f0 100644 (file)
@@ -68,7 +68,7 @@ class PackageManager implements \TYPO3\Flow\Package\PackageManagerInterface {
         * Absolute path leading to the various package directories
         * @var string
         */
-       protected $packagesBasePath;
+       protected $packagesBasePath = FLOW_PATH_PACKAGES;
 
        /**
         * @var string
@@ -123,16 +123,13 @@ class PackageManager implements \TYPO3\Flow\Package\PackageManagerInterface {
         * Initializes the package manager
         *
         * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
-        * @param string $packagesBasePath Absolute path of the Packages directory
-        * @param string $packageStatesPathAndFilename
         * @return void
         */
-       public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap, $packagesBasePath = FLOW_PATH_PACKAGES, $packageStatesPathAndFilename = '') {
+       public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap) {
                $this->systemLogger = new \TYPO3\Flow\Log\EarlyLogger();
 
                $this->bootstrap = $bootstrap;
-               $this->packagesBasePath = $packagesBasePath;
-               $this->packageStatesPathAndFilename = ($packageStatesPathAndFilename === '') ? FLOW_PATH_CONFIGURATION . 'PackageStates.php' : $packageStatesPathAndFilename;
+               $this->packageStatesPathAndFilename = $this->packageStatesPathAndFilename ?: FLOW_PATH_CONFIGURATION . 'PackageStates.php';
                $this->packageFactory = new PackageFactory($this);
 
                $this->loadPackageStates();
index 55a3dcf..1d7074b 100644 (file)
@@ -19,9 +19,9 @@ namespace TYPO3\Flow\Package;
 interface PackageManagerInterface {
 
        /**
-        * Initializes the package manager.
+        * Initializes the package manager
         *
-        * @param \TYPO3\Flow\Core\Bootstrap $bootstrap
+        * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
         * @return void
         */
        public function initialize(\TYPO3\Flow\Core\Bootstrap $bootstrap);
index b183fa7..bac8181 100644 (file)
@@ -8,4 +8,8 @@ The following has been changed:
 
 It has been imported from this commmit hash:
 
-327db44575d90f5f7309ec9febaa444fc2ac8a4e
\ No newline at end of file
+327db44575d90f5f7309ec9febaa444fc2ac8a4e
+
+2014-03-10 Changes to PackageManager classes
+* The PackageManagerInterface dictates a constructor with only 1 parameter.
+  The PackageManager classes and the calls are adopted accordingly.
\ No newline at end of file