Merge branch 'master' into customer

This commit is contained in:
Manuel Raynaud
2013-10-07 09:16:25 +02:00
7 changed files with 50 additions and 44 deletions

1
.gitignore vendored
View File

@@ -14,7 +14,6 @@ coverage
.buildpath .buildpath
.project .project
.settings/ .settings/
local/cache/*
local/media/documents/* local/media/documents/*
local/media/images/* local/media/images/*
web/assets/* web/assets/*

View File

@@ -8,6 +8,7 @@ env:
- DB_USER=root - DB_USER=root
before_script: before_script:
- phpenv config-add travis.php.ini
- composer self-update - composer self-update
- composer install --prefer-dist --dev - composer install --prefer-dist --dev
- sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi" - sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi"

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Thelia\Command\ContainerAwareCommand; use Thelia\Command\ContainerAwareCommand;
use Thelia\Install\CheckPermission;
use Thelia\Install\Database; use Thelia\Install\Database;
/** /**
@@ -82,6 +83,9 @@ class Install extends ContainerAwareCommand
'', '',
'Welcome to Thelia install process', 'Welcome to Thelia install process',
'You need information about your database configuration (host, username, password, database name, etc)', 'You need information about your database configuration (host, username, password, database name, etc)',
'',
'<info>Caution : You are installing Thelia in cli mode, we verify some information, but this information are only available for the cli php sapi</info>',
'<info>This informations can be different in your apache or cgi php.ini files</info>',
'' ''
)); ));
@@ -136,40 +140,35 @@ class Install extends ContainerAwareCommand
"Checking some permissions" "Checking some permissions"
)); ));
$confDir = THELIA_ROOT . "local/config"; $permissions = new CheckPermission(false, $this->getContainer()->get('thelia.translator'));
$cacheDir = THELIA_ROOT . "cache"; $isValid = $permissions->exec();
$logDir = THELIA_ROOT . "log";
$conf = is_writable($confDir); foreach($permissions->getValidationMessages() as $item => $data) {
$cache = is_writable($cacheDir); if($data['status']) {
$log = is_writable($logDir); $output->writeln(array(
sprintf("<info>%s ...</info> %s",
$data['text'],
"<info>Ok</info>")
)
);
} else {
$output->writeln(array(
sprintf("<error>%s </error>%s",
$data['text'],
sprintf("<error>%s</error>", $data["hint"])
)
));
}
$output->writeln(array(
sprintf(
"<info>config directory(%s)...</info> %s",
$confDir,
$conf ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>cache directory(%s)...</info> %s"
,$cacheDir,
$cache ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>log directory(%s)...</info> %s",
$logDir,
$log ? "<info>Ok</info>" : "<error>Fail</error>"
),
));
if ($conf === false || $cache === false || $log === false) {
$output->writeln(array(
"",
"<error>Please put correct permission and reload install process</error>"
));
exit;
} }
if(false === $isValid) {
$output->writeln(array(
"",
"<error>Please put correct permissions and reload install process</error>"
));
exit;
}
} }
/** /**

View File

@@ -45,6 +45,7 @@ class CheckPermission extends BaseInstall
const DIR_LOG = 'log'; const DIR_LOG = 'log';
const DIR_CACHE = 'cache'; const DIR_CACHE = 'cache';
const DIR_WEB = 'web'; const DIR_WEB = 'web';
const DIR_SESSION = 'local/session';
/** @var array Directory needed to be writable */ /** @var array Directory needed to be writable */
protected $directoriesToBeWritable = array( protected $directoriesToBeWritable = array(
@@ -52,11 +53,12 @@ class CheckPermission extends BaseInstall
self::DIR_LOG, self::DIR_LOG,
self::DIR_CACHE, self::DIR_CACHE,
self::DIR_WEB, self::DIR_WEB,
self::DIR_SESSION,
); );
/** @var array Minimum server configuration necessary */ /** @var array Minimum server configuration necessary */
protected $minServerConfigurationNecessary = array( protected $minServerConfigurationNecessary = array(
'memory_limit' => 134217728, 'memory_limit' => 157286400,
'post_max_size' => 20971520, 'post_max_size' => 20971520,
'upload_max_filesize' => 2097152 'upload_max_filesize' => 2097152
); );
@@ -187,9 +189,9 @@ class CheckPermission extends BaseInstall
{ {
if ($this->translator !== null) { if ($this->translator !== null) {
if ($isValid) { if ($isValid) {
$sentence = 'Your directory <strong>%directory%</strong> is writable'; $sentence = 'Your directory %directory% is writable';
} else { } else {
$sentence = 'Your directory <strong>%directory%</strong> is not writable'; $sentence = 'Your directory %directory% is not writable';
} }
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
@@ -216,7 +218,7 @@ class CheckPermission extends BaseInstall
protected function getI18nDirectoryHint($directory) protected function getI18nDirectoryHint($directory)
{ {
if ($this->translator !== null) { if ($this->translator !== null) {
$sentence = '<span class="label label-primary">chmod 777 %directory%</span> on your server with admin rights could help'; $sentence = 'chmod 777 %directory% on your server with admin rights could help';
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
$sentence, $sentence,
array( array(
@@ -246,9 +248,9 @@ class CheckPermission extends BaseInstall
protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid) protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid)
{ {
if ($isValid) { if ($isValid) {
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)'; $sentence = 'Your %key% server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)';
} else { } else {
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)'; $sentence = 'Your %key% server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)';
} }
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
@@ -271,7 +273,7 @@ class CheckPermission extends BaseInstall
*/ */
protected function getI18nConfigHint() protected function getI18nConfigHint()
{ {
$sentence = 'Modifying this value on your server <span class="label label-primary">php.ini</span> file with admin rights could help'; $sentence = 'Modifying this value on your server php.ini file with admin rights could help';
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
$sentence, $sentence,
array(), array(),
@@ -294,9 +296,9 @@ class CheckPermission extends BaseInstall
{ {
if ($this->translator !== null) { if ($this->translator !== null) {
if ($isValid) { if ($isValid) {
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is well enough to run Thelia2 (%expectedValue% needed)'; $sentence = 'Your PHP version %currentValue% is well enough to run Thelia2 (%expectedValue% needed)';
} else { } else {
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is not sufficient enough to run Thelia2 (%expectedValue% needed)'; $sentence = 'Your PHP version %currentValue% is not sufficient enough to run Thelia2 (%expectedValue% needed)';
} }
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
@@ -343,6 +345,10 @@ class CheckPermission extends BaseInstall
{ {
$serverValueInBytes = $this->returnBytes(ini_get($key)); $serverValueInBytes = $this->returnBytes(ini_get($key));
if($serverValueInBytes == -1) {
return true;
}
return ($serverValueInBytes >= $necessaryValueInBytes); return ($serverValueInBytes >= $necessaryValueInBytes);
} }

1
travis.php.ini Normal file
View File

@@ -0,0 +1 @@
post_max_size = 20M

0
local/cache/.gitkeep → web/cache/.gitkeep vendored Executable file → Normal file
View File

View File

@@ -42,11 +42,11 @@ $request = Request::createFromGlobals();
$thelia = new Thelia("dev", true); $thelia = new Thelia("dev", true);
if ( false === in_array($request->getClientIp(), $trustedIp)) { if ( false === in_array($request->getClientIp(), $trustedIp)) {
// Redirect 401 Unauthorized $response = Response::create('Forbidden', 403)->send();
$response = new Response('Unauthorized', 401); $thelia->terminate($request, $response);
} else {
$response = $thelia->handle($request)->prepare($request)->send();
$thelia->terminate($request, $response); $thelia->terminate($request, $response);
} }
$response = $thelia->handle($request)->prepare($request)->send();
$thelia->terminate($request, $response);