Esempio n. 1
0
 public function forceUpgrade(Setup_Upgrade $upgrader, Application $app)
 {
     $from_version = $this->get_version();
     $app['phraseanet.cache-service']->flushAll();
     // Executes stuff before applying patches
     $app['phraseanet.pre-schema-upgrader']->apply($app);
     $finder = new Finder();
     $in = [];
     $path = $app['cache.path'];
     $in[] = $path . '/minify/';
     $in[] = $path . '/twig/';
     $in[] = $path . '/translations/';
     $in[] = $path . '/profiler/';
     $in[] = $path . '/doctrine/';
     $in[] = $path . '/serializer/';
     $finder->in(array_filter($in, function ($path) {
         return is_dir($path);
     }))->depth(0)->ignoreVCS(true)->ignoreDotFiles(true);
     $app['filesystem']->remove($finder);
     foreach (['config/custom_files/' => 'www/custom/', 'config/minilogos/' => 'www/custom/minilogos/', 'config/stamp/' => 'www/custom/stamp/', 'config/status/' => 'www/custom/status/', 'config/wm/' => 'www/custom/wm/'] as $source => $target) {
         $app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target, null, array('override' => true));
     }
     // do not apply patches
     // just update old database schema
     // it is need before applying patches
     $advices = $this->upgradeDB(false, $app);
     foreach ($this->get_databoxes() as $s) {
         $advices = array_merge($advices, $s->upgradeDB(false, $app));
     }
     // then apply patches
     $advices = $this->upgradeDB(true, $app);
     foreach ($this->get_databoxes() as $s) {
         $advices = array_merge($advices, $s->upgradeDB(true, $app));
     }
     $this->post_upgrade($app);
     $app['phraseanet.cache-service']->flushAll();
     if ($app['orm.em']->getConnection()->getDatabasePlatform()->supportsAlterTable()) {
         $tool = new SchemaTool($app['orm.em']);
         $metas = $app['orm.em']->getMetadataFactory()->getAllMetadata();
         $tool->updateSchema($metas, true);
     }
     if (version::lt($from_version, '3.1')) {
         $upgrader->addRecommendation($app->trans('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.1');
     } elseif (version::lt($from_version, '3.5')) {
         $upgrader->addRecommendation($app->trans('Your install requires data migration, please execute the following command'), 'bin/setup system:upgrade-datas --from=3.5');
     }
     if (version::lt($from_version, '3.7')) {
         $upgrader->addRecommendation($app->trans('Your install might need to re-read technical datas'), 'bin/console records:rescan-technical-datas');
         $upgrader->addRecommendation($app->trans('Your install might need to build some sub-definitions'), 'bin/console records:build-missing-subdefs');
     }
     return $advices;
 }