Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
[CoreBundle] Update improvements (#2520)
Browse files Browse the repository at this point in the history
* [CoreBundle] VERSION.txt building script.

* Removing the branch creation.

* wip

* Removing version file

* Uncommenting stuff

* Create VERSION.txt

* wip

* Changelog tracking

* md file

* use printf instead of echo

* md link

* double space ending md

* starts with hyphen

* Changelog links

* uncomment

* add title

* Register the current version at the v10 upgrade.

* Saving before doing stuff that might brake everything

* db version registration

* wip

* Claroline update command allows to use version

* phpmd

* phpmd

* Remove outdated unit tests

* test if db up to date

* Removing the previous repository snapshot from OperationExecutor update

* phpmd
  • Loading branch information
ngodfraind authored and LaurentGruber committed Jun 28, 2017
1 parent f512e07 commit ef7c925
Show file tree
Hide file tree
Showing 124 changed files with 1,032 additions and 826 deletions.
3 changes: 3 additions & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
10.0.0-rc4
392f397fcdd7cfe5f5f288cf5f09c21b26e69247
master
Empty file added changelogs/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions main/core/ClarolineCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use Claroline\CoreBundle\DependencyInjection\Compiler\RouterPass;
use Claroline\CoreBundle\DependencyInjection\Compiler\RuleConstraintsConfigPass;
use Claroline\CoreBundle\DependencyInjection\Factory\ApiFactory;
use Claroline\CoreBundle\Library\DistributionPluginBundle;
use Claroline\CoreBundle\Library\Installation\AdditionalInstaller;
use Claroline\CoreBundle\Library\PluginBundle;
use Claroline\KernelBundle\Bundle\AutoConfigurableInterface;
use Claroline\KernelBundle\Bundle\ConfigurationBuilder;
use Claroline\KernelBundle\Bundle\ConfigurationProviderInterface;
Expand All @@ -34,7 +34,7 @@
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Zenstruck\Bundle\FormBundle\ZenstruckFormBundle;

class ClarolineCoreBundle extends PluginBundle implements AutoConfigurableInterface, ConfigurationProviderInterface
class ClarolineCoreBundle extends DistributionPluginBundle implements AutoConfigurableInterface, ConfigurationProviderInterface
{
public function build(ContainerBuilder $container)
{
Expand Down
24 changes: 12 additions & 12 deletions main/core/Command/AbstractPluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Claroline\CoreBundle\Command;

use Claroline\BundleRecorder\Detector\Detector;
use Claroline\CoreBundle\Library\DistributionPluginBundle;
use Psr\Log\LogLevel;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Claroline\BundleRecorder\Detector\Detector;
use Claroline\CoreBundle\Library\PluginBundle;

/**
* This class contains common methods for the plugin install/uninstall commands.
Expand Down Expand Up @@ -68,8 +68,8 @@ protected function getPlugin(InputInterface $input, $fromKernel = true)
if ($name === $bundleName) {
$bundle = new $bundleFqcn($kernel);

if (!$bundle instanceof PluginBundle) {
throw new \Exception("Bundle {$bundle->getName()} must extend PluginBundle");
if (!$bundle instanceof DistributionPluginBundle) {
throw new \Exception("Bundle {$bundle->getName()} must extend DistributionPluginBundle");
}

return $bundle;
Expand All @@ -83,11 +83,11 @@ protected function getPluginInstaller(OutputInterface $output)
{
/** @var \Claroline\CoreBundle\Library\Installation\Plugin\Installer $installer */
$installer = $this->getContainer()->get('claroline.plugin.installer');
$verbosityLevelMap = array(
$verbosityLevelMap = [
LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL,
LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL,
LogLevel::DEBUG => OutputInterface::VERBOSITY_NORMAL,
);
];
$consoleLogger = new ConsoleLogger($output, $verbosityLevelMap);
$installer->setLogger($consoleLogger);

Expand All @@ -98,7 +98,7 @@ protected function getPluginInstaller(OutputInterface $output)
* @todo Remove ?
*
* Clears the cache in production environment (mandatory after plugin
* installation/uninstallation).
* installation/uninstallation)
*
* @param OutputInterface $output
*/
Expand All @@ -108,10 +108,10 @@ protected function resetCache(OutputInterface $output)
$command = $this->getApplication()->find('cache:clear');

$input = new ArrayInput(
array(
[
'command' => 'cache:clear',
'--no-warmup' => true,
)
]
);

$command->run($input, $output);
Expand All @@ -130,11 +130,11 @@ protected function installAssets(OutputInterface $output)
$webDir = $this->getContainer()->getParameter('kernel.root_dir').'/../web';
$command = $this->getApplication()->find('assets:install');
$input = new ArrayInput(
array(
[
'command' => 'assets:install',
'target' => realpath($webDir),
'--symlink' => true,
)
]
);
$command->run($input, $output);
}
Expand Down
4 changes: 2 additions & 2 deletions main/core/Command/Dev/TestUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Claroline\CoreBundle\Command\Dev;

use Claroline\CoreBundle\Entity\Plugin;
use Claroline\CoreBundle\Library\PluginBundle;
use Claroline\CoreBundle\Library\DistributionPluginBundle;
use Psr\Log\LogLevel;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$container = $this->getContainer();
$bundleName = $input->getArgument('bundle');
$bundle = $container->get('kernel')->getBundle($bundleName);
$installerType = $bundle instanceof PluginBundle ?
$installerType = $bundle instanceof DistributionPluginBundle ?
'claroline.plugin.installer' :
'claroline.installation.manager';

Expand Down
31 changes: 23 additions & 8 deletions main/core/Command/PlatformUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@

use Claroline\CoreBundle\Library\Maintenance\MaintenanceHandler;
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
use JMS\DiExtraBundle\Annotation\Inject;
use JMS\DiExtraBundle\Annotation\InjectParams;
use JMS\DiExtraBundle\Annotation\Service;
use Psr\Log\LogLevel;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\Inject;
use JMS\DiExtraBundle\Annotation\InjectParams;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand All @@ -41,6 +42,12 @@ protected function configure()
->setDescription(
'Updates, installs or uninstalls the platform packages brought by composer.'
);
$this->setDefinition(
[
new InputArgument('from_version', InputArgument::OPTIONAL, 'from version'),
new InputArgument('to_version', InputArgument::OPTIONAL, 'to version'),
]
);
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand All @@ -49,20 +56,28 @@ protected function execute(InputInterface $input, OutputInterface $output)

$databaseCreator = new CreateDatabaseDoctrineCommand();
$databaseCreator->setContainer($this->getContainer());
$databaseCreator->run(new ArrayInput(array()), $output);
$databaseCreator->run(new ArrayInput([]), $output);

$verbosityLevelMap = array(
$verbosityLevelMap = [
LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL,
LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL,
LogLevel::DEBUG => OutputInterface::VERBOSITY_NORMAL,
);
];
$consoleLogger = new ConsoleLogger($output, $verbosityLevelMap);

/** @var \Claroline\CoreBundle\Library\Installation\PlatformInstaller $installer */
$installer = $this->getContainer()->get('claroline.installation.platform_installer');
$installer->setOutput($output);
$installer->setLogger($consoleLogger);
$installer->updateFromComposerInfo();

$from = $input->getArgument('from_version');
$to = $input->getArgument('to_version');

if ($from && $to) {
$installer->updateAll($from, $to);
} else {
$installer->updateFromComposerInfo();
}

/** @var \Claroline\CoreBundle\Library\Installation\Refresher $refresher */
$refresher = $this->getContainer()->get('claroline.installation.refresher');
Expand Down
12 changes: 6 additions & 6 deletions main/core/Controller/Testing/RemoteTestingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Claroline\CoreBundle\Controller\Testing;

use Claroline\CoreBundle\Library\PluginBundle;
use Claroline\CoreBundle\DataFixtures\Required\LoadRequiredFixturesData;
use Claroline\CoreBundle\Library\DistributionPluginBundle;
use Claroline\CoreBundle\Library\Workspace\TemplateBuilder;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as EXT;
use Doctrine\Common\DataFixtures\ReferenceRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as EXT;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Claroline\CoreBundle\DataFixtures\Required\LoadRequiredFixturesData;

class RemoteTestingController extends Controller
{
Expand Down Expand Up @@ -58,7 +58,7 @@ public function reinstallAction()
$installer = $this->container->get('claroline.plugin.installer');

foreach ($bundles as $bundle) {
if ($bundle instanceof PluginBundle) {
if ($bundle instanceof DistributionPluginBundle) {
$installer->install($bundle);
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public function loadFixtureAction(Request $request)
return new Response('Invalid or missing FQCN parameter', 401);
}

$args = $request->request->get('args', array());
$args = $request->request->get('args', []);
$fixture = new $fqcn($args);
$om = $this->get('claroline.persistence.object_manager');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function load(ObjectManager $manager)
$order = $fixture->getOrder();
}

$this->log('load '.$className.' positon: '.$order);
$this->log('load '.$className.' position: '.$order);
$fixture->setContainer($this->container);
$fixture->load($om);
$om->flush();
Expand Down
151 changes: 151 additions & 0 deletions main/core/Entity/Update/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php

/*
* This file is part of the Claroline Connect package.
*
* (c) Claroline Consortium <consortium@claroline.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Claroline\CoreBundle\Entity\Update;

use Claroline\CoreBundle\Library\Installation\PackageInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
* uniqueConstraints={.
*
* @ORM\UniqueConstraint(
* name="unique_version",
* columns={"version", "bundle", "branch"}
* )
* }
*/

/**
* @ORM\Entity(repositoryClass="Claroline\CoreBundle\Repository\VersionRepository")
* @ORM\Table(
* name="claro_version"
*)
*/
class Version implements PackageInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

/**
* @ORM\Column()
*/
protected $commit;

/**
* @ORM\Column()
*/
protected $version;

/**
* @ORM\Column()
*/
protected $branch;

/**
* @ORM\Column()
*/
protected $bundle;

/**
* @ORM\Column(name="is_upgraded", type="boolean")
*/
protected $isUpgraded = false;

/**
* @ORM\Column(type="integer", nullable=true)
*
* @Gedmo\Timestampable(on="create")
*
* @var \DateTime
*/
protected $date;

public function __construct($version = null, $commit = null, $branch = null, $bundle = null)
{
$this->version = $version;
$this->commit = $commit;
$this->branch = $branch;
$this->bundle = $bundle;
}

public function getId()
{
return $this->id;
}

public function setCommit($commit)
{
$this->commit = $commit;
}

public function getCommit($commit)
{
$this->commit = $commit;
}

public function setVersion($version)
{
$this->version = $version;
}

public function getVersion()
{
return $this->version;
}

public function setBranch($branch)
{
$this->branch = $branch;
}

public function getBranch()
{
return $this->branch;
}

public function setDate($date)
{
$this->date = $date;
}

public function getDate()
{
return $this->date;
}

public function setIsUpgraded($bool)
{
$this->isUpgraded = $bool;
}

public function isUpgraded()
{
return $this->isUpgraded;
}

public function getBundle()
{
return $this->bundle;
}

//alias
public function getName()
{
return $this->getBundle();
}
}
Loading

0 comments on commit ef7c925

Please sign in to comment.