Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Commit

Permalink
add check for Contao 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Feb 10, 2018
1 parent 9e66694 commit 375104c
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 29 deletions.
4 changes: 4 additions & 0 deletions check/.htaccess
@@ -0,0 +1,4 @@
<IfModule mod_rewrite.c>
# Turn off any rewrites from parent folders
RewriteEngine Off
</IfModule>
16 changes: 16 additions & 0 deletions check/controller/composer.php
Expand Up @@ -81,6 +81,22 @@ public function hasPhar()
return false;
}

/**
* Check whether the XCache extension is loaded
*
* @return boolean True if the PHP Phar extension is loaded
*/
public function hasXCache()
{
if (!extension_loaded('XCache')) {
return false;
}

$this->available = false;

return true;
}

/**
* Check whether the PHP cURL extension is available
*
Expand Down
40 changes: 39 additions & 1 deletion check/controller/contao4.php
Expand Up @@ -9,7 +9,7 @@
*/

/**
* Check the Contao 4.x requirements
* Check the Contao 4.4 requirements
*
* @author Fritz Michael Gschwantner <https://github.com/fritzmg>
*/
Expand Down Expand Up @@ -40,6 +40,44 @@ public function isCompatible()
return $this->compatible;
}

/**
* Executes all compatibility checks.
*
* @return boolean True if Contao 4.x can be run
*/
public function checkCompatibility()
{
if (!$this->hasPhp()) {
return false;
}

if (!$this->hasGraphicsLib()) {
return false;
}

if (!$this->hasDom()) {
return false;
}

if (!$this->hasIntl()) {
return false;
}

if (!$this->canWriteTmpDir()) {
return false;
}

if (!$this->canUseSymlink()) {
return false;
}

if (!$this->canCreateSymlinks()) {
return false;
}

return true;
}

/**
* Check whether the PHP version meets the requirements
*
Expand Down
95 changes: 95 additions & 0 deletions check/controller/contao45.php
@@ -0,0 +1,95 @@
<?php

/*
* Contao check
*
* Copyright (c) 2005-2016 Leo Feyer
*
* @license LGPL-3.0+
*/

require_once __DIR__ . '/contao4.php';

/**
* Check the Contao 4.5 requirements
*
* @author Fritz Michael Gschwantner <https://github.com/fritzmg>
*/
class Contao45 extends Contao4
{
const PHP_VERSION = '7.1.0';
const ICU_VERSION = '4.6';

/**
* @var string
*/
protected $icuVersion = null;

/**
* Execute the command
*/
public function run()
{
include __DIR__ . '/../views/contao45.phtml';
}

/**
* Returns the detected ICU version
*
* @return string
*/
public function getIcuVersion()
{
return $this->icuVersion;
}

/**
* Executes all compatibility checks.
*
* @return boolean True if Contao 4.5 can be run
*/
public function checkCompatibility()
{
parent::checkCompatibility();

if (!$this->compatible) {
return false;
}

if (!$this->hasIcu()) {
return false;
}

return true;
}

/**
* Checks the minimum version of the ICU library
*
* @return boolean True if the version of the ICU library is sufficiently high
*/
public function hasIcu()
{
if (extension_loaded('intl')) {

if (defined('INTL_ICU_VERSION')) {
$this->icuVersion = INTL_ICU_VERSION;
} else {
$reflector = new \ReflectionExtension('intl');
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
$this->icuVersion = $matches[1];
}

if (version_compare($this->icuVersion, static::ICU_VERSION, '>=')) {
return true;
}
}

$this->compatible = false;

return false;
}
}
47 changes: 20 additions & 27 deletions check/controller/index.php
Expand Up @@ -11,6 +11,7 @@
require_once __DIR__ . '/contao2.php';
require_once __DIR__ . '/contao3.php';
require_once __DIR__ . '/contao4.php';
require_once __DIR__ . '/contao45.php';
require_once __DIR__ . '/composer.php';
require_once __DIR__ . '/file-permissions.php';
require_once __DIR__ . '/live-update.php';
Expand Down Expand Up @@ -99,35 +100,19 @@ public function supportsContao4()
{
$contao = new Contao4;

if (!$contao->hasPhp()) {
return false;
}

if (!$contao->hasGraphicsLib()) {
return false;
}

if (!$contao->hasDom()) {
return false;
}

if (!$contao->hasIntl()) {
return false;
}

if (!$contao->canWriteTmpDir()) {
return false;
}

if (!$contao->canUseSymlink()) {
return false;
}
return $contao->checkCompatibility();
}

if (!$contao->canCreateSymlinks()) {
return false;
}
/**
* Return true if Contao 4 can be installed
*
* @return boolean True if Contao 4 can be installed
*/
public function supportsContao45()
{
$contao = new Contao45;

return true;
return $contao->checkCompatibility();
}

/**
Expand Down Expand Up @@ -157,6 +142,10 @@ public function canUseLiveUpdate()
return false;
}

if ($update->hasXCache()) {
return false;
}

if (!$update->hasSsl()) {
return false;
}
Expand Down Expand Up @@ -201,6 +190,10 @@ public function canUseComposer()
return false;
}

if ($composer->hasXCache()) {
return false;
}

if (!$composer->hasCurl()) {
return false;
}
Expand Down
16 changes: 16 additions & 0 deletions check/controller/live-update.php
Expand Up @@ -72,6 +72,22 @@ public function hasPhar()
return false;
}

/**
* Check whether the XCache extension is loaded
*
* @return boolean True if the PHP Phar extension is loaded
*/
public function hasXCache()
{
if (!extension_loaded('XCache')) {
return false;
}

$this->available = false;

return true;
}

/**
* Check whether the PHP OpenSSL extension is available
*
Expand Down
13 changes: 13 additions & 0 deletions check/i18n/en.php
Expand Up @@ -77,6 +77,8 @@
'You cannot install Contao 3.x' => 'You cannot install Contao 3.x',
'You can install Contao 4.x' => 'You can install Contao 4.x',
'You cannot install Contao 4.x' => 'You cannot install Contao 4.x',
'You can install Contao 4.5' => 'You can install Contao 4.5',
'You cannot install Contao 4.5' => 'You cannot install Contao 4.5',
'The file permissions cannot be checked.' => 'The file permissions cannot be checked.',
'More information …' => 'More information …',
'Additional services' => 'Additional services',
Expand Down Expand Up @@ -170,6 +172,7 @@
'You can install Contao 3.x on this server.' => 'You can install Contao 3.x on this server.',
'You cannot install Contao 3.x on this server.' => 'You cannot install Contao 3.x on this server.',
'Contao 4.x' => 'Contao 4.x',
'Contao 4.5' => 'Contao 4.5',
'As of Contao 4.1 you need at least PHP %s.' => 'As of Contao 4.1 you need at least PHP %s.',
'PHP intl extension' => 'PHP intl extension',
'The PHP intl extension is enabled.' => 'The PHP intl extension is enabled.',
Expand All @@ -179,6 +182,8 @@
'The PHP GDlib extension is not part of the PHP core and has to be explicitly enabled using the --with-gd flag. Recompile PHP with the flag.' => 'The PHP GDlib extension is not part of the PHP core and has to be explicitly enabled using the --with-gd flag. Recompile PHP with the flag.',
'You can install Contao 4.x on this server.' => 'You can install Contao 4.x on this server.',
'You cannot install Contao 4.x on this server.' => 'You cannot install Contao 4.x on this server.',
'You can install Contao 4.5 on this server.' => 'You can install Contao 4.5 on this server.',
'You cannot install Contao 4.5 on this server.' => 'You cannot install Contao 4.5 on this server.',
'PHP image processing' => 'PHP image processing',
'At least one of the supported image processing libraries is available.' => 'At least one of the supported image processing libraries is available.',
'None of the supported image processing libraries are available.' => 'None of the supported image processing libraries are available.',
Expand All @@ -197,4 +202,12 @@
'Working symlinks are required to run Contao 4. Please contact your server administrator.' => 'Working symlinks are required to run Contao 4. Please contact your server administrator.',
'The PHP symlink() function is disabled.' => 'The PHP symlink() function is disabled.',
'The PHP symlink() function is required to run Contao 4. Please contact your server administrator.' => 'The PHP symlink() function is required to run Contao 4. Please contact your server administrator.',
'PHP XCache extension' => 'PHP XCache extension',
'The PHP XCache extension is not enabled.' => 'The PHP XCache extension is not enabled.',
'The PHP XCache extension is enabled.' => 'The PHP XCache extension is enabled.',
'The PHP XCache extension prevents the execution of .phar files. Disable this extension in your php.ini.' => 'The PHP XCache extension prevents the execution of .phar files. Disable this extension in your php.ini.',
'The ICU library version is %s.' => 'The ICU library version is %s.',
'The ICU library version on your system needs to be at least %s. Please contact your server administrator.' => 'The ICU library version on your system needs to be at least %s. Please contact your server administrator.',
'ICU library' => 'ICU library',
'Contao system requirements' => 'Contao system requirements',
);
9 changes: 9 additions & 0 deletions check/views/composer.phtml
Expand Up @@ -30,6 +30,15 @@
<p class="explain"><?php echo __('The PHP Phar extension is part of the PHP core since PHP 5.3 and has to be explicitly disabled using the --disable-phar flag. Recompile PHP without the flag.') ?></p>
<?php endif; ?>
</div>
<div class="row">
<h3><?php echo __('PHP XCache extension') ?></h3>
<?php if (!$this->hasXCache()): ?>
<p class="confirm"><?php echo __('The PHP XCache extension is not enabled.') ?></p>
<?php else: ?>
<p class="error"><?php echo __('The PHP XCache extension is enabled.') ?></p>
<p class="explain"><?php echo __('The PHP XCache extension prevents the execution of .phar files. Disable this extension in your php.ini.') ?></p>
<?php endif; ?>
</div>
<div class="row">
<h3><?php echo __('PHP cURL extension') ?></h3>
<?php if ($this->hasCurl()): ?>
Expand Down

0 comments on commit 375104c

Please sign in to comment.