| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @author Victor Dubiniuk <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (c) 2015, ownCloud, Inc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license AGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This code is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * it under the terms of the GNU Affero General Public License, version 3, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * as published by the Free Software Foundation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * You should have received a copy of the GNU Affero General Public License, version 3, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | namespace Owncloud\Updater\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Owncloud\Updater\Utils\Checkpoint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Owncloud\Updater\Utils\FilesystemHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Symfony\Component\Console\Input\InputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Symfony\Component\Process\Exception\ProcessFailedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Owncloud\Updater\Utils\OccRunner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Owncloud\Updater\Utils\ZipExtractor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * Class ExecuteCoreUpgradeScriptsCommand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @package Owncloud\Updater\Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | class ExecuteCoreUpgradeScriptsCommand extends Command { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 * @var OccRunner $occRunner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	protected $occRunner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * ExecuteCoreUpgradeScriptsCommand constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * @param null|string $occRunner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	public function __construct($occRunner){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		parent::__construct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$this->occRunner = $occRunner; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	protected function configure(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		$this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 				->setName('upgrade:executeCoreUpgradeScripts') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 				->setDescription('execute core upgrade scripts [danger, might take long]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 * @param InputInterface $input | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * @param OutputInterface $output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * @throws \Exception | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 	protected function execute(InputInterface $input, OutputInterface $output){ | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 		$locator = $this->container['utils.locator']; | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 		/** @var FilesystemHelper $fsHelper */ | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 		$fsHelper = $this->container['utils.filesystemhelper']; | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 		$registry = $this->container['utils.registry']; | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 		$fetcher = $this->container['utils.fetcher']; | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 		/** @var Checkpoint $checkpoint */ | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  | 		$checkpoint = $this->container['utils.checkpoint']; | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  | 		$installedVersion = implode('.', $locator->getInstalledVersion()); | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  | 		$registry->set('installedVersion', $installedVersion); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  | 		/** @var  \Owncloud\Updater\Utils\Feed $feed */ | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  | 		$feed = $registry->get('feed'); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 		if ($feed){ | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 			$path = $fetcher->getBaseDownloadPath($feed); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 			$fullExtractionPath = $locator->getExtractionBaseDir() . '/' . $feed->getVersion(); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | 			if (file_exists($fullExtractionPath)){ | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  | 				$fsHelper->removeIfExists($fullExtractionPath); | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  | 			try{ | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  | 				$fsHelper->mkdir($fullExtractionPath, true); | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  | 			} catch (\Exception $e){ | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  | 					$output->writeln('Unable create directory ' . $fullExtractionPath); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  | 					throw $e; | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  | 			$output->writeln('Extracting source into ' . $fullExtractionPath); | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | 			$extractor = new ZipExtractor($path, $fullExtractionPath, $output); | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  | 			try{ | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  | 				$extractor->extract(); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  | 			} catch (\Exception $e){ | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  | 				$output->writeln('Extraction has been failed'); | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  | 				$fsHelper->removeIfExists($locator->getExtractionBaseDir()); | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  | 				throw $e; | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  | 			$tmpDir = $locator->getExtractionBaseDir() . '/' . $installedVersion; | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  | 			$fsHelper->removeIfExists($tmpDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  | 			$fsHelper->mkdir($tmpDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  | 			$oldSourcesDir = $locator->getOwncloudRootPath(); | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  | 			$newSourcesDir = $fullExtractionPath . '/owncloud'; | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  | 			$packageVersion = $this->loadVersion($newSourcesDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  | 			$allowedPreviousVersions = $this->loadAllowedPreviousVersions($newSourcesDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  | 			if (!$this->isUpgradeAllowed($installedVersion, $packageVersion, $allowedPreviousVersions)){ | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  | 				$message = sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  | 					'Update from %s to %s is not possible. Updates between multiple major versions and downgrades are unsupported.', | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  | 					$installedVersion, | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  | 					$packageVersion | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  | 				$this->getApplication()->getLogger()->error($message); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  | 				$output->writeln('<error>'. $message .'</error>'); | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  | 				return 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  | 			foreach ($locator->getRootDirContent() as $dir){ | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  | 				$this->getApplication()->getLogger()->debug('Replacing ' . $dir); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  | 				$fsHelper->tripleMove($oldSourcesDir, $newSourcesDir, $tmpDir, $dir); | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  | 			$fsHelper->copyr($tmpDir . '/config/config.php', $oldSourcesDir . '/config/config.php'); | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  | 			//Remove old apps | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  | 			$appDirectories = $fsHelper->scandirFiltered($oldSourcesDir . '/apps'); | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  | 			foreach ($appDirectories as $appDirectory){ | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  | 				$fsHelper->rmdirr($oldSourcesDir . '/apps/' . $appDirectory); | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  | 			//Put new shipped apps | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  | 			$newAppsDir = $fullExtractionPath . '/owncloud/apps'; | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  | 			$newAppsList = $fsHelper->scandirFiltered($newAppsDir); | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  | 			foreach ($newAppsList as $appId){ | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  | 				$output->writeln('Copying the application ' . $appId); | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  | 				$fsHelper->copyr($newAppsDir . '/' . $appId, $locator->getOwnCloudRootPath() . '/apps/' . $appId, false); | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  | 			try { | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  | 				$plain = $this->occRunner->run('upgrade'); | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  | 				$output->writeln($plain); | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  | 			} catch (ProcessFailedException $e){ | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  | 				$lastCheckpointId = $checkpoint->getLastCheckpointId(); | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  | 				if ($lastCheckpointId){ | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  | 					$lastCheckpointPath = $checkpoint->getCheckpointPath($lastCheckpointId); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  | 					$fsHelper->copyr($lastCheckpointPath . '/apps', $oldSourcesDir . '/apps', false); | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  | 				if ($e->getProcess()->getExitCode() != 3){ | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  | 					throw ($e); | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 8 |  | 	public function isUpgradeAllowed($installedVersion, $packageVersion, $canBeUpgradedFrom){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 8 |  | 		if (version_compare($installedVersion, $packageVersion, '<=')){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 5 |  | 			foreach ($canBeUpgradedFrom as $allowedPreviousVersion){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 5 |  | 				if (version_compare($allowedPreviousVersion, $installedVersion, '<=')){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 5 |  | 					return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 3 |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 * @param string $pathToPackage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	protected function loadVersion($pathToPackage){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		require  $pathToPackage . '/version.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		/** @var $OC_Version array */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		return implode('.', $OC_Version); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 	 * @param string $pathToPackage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	 * @return string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 2 |  | 	protected function loadAllowedPreviousVersions($pathToPackage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 2 |  | 		$canBeUpgradedFrom = $this->loadCanBeUpgradedFrom($pathToPackage); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 | 2 |  | 		$firstItem = reset($canBeUpgradedFrom); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 2 |  | 		if (!is_array($firstItem)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 | 1 |  | 			$canBeUpgradedFrom = [$canBeUpgradedFrom]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 1 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 2 |  | 		$allowedVersions = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 2 |  | 		foreach ($canBeUpgradedFrom as $version){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 2 |  | 			$allowedVersions[] = implode('.', $version); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 2 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 2 |  | 		return $allowedVersions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	 * @param string $pathToPackage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	protected function loadCanBeUpgradedFrom($pathToPackage){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		require $pathToPackage . '/version.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 		/** @var array $OC_VersionCanBeUpgradedFrom */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		return $OC_VersionCanBeUpgradedFrom; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 213 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 214 |  |  |  | 
            
                        
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.