Example #1
0
 /**
  * Updates database and all related caches according to changes of extended entities
  *
  * @param bool $updateRouting
  *
  * @return bool
  */
 public function updateDatabase($updateRouting = false)
 {
     set_time_limit(0);
     // disable Profiler to avoid an exception in DoctrineDataCollector
     // in case if entity classes and Doctrine metadata are not match each other in the current process
     if ($this->profiler) {
         $this->profiler->disable();
     }
     $this->maintenance->activate();
     $isSuccess = $this->executeCommands($this->commands);
     if ($isSuccess && $updateRouting) {
         $isSuccess = $this->executeCommands($this->updateRoutingCommands);
     }
     return $isSuccess;
 }
Example #2
0
 /**
  * Update database and generate extended field
  *
  * @param bool $generateProxies
  * @return bool
  */
 public function updateDatabase($generateProxies = true)
 {
     set_time_limit(0);
     $this->maintenance->activate();
     $exitCode = 0;
     foreach ($this->commands as $command => $options) {
         $code = $this->commandExecutor->runCommand($command, $options, $this->logger);
         if ($code !== 0) {
             $exitCode = $code;
         }
     }
     $isSuccess = $exitCode === 0;
     if ($isSuccess && $generateProxies) {
         $this->generateProxies();
     }
     return $isSuccess;
 }
Example #3
0
 /**
  * Updates database and all related caches according to changes of extended entities
  *
  * @param bool $warmUpConfigCache Whether the entity config cache should be warmed up
  *                                after database schema is changed
  * @param bool $updateRouting     Whether routes should be updated after database schema is changed
  *
  * @return bool
  */
 public function updateDatabase($warmUpConfigCache = false, $updateRouting = false)
 {
     set_time_limit(0);
     // disable Profiler to avoid an exception in DoctrineDataCollector
     // in case if entity classes and Doctrine metadata are not match each other in the current process
     if ($this->profiler) {
         $this->profiler->disable();
     }
     $this->maintenance->activate();
     $commands = ['oro:entity-extend:update-config' => [], 'oro:entity-extend:cache:warmup' => [], 'oro:entity-extend:update-schema' => []];
     if ($warmUpConfigCache) {
         $commands = array_merge($commands, ['oro:entity-config:cache:warmup' => []]);
     }
     if ($updateRouting) {
         $commands = array_merge($commands, ['router:cache:clear' => [], 'fos:js-routing:dump' => []]);
     }
     return $this->executeCommands($commands);
 }
Example #4
0
 /**
  * @param string $packageName
  * @throws VerboseException
  */
 public function update($packageName)
 {
     $this->logger->info(sprintf('%s updating begin', $packageName));
     $this->maintenance->activate();
     $previousInstalled = $this->getInstalled();
     $currentPackage = $this->findInstalledPackage($packageName);
     $this->updateComposerJsonFile($currentPackage, '*');
     $this->scriptRunner->removeApplicationCache();
     if ($this->doInstall($packageName)) {
         $currentlyInstalled = $this->getInstalled();
         $changeSetBuilder = new ChangeSetBuilder();
         list($installedPackages, $updatedPackages, $uninstalledPackages) = $changeSetBuilder->build($previousInstalled, $currentlyInstalled);
         array_map(function (PackageInterface $p) {
             $this->scriptRunner->runInstallScripts($p);
         }, $installedPackages);
         $fetchPreviousInstalledPackageVersion = function ($packageName) use($previousInstalled) {
             foreach ($previousInstalled as $p) {
                 if ($p->getName() == $packageName) {
                     return $p->getVersion();
                 }
             }
             return '';
         };
         array_map(function (PackageInterface $p) use($fetchPreviousInstalledPackageVersion) {
             $previousInstalledPackageVersion = $fetchPreviousInstalledPackageVersion($p->getName());
             $this->scriptRunner->runUpdateScripts($p, $previousInstalledPackageVersion);
         }, $updatedPackages);
         array_map(function (PackageInterface $p) {
             $this->scriptRunner->runUninstallScripts($p);
         }, $uninstalledPackages);
         $this->scriptRunner->clearApplicationCache();
         $this->scriptRunner->runPlatformUpdate();
         $this->scriptRunner->clearDistApplicationCache();
         $justInstalledPackage = $this->findInstalledPackage($packageName);
         $this->updateComposerJsonFile($justInstalledPackage, $justInstalledPackage->getPrettyVersion());
     } else {
         $this->updateComposerJsonFile($currentPackage, $currentPackage->getPrettyVersion());
         $errorMessage = sprintf('%s can\'t be updated!', $packageName);
         $this->logger->error($errorMessage);
         $this->logger->error($this->composerIO->getOutput());
         throw new VerboseException($errorMessage, $this->composerIO->getOutput());
     }
     $this->logger->info(sprintf('%s updated', $packageName));
 }
Example #5
0
 public function testModeOff()
 {
     $this->dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(Events::MAINTENANCE_OFF));
     $this->assertTrue($this->mode->off());
 }