Skip to content

Commit

Permalink
Merge pull request #3354 from zikula/FC
Browse files Browse the repository at this point in the history
FC
  • Loading branch information
craigh authored Jan 1, 2017
2 parents 8b4b31c + ae0bbed commit 009a30d
Show file tree
Hide file tree
Showing 59 changed files with 175 additions and 135 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ CHANGELOG - ZIKULA 1.4.x
- ?

- Deprecated:
- ?
- \StreamReader_*
- all classes in zrc/lib/i18n (e.g. ZGettext, ZLanguage, etc)
- \Zikula_Core::VERSION_* constants are replaced by constants in \ZikulaKernel
(\Zikula_Core was already deprecated long ago)
- \Zikula_Core::VERSION_ID will not be continued in Core-2.0

- Fixes:
- Fixed broken categories selector for legacy extensions (#3356).
Expand Down
11 changes: 11 additions & 0 deletions src/app/ZikulaKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@

class ZikulaKernel extends Kernel
{
const VERSION = '1.4.6';

const VERSION_SUB = 'Overture';

const PHP_MINIMUM_VERSION = '5.4.1';

/**
* The parameter name identifying the currently installed version of the core.
*/
const CORE_INSTALLED_VERSION_PARAM = 'core_installed_version';

/**
* Public list of core modules and their bundle class.
* @var array
Expand Down
2 changes: 1 addition & 1 deletion src/lib/EventHandlers/SystemListeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function initDB(Zikula_Event $event)
public function systemPlugins(Zikula_Event $event)
{
if ($event['stage'] & Zikula_Core::STAGE_TABLES) {
if (!System::isInstalling()) {
if (ServiceUtil::getManager()->getParameter('installed')) {
ServiceUtil::loadPersistentServices();
PluginUtil::loadPlugins(realpath(realpath('.').'/plugins'), "SystemPlugin");
EventUtil::loadPersistentEvents();
Expand Down
1 change: 1 addition & 0 deletions src/lib/StreamReader/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* StreamReader Base.
* @deprecated remove at Core-2.0
*/
abstract class StreamReader_Abstract
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/StreamReader/CachedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* File reader with seek ability.
*
* Reads whole file at once.
* @deprecated remove at Core-2.0
*/
class StreamReader_CachedFile extends StreamReader_String
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/StreamReader/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* File reader with seek capability.
*
* Reads file as required.
* @deprecated remove at Core-2.0
*/
class StreamReader_File extends StreamReader_Abstract
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/StreamReader/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* String reader.
*
* Reads buffer as stream.
* @deprecated remove at Core-2.0
*/
class StreamReader_String extends StreamReader_Abstract
{
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Zikula/Bundle/CoreBundle/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(KernelInterface $kernel)
$this->kernel = $kernel;

$this->setName('Zikula');
$this->setVersion(\Zikula_Core::VERSION_NUM.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
$this->setVersion(\ZikulaKernel::VERSION.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
}

protected function registerCommands()
Expand All @@ -46,9 +46,9 @@ protected function registerCommands()
if ($this->kernel->getContainer()->getParameter('installed') === true) {
// don't attempt to login if the Core needs an upgrade
VersionUtil::defineCurrentInstalledCoreVersion($this->kernel->getContainer());
$currentVersion = $this->kernel->getContainer()->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
$currentVersion = $this->kernel->getContainer()->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
// @todo login is pointless for CLI isn't it?
if (version_compare($currentVersion, \Zikula_Core::VERSION_NUM, '==')) {
if (version_compare($currentVersion, \ZikulaKernel::VERSION, '==')) {
try {
$this->loginAsAdministrator();
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Engine $themeEngine)
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = [
'version' => \Zikula_Core::VERSION_NUM,
'version' => \ZikulaKernel::VERSION,
'ghZikulaCoreUrl' => 'https://www.github.com/zikula/core',
'ghZikulaDocsUrl' => 'https://www.github.com/zikula/zikula-docs',
'ghZikulaBootstrapDocsUrl' => 'http://zikula.github.io/bootstrap-docs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;

class OverrideBlameableListenerPass implements CompilerPassInterface
Expand All @@ -24,7 +25,8 @@ public function process(ContainerBuilder $container)
->setArguments([
new Reference('stof_doctrine_extensions.listener.blameable'),
new Reference('doctrine.orm.default_entity_manager'),
new Reference('session')
new Reference('session'),
new Parameter('installed')
]);
}
}
11 changes: 9 additions & 2 deletions src/lib/Zikula/Bundle/CoreBundle/EventListener/BlameListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ class BlameListener implements EventSubscriberInterface
*/
private $session;

/**
* @var bool
*/
private $installed;

public function __construct(
BlameableListener $blameableListener,
EntityManagerInterface $entityManager,
SessionInterface $session
SessionInterface $session,
$installed
) {
$this->blameableListener = $blameableListener;
$this->entityManager = $entityManager;
$this->session = $session;
$this->installed = $installed;
}

/**
Expand All @@ -55,7 +62,7 @@ public function __construct(
public function onKernelRequest(GetResponseEvent $event)
{
try {
if (\System::isInstalling()) {
if (!$this->installed) {
$uid = 2;
} else {
$uid = $this->session->isStarted() ? $this->session->get('uid', PermissionApi::UNREGISTERED_USER) : PermissionApi::UNREGISTERED_USER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ class Doctrine1ConnectorListener implements EventSubscriberInterface
*/
protected $doctrineManager;

/**
* @var ContainerInterface
*/
private $container;

/**
* @var EventDispatcherInterface
*/
private $dispatcher;

public function __construct(ContainerInterface $container, EventDispatcherInterface $dispatcher)
Expand Down Expand Up @@ -142,9 +149,7 @@ public function doctrineInit(Zikula_Event $event)
$connection->setCollate($connectionInfo['collate']);
}
} catch (\Exception $e) {
//if (!System::isInstalling()) {
// throw new Exception(__('Error setting database characterset and collation.'));
//}
// do nothing
}

if ($connectionInfo['dbdriver'] != 'oracle') {
Expand Down Expand Up @@ -172,7 +177,7 @@ public function doctrineInit(Zikula_Event $event)
public function configureCache(Zikula_Event $event)
{
$manager = $event->getSubject();
if (!System::isInstalling() && $this->container['dbcache.enable']) {
if ($this->container->getParameter('installed') && $this->container['dbcache.enable']) {
$type = $this->container['dbcache.type'];

// Setup Doctrine Caching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function onKernelRequestSiteOff(GetResponseEvent $event)
$siteOff = (bool)$this->variableApi->getSystemVar('siteoff');
$hasAdminPerms = $this->permissionApi->hasPermission('ZikulaSettingsModule::', 'SiteOff::', ACCESS_ADMIN);
$currentInstalledVersion = $this->variableApi->getSystemVar('Version_Num');
$versionsEqual = (\Zikula_Core::VERSION_NUM == $currentInstalledVersion);
$versionsEqual = (\ZikulaKernel::VERSION == $currentInstalledVersion);

// Check for site closed
if (($siteOff || !$versionsEqual) && !$hasAdminPerms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Zikula\Common\Translator\TranslatorInterface;
use Zikula_Core;

/**
* Class AbstractCoreInstallerCmd
Expand Down Expand Up @@ -94,7 +93,6 @@ abstract class AbstractCoreInstallerCommand extends ContainerAwareCommand

protected function bootstrap($disableSessions = true, $fakeRequest = true)
{
define('_ZINSTALLVER', \Zikula_Core::VERSION_NUM);
if ($disableSessions) {
// Disable sessions.
$this->getContainer()->set('session.storage', new MockArraySessionStorage());
Expand Down Expand Up @@ -130,7 +128,7 @@ protected function printRequirementsWarnings(OutputInterface $output, $warnings)
private function errorCodeToMessage($key)
{
$messages = [
'phpsatisfied' => $this->translator->__f("You have got a problem! Your PHP version is %actual, which does not satisfy the Zikula system requirement of version %required or later.", ['%actual' => phpversion(), '%required' => Zikula_Core::PHP_MINIMUM_VERSION]),
'phpsatisfied' => $this->translator->__f("You have got a problem! Your PHP version is %actual, which does not satisfy the Zikula system requirement of version %required or later.", ['%actual' => phpversion(), '%required' => \ZikulaKernel::PHP_MINIMUM_VERSION]),
'datetimezone' => $this->translator->__("date.timezone is currently not set. It needs to be set to a valid timezone in your php.ini such as timezone like UTC, GMT+5, Europe/Berlin."),
'pdo' => $this->translator->__("Your PHP installation doesn't have the PDO extension loaded."),
'phptokens' => $this->translator->__("You have got a problem! Your PHP installation does not have the token functions available, but they are necessary for Zikula's output system."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Zikula_Core;
use Zikula\Bundle\CoreBundle\YamlDumper;
use Zikula\Bundle\CoreInstallerBundle\Command\AbstractCoreInstallerCommand;

Expand Down Expand Up @@ -78,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($input->isInteractive()) {
$env = $this->getContainer()->get('kernel')->getEnvironment();
$io->comment($this->translator->__f('Configuring Zikula installation in %env% environment.', ['%env%' => $env]));
$io->comment($this->translator->__f('Please follow the instructions to install Zikula %version%.', ['%version%' => Zikula_Core::VERSION_NUM]));
$io->comment($this->translator->__f('Please follow the instructions to install Zikula %version%.', ['%version%' => \ZikulaKernel::VERSION]));
}

// get the settings from user input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$currentVersion = $this->getContainer()->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
$currentVersion = $this->getContainer()->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
if (version_compare($currentVersion, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<=')) {
$output->writeln($this->translator->__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', ['%1$s' => $currentVersion, '%2$s' => UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION]));

Expand All @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$io = new SymfonyStyle($input, $output);
$io->title($this->translator->__('Zikula Upgrader Script'));
$io->section($this->translator->__f('*** UPGRADING TO ZIKULA CORE %version% ***', ['%version%' => \Zikula_Core::VERSION_NUM]));
$io->section($this->translator->__f('*** UPGRADING TO ZIKULA CORE %version% ***', ['%version%' => \ZikulaKernel::VERSION]));
$env = $this->getContainer()->get('kernel')->getEnvironment();
$io->text($this->translator->__f('Upgrading Zikula in %env% environment.', ['%env%' => $env]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ private function executeStage($stageName)
case "protect":
return $this->protectFiles();
}
\System::setInstalling(false);

return true;
}
Expand Down Expand Up @@ -284,7 +283,7 @@ private function protectFiles()
$params = $this->yamlManager->getParameters();
$params['installed'] = true;
// set currently installed version into parameters
$params[\Zikula_Core::CORE_INSTALLED_VERSION_PARAM] = \Zikula_Core::VERSION_NUM;
$params[\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM] = \ZikulaKernel::VERSION;

$this->yamlManager->setParameters($params);
// clear the cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(ContainerInterface $container)
$this->yamlManager = new YamlDumper($this->container->get('kernel')->getRootDir() .'/config', 'custom_parameters.yml');
// load and set new default values from the original parameters.yml file into the custom_parameters.yml file.
$this->yamlManager->setParameters(array_merge($originalParameters['parameters'], $this->yamlManager->getParameters()));
$this->currentVersion = $this->container->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
$this->currentVersion = $this->container->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
}

public function ajaxAction(Request $request)
Expand Down Expand Up @@ -85,7 +85,7 @@ private function executeStage($stageName)

return $result;
case "installroutes":
if (version_compare(\Zikula_Core::VERSION_NUM, '1.4.0', '>') && version_compare($this->currentVersion, '1.4.0', '>=')) {
if (version_compare(\ZikulaKernel::VERSION, '1.4.0', '>') && version_compare($this->currentVersion, '1.4.0', '>=')) {
// this stage is not necessary to upgrade from 1.4.0 -> 1.4.x
return true;
}
Expand Down Expand Up @@ -113,7 +113,6 @@ private function executeStage($stageName)
case "clearcaches":
return $this->clearCaches();
}
\System::setInstalling(false);

return true;
}
Expand Down Expand Up @@ -277,17 +276,17 @@ private function finalizeParameters()
$params['router.request_context.base_url'] = isset($params['router.request_context.base_url']) ? $params['router.request_context.base_url'] : $this->container->get('request')->getBasePath();

// set currently installed version into parameters
$params[\Zikula_Core::CORE_INSTALLED_VERSION_PARAM] = \Zikula_Core::VERSION_NUM;
$params[\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM] = \ZikulaKernel::VERSION;

// disable asset combination on upgrades
$params['zikula_asset_manager.combine'] = false;

$this->yamlManager->setParameters($params);

// store the recent version in a config var for later usage. This enables us to determine the version we are upgrading from
$variableApi->set(VariableApi::CONFIG, 'Version_Num', \Zikula_Core::VERSION_NUM);
$variableApi->set(VariableApi::CONFIG, 'Version_ID', \Zikula_Core::VERSION_ID);
$variableApi->set(VariableApi::CONFIG, 'Version_Sub', \Zikula_Core::VERSION_SUB);
$variableApi->set(VariableApi::CONFIG, 'Version_Num', \ZikulaKernel::VERSION);
$variableApi->set(VariableApi::CONFIG, 'Version_ID', \Zikula_Core::VERSION_ID); // @deprecated
$variableApi->set(VariableApi::CONFIG, 'Version_Sub', \ZikulaKernel::VERSION_SUB);

// set the 'start' page information to empty to avoid missing module errors.
$variableApi->set(VariableApi::CONFIG, 'startpage', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class UpgraderController extends AbstractController
*/
public function upgradeAction(Request $request, $stage)
{
$currentVersion = $this->container->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
if (version_compare($currentVersion, \Zikula_Core::VERSION_NUM, '=')) {
$currentVersion = $this->container->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
if (version_compare($currentVersion, \ZikulaKernel::VERSION, '=')) {
$stage = 'complete';
}
// notinstalled?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function onCoreInit(GenericEvent $event)
$requiresUpgrade = false;
if ($installed) {
VersionUtil::defineCurrentInstalledCoreVersion($this->container);
$currentVersion = $this->container->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
$requiresUpgrade = $installed && version_compare($currentVersion, \Zikula_Core::VERSION_NUM, '<');
$currentVersion = $this->container->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
$requiresUpgrade = $installed && version_compare($currentVersion, \ZikulaKernel::VERSION, '<');
}

$routeInfo = $this->container->get('router')->match($request->getPathInfo());
Expand Down Expand Up @@ -71,9 +71,6 @@ public function onCoreInit(GenericEvent $event)
$response->send();
\System::shutDown();
}
if (!$installed || $requiresUpgrade || $this->container->hasParameter('upgrading')) {
\System::setInstalling(true);
}
}

public static function getSubscribedEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getTemplateGlobals(StageInterface $currentStage)
$globals = [
'lang' => \ZLanguage::getLanguageCode(),
'charset' => \ZLanguage::getEncoding(),
'version' => \Zikula_Core::VERSION_NUM,
'version' => \ZikulaKernel::VERSION,
'currentstage' => $currentStage->getName()
];

Expand Down Expand Up @@ -83,7 +83,7 @@ public function requirementsMet(ContainerInterface $container)

$x = explode('.', str_replace('-', '.', phpversion()));
$phpVersion = "$x[0].$x[1].$x[2]";
$results['phpsatisfied'] = version_compare($phpVersion, \Zikula_Core::PHP_MINIMUM_VERSION, ">=");
$results['phpsatisfied'] = version_compare($phpVersion, \ZikulaKernel::PHP_MINIMUM_VERSION, ">=");

$results['pdo'] = extension_loaded('pdo');
$isEnabled = @preg_match('/^\p{L}+$/u', 'TheseAreLetters');
Expand Down Expand Up @@ -114,7 +114,7 @@ public function requirementsMet(ContainerInterface $container)
return true;
}
$results['phpversion'] = phpversion();
$results['phpcoreminversion'] = \Zikula_Core::PHP_MINIMUM_VERSION;
$results['phpcoreminversion'] = \ZikulaKernel::PHP_MINIMUM_VERSION;

return $results;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function getTemplateName()

public function isNecessary()
{
$currentVersion = $this->container->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
if (version_compare(\Zikula_Core::VERSION_NUM, '1.4.0', '>') && version_compare($currentVersion, '1.4.0', '>=')) {
$currentVersion = $this->container->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
if (version_compare(\ZikulaKernel::VERSION, '1.4.0', '>') && version_compare($currentVersion, '1.4.0', '>=')) {
// this stage is not necessary to upgrade from 1.4.0 -> 1.4.x
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getTemplateName()

public function isNecessary()
{
$currentVersion = $this->container->getParameter(\Zikula_Core::CORE_INSTALLED_VERSION_PARAM);
$currentVersion = $this->container->getParameter(\ZikulaKernel::CORE_INSTALLED_VERSION_PARAM);
if (version_compare($currentVersion, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<=')) {
throw new AbortStageException($this->translator->__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', ['%1$s' => $currentVersion, '%2$s' => UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION]));
}
Expand Down
Loading

0 comments on commit 009a30d

Please sign in to comment.