Update directory structure & allow to configure paths (tmp, log, cache)

This commit is contained in:
Nicolas Le Goff
2014-09-05 11:28:25 +02:00
parent 69fd50906f
commit de7988689e
2201 changed files with 850 additions and 13650 deletions

72
.gitignore vendored
View File

@@ -1,20 +1,62 @@
# Exclude common IDE project files
/nbproject /nbproject
/config/custom_files /.idea
/config/templates
/config/topics # Exclude javascript dependencies folder
/config/wm
/config/minilogos
/config/status
/config/stamp
/config/configuration.yml
/vendor
/plugins
/node_modules
composer.phar
behat.yml
/datas
/www/assets /www/assets
/tmp-assets /tmp-assets
# Exclude node.js dependencies folder
/node_modules
# Exclude compiled LESS folder
/www/skins/build /www/skins/build
/www/crossdomain.xml
# Exclude compiled javascript test fixture folder
/www/scripts/tests/fixtures /www/scripts/tests/fixtures
# Exclude configuration folder exception the configuration sample file
/config
!/config/configuration.sample.yml
# Exclude generated proxies from doctrine2
/resources/proxies
# Exclude temporaries resources (zip files, quarantine documents etc ..) folder
/tmp
# Exclude cache folder
/cache
# Exclude log folder
/logs
# Exclude plugin folder
/plugins
# Excluse assets plugin folder
/www/plugins
# Exclude folder for storing documents (images, videos, PDF) and their sub-definitions
/datas
# Exclude dependencies folder
/vendor
# Exclude package's binaries folder except the Phraseanet's ones
/bin
!/bin/console
!/bin/developer
!/bin/setup
# Exclude composer
composer.phar
# Exclude behat configuration file
behat.yml
# Exclude vagrant configuration file
.vagrant
# Exclude crossdomain.xml file it's generated
/www/crossdomain.xml

View File

@@ -61,7 +61,7 @@ script:
bin/setup system:install --email=test@phraseanet.com --password=test --db-user=root --db-template=fr --db-password= --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y -v; bin/setup system:install --email=test@phraseanet.com --password=test --db-user=root --db-template=fr --db-password= --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y -v;
bin/developer ini:setup-tests-dbs -v; bin/developer ini:setup-tests-dbs -v;
fi" fi"
- php hudson/cleanupSubdefs.php - php resources/hudson/cleanupSubdefs.php
#sqlite db generation should occur once Phraseanet is up to date : #sqlite db generation should occur once Phraseanet is up to date :
- bin/developer phraseanet:regenerate-sqlite - bin/developer phraseanet:regenerate-sqlite
- ./node_modules/.bin/grunt test - ./node_modules/.bin/grunt test

View File

@@ -20,7 +20,8 @@ module.exports = function(grunt) {
all: ['www/include/js/tests/*.html'] all: ['www/include/js/tests/*.html']
}, },
clean: { clean: {
"assets": ["<%= path.bower %>", "<%= path.asset %>"] "assets": ["<%= path.asset %>"],
"bower": ["<%= path.bower %>"]
}, },
bower: { bower: {
install: { install: {
@@ -253,6 +254,32 @@ module.exports = function(grunt) {
"dest": "<%= path.asset %>/normalize-css/", "dest": "<%= path.asset %>/normalize-css/",
"flatten": true "flatten": true
}, },
"sinon-chai": {
"expand": true,
"src": [
"<%= path.bower %>/sinon-chai/lib/sinon-chai.js",
"<%= path.bower %>/sinon-chai/LICENCE.txt",
],
"dest": "<%= path.asset %>/sinon-chai/",
"flatten": true
},
"sinonjs": {
"expand": true,
"src": [
"<%= path.bower %>/sinonjs/sinon.js"
],
"dest": "<%= path.asset %>/sinonjs/",
"flatten": true
},
"squire": {
"expand": true,
"src": [
"<%= path.bower %>/squire/src/Squire.js",
"<%= path.bower %>/squire/LICENCE"
],
"dest": "<%= path.asset %>/squire/",
"flatten": true
},
"qunit": { "qunit": {
"expand": true, "expand": true,
"src": [ "src": [
@@ -390,6 +417,7 @@ module.exports = function(grunt) {
"copy:blueimp", "copy:blueimp",
"copy:bootstrap", "copy:bootstrap",
"copy:bootstrap-multiselect", "copy:bootstrap-multiselect",
"copy:chai",
"copy:font-awesome", "copy:font-awesome",
"copy:geonames-server-jquery-plugin", "copy:geonames-server-jquery-plugin",
"copy:humane-js", "copy:humane-js",
@@ -402,9 +430,16 @@ module.exports = function(grunt) {
"copy:jquery-ui", "copy:jquery-ui",
"copy:jquery.treeview", "copy:jquery.treeview",
"copy:json2", "copy:json2",
"copy:js-fixtures",
"copy:modernizr", "copy:modernizr",
"copy:normalize", "copy:normalize",
"copy:normalize",
"copy:qunit",
"copy:mocha",
"copy:requirejs", "copy:requirejs",
"copy:sinon-chai",
"copy:sinonjs",
"copy:squire",
"copy:swfobject", "copy:swfobject",
"copy:tinymce", "copy:tinymce",
"copy:underscore", "copy:underscore",
@@ -416,7 +451,8 @@ module.exports = function(grunt) {
"bower", "bower",
"copy-deps", "copy-deps",
"bower_postinst", "bower_postinst",
"copy-assets" "copy-assets",
"clean:bower"
]); ]);
grunt.registerTask('test', ["shell:generate_js_fixtures", "qunit", "mocha_phantomjs"]); grunt.registerTask('test', ["shell:generate_js_fixtures", "qunit", "mocha_phantomjs"]);
}; };

12
Vagrantfile vendored
View File

@@ -1,11 +1,15 @@
require 'yaml' require 'yaml'
unless Vagrant.has_plugin?("vagrant-hostsupdater")
raise 'vagrant-hostmanager is not installed! please run "vagrant plugin install vagrant-hostsupdater'
end
root = File.dirname(File.expand_path(__FILE__)) root = File.dirname(File.expand_path(__FILE__))
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
Dir.glob(root+"/vagrant/vms/**/puphpet/config.yaml").each do|f| Dir.glob(root+"/resources/vagrant/vms/**/puphpet/config.yaml").each do|f|
dir = File.dirname(File.expand_path(f)+"/..") dir = File.dirname(File.expand_path(f+"/.."))
base_path = dir[0..-21] base_path = dir
configValues = YAML.load_file(f) configValues = YAML.load_file(f)
data = configValues['vagrantfile-local'] data = configValues['vagrantfile-local']
@@ -167,7 +171,7 @@ Vagrant.configure("2") do |config|
node.vm.provision "shell" do |s| node.vm.provision "shell" do |s|
s.path = "#{base_path}/puphpet/shell/initial-setup.sh" s.path = "#{base_path}/puphpet/shell/initial-setup.sh"
s.args = "/vagrant/vagrant/vms/#{data['name']}/puphpet" s.args = "/vagrant/resources/vagrant/vms/#{data['name']}/puphpet"
end end
node.vm.provision "shell" do |kg| node.vm.provision "shell" do |kg|

View File

@@ -79,8 +79,12 @@ main:
host: 127.0.0.1 host: 127.0.0.1
port: 6700 port: 6700
storage: storage:
subdefs: subdefs:null
default-dir: null cache: null
log : null
download: null
lazaret: null
caption: null
bridge: bridge:
youtube: youtube:
enabled: false enabled: false

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
config/topics/.gitkeep Normal file
View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
config/wm/.gitkeep Normal file
View File

0
datas/.gitkeep Normal file
View File

View File

@@ -1,4 +0,0 @@
dailymotion:
public_key:
secret_key:
dev_token:

View File

@@ -1,74 +0,0 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
$console = new Application('Functionnal tests for dailymotion API');
$console
->register('upload:dailymotion')
->setDescription('Test upload on dailymotion API')
->setCode(function (InputInterface $input, OutputInterface $output) use ($core) {
try {
$configuration = Yaml::parse(__DIR__. '/config/keys.conf.yml');
} catch(\Exception $e) {
$output->writeln('<error>could not parse configuration file</error>');
return;
}
$appbox = \appbox::get_instance($core);
$found = false;
foreach ($appbox->get_databoxes() as $databox) {
/* @var $databox \databox */
$sql = 'SELECT record_id FROM record WHERE type="video" AND (
mime="video/mp4" OR mime="video/quicktime" OR mime="video/x-msvideo" OR mime="video/x-msvideo"
) LIMIT 1';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$rows = $stmt->fetch(\PDO::FETCH_ASSOC);
if(1 === count($rows)) {
$found = true;
$record = $databox->get_record($rows['record_id']);
break;
}
unset($stmt);
}
if (!$found) {
$output->writeln('<error>No video found, </error>');
return;
}
$bridge = new \Bridge_Api_Dailymotion($core['Registry'], new \Bridge_Api_Auth_OAuth2());
$bridge->set_oauth_token($configuration['dailymotion']['dev_token']);
$options = [];
$samples = [
'title' => $record->get_title(),
'description' => 'Upload functionnal test',
'tags' => 'phraseanet upload test dm api',
'private' => true,
];
foreach($bridge->get_fields() as $field) {
$options[$field['name']] = isset($samples[$field['name']]) ? $samples[$field['name']] : uniqid('test_upload');
}
try {
$idVideo = $bridge->upload($record, $options);
$output->writeln(sprintf('<info>video id is %s</info>', $idVideo));
} catch(\Bridge_Exception_ActionAuthNeedReconnect $e) {
$output->writeln(sprintf('<error>Invalid token %s</error>', $configuration['dailymotion']['dev_token']));
} catch(\Exception $e) {
$output->writeln(sprintf('<error>%s : %s -> %s</error>',get_class($e), $e->getMessage(), $e->getTraceAsString()));
}
});
$console->run();

View File

@@ -188,25 +188,25 @@ class Application extends SilexApplication
error_reporting(-1); error_reporting(-1);
$this['root.path'] = realpath(__DIR__ . '/../../..');
$this->environment = $environment; $this->environment = $environment;
mb_internal_encoding("UTF-8"); $this->setupApplicationPaths($this);
$this['charset'] = 'UTF-8';
mb_internal_encoding($this['charset']);
!defined('JETON_MAKE_SUBDEF') ? define('JETON_MAKE_SUBDEF', 0x01) : ''; !defined('JETON_MAKE_SUBDEF') ? define('JETON_MAKE_SUBDEF', 0x01) : '';
!defined('JETON_WRITE_META_DOC') ? define('JETON_WRITE_META_DOC', 0x02) : ''; !defined('JETON_WRITE_META_DOC') ? define('JETON_WRITE_META_DOC', 0x02) : '';
!defined('JETON_WRITE_META_SUBDEF') ? define('JETON_WRITE_META_SUBDEF', 0x04) : ''; !defined('JETON_WRITE_META_SUBDEF') ? define('JETON_WRITE_META_SUBDEF', 0x04) : '';
!defined('JETON_WRITE_META') ? define('JETON_WRITE_META', 0x06) : ''; !defined('JETON_WRITE_META') ? define('JETON_WRITE_META', 0x06) : '';
$this['charset'] = 'UTF-8';
$this['debug'] = $this->share(function (Application $app) { $this['debug'] = $this->share(function (Application $app) {
return Application::ENV_PROD !== $app->getEnvironment(); return Application::ENV_PROD !== $app->getEnvironment();
}); });
if ($this['debug'] === true) { if ($this['debug'] === true) {
ini_set('log_errors', 'on'); ini_set('log_errors', 'on');
ini_set('error_log', $this['root.path'] . '/logs/php_error.log'); ini_set('error_log', $this['root.path'].'/logs/php_error.log');
} }
$this->register(new BasketMiddlewareProvider()); $this->register(new BasketMiddlewareProvider());
@@ -218,6 +218,7 @@ class Application extends SilexApplication
$this->register(new AuthenticationManagerServiceProvider()); $this->register(new AuthenticationManagerServiceProvider());
$this->register(new BorderManagerServiceProvider()); $this->register(new BorderManagerServiceProvider());
$this->register(new BrowserServiceProvider()); $this->register(new BrowserServiceProvider());
$this->register(new FilesystemServiceProvider());
$this->register(new ConfigurationServiceProvider()); $this->register(new ConfigurationServiceProvider());
$this->register(new ConfigurationTesterServiceProvider); $this->register(new ConfigurationTesterServiceProvider);
$this->register(new ConvertersServiceProvider()); $this->register(new ConvertersServiceProvider());
@@ -229,7 +230,6 @@ class Application extends SilexApplication
$this->register(new JMSSerializerServiceProvider()); $this->register(new JMSSerializerServiceProvider());
$this->register(new FFMpegServiceProvider()); $this->register(new FFMpegServiceProvider());
$this->register(new FeedServiceProvider()); $this->register(new FeedServiceProvider());
$this->register(new FilesystemServiceProvider());
$this->register(new FtpServiceProvider()); $this->register(new FtpServiceProvider());
$this->register(new GeonamesServiceProvider()); $this->register(new GeonamesServiceProvider());
$this['geonames.server-uri'] = $this->share(function (Application $app) { $this['geonames.server-uri'] = $this->share(function (Application $app) {
@@ -333,7 +333,7 @@ class Application extends SilexApplication
$this->register(new TokensServiceProvider()); $this->register(new TokensServiceProvider());
$this->register(new TwigServiceProvider(), [ $this->register(new TwigServiceProvider(), [
'twig.options' => [ 'twig.options' => [
'cache' => $this['root.path'].'/tmp/cache_twig/', 'cache' => $this->share(function($app) {return $app['cache.path'].'/twig';}),
], ],
]); ]);
@@ -341,7 +341,7 @@ class Application extends SilexApplication
'locale_fallbacks' => ['fr'], 'locale_fallbacks' => ['fr'],
'translator.cache-options' => [ 'translator.cache-options' => [
'debug' => $this['debug'], 'debug' => $this['debug'],
'cache_dir' => $this['root.path'].'/tmp/translations' 'cache_dir' => $this->share(function($app) {return $app['cache.path'].'/translations';}),
], ],
]); ]);
@@ -589,6 +589,8 @@ class Application extends SilexApplication
{ {
$this['twig'] = $this->share( $this['twig'] = $this->share(
$this->extend('twig', function ($twig, $app) { $this->extend('twig', function ($twig, $app) {
$twig->setCache($app['cache.path'].'/twig');
$paths = require $app['plugins.directory'] . '/twig-paths.php'; $paths = require $app['plugins.directory'] . '/twig-paths.php';
if ($app['browser']->isTablet() || $app['browser']->isMobile()) { if ($app['browser']->isTablet() || $app['browser']->isMobile()) {
@@ -899,4 +901,92 @@ class Application extends SilexApplication
{ {
return static::$flashTypes; return static::$flashTypes;
} }
private function setupApplicationPaths(Application $app)
{
// app root path
$this['root.path'] = realpath(__DIR__ . '/../../..');
// temporary resources default path such as download zip, quarantined documents etc ..
$this['tmp.path'] = $this['root.path'].'/tmp';
// cache path for dev env
$this['cache.dev.path'] = $app->share(function() use ($app) {
$path = sys_get_temp_dir().'/'.md5($app['root.path']);
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// cache path (twig, minify, translations, configuration, doctrine metas serializer metas, profiler etc ...)
$this['cache.path'] = $app->share(function() use ($app) {
// if ($app->getEnvironment() !== Application::ENV_PROD) {
// return $this['cache.dev.path'];
// }
$path = $this['root.path'].'/cache';
if ($app['phraseanet.configuration']->isSetup()) {
$path = $app['conf']->get(['main', 'storage', 'cache'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
$app['cache.paths'] = $app->share(function() use ($app) {
return array(
self::ENV_DEV => $this['cache.path'],
self::ENV_TEST => $this['cache.path'],
self::ENV_PROD => $this['cache.path']
);
});
// log path
$this['log.path'] = $app->share(function() use ($app) {
$path = $this['root.path'].'/logs';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'log'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// temporary download file path (zip file)
$this['tmp.download.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/download';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'download'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// quarantined file path
$this['tmp.lazaret.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/lazaret';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'quarantine'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// document caption file path
$this['tmp.caption.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/caption';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'caption'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
}
} }

View File

@@ -61,7 +61,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) { if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
$app->register($p = new WebProfilerServiceProvider(), [ $app->register($p = new WebProfilerServiceProvider(), [
'profiler.cache_dir' => $app['root.path'].'/tmp/cache/profiler', 'profiler.cache_dir' => $app['cache.path'].'/profiler',
]); ]);
$app->mount('/_profiler', $p); $app->mount('/_profiler', $p);

View File

@@ -196,11 +196,11 @@ class Manager
*/ */
protected function bookLazaretPathfile($filename, $suffix = '') protected function bookLazaretPathfile($filename, $suffix = '')
{ {
$output = $this->app['root.path'] . '/tmp/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION); $output = $this->app['tmp.path'].'/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION);
$infos = pathinfo($output); $infos = pathinfo($output);
$n = 0; $n = 0;
$this->app['filesystem']->mkdir($this->app['root.path'] . '/tmp/lazaret'); $this->app['filesystem']->mkdir($this->app['tmp.lazaret.path']);
while (true) { while (true) {
$output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : '')); $output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : ''));

View File

@@ -100,12 +100,12 @@ class IniReset extends Command
// inject v3.1 fixtures // inject v3.1 fixtures
if ($input->getOption('v3.1')) { if ($input->getOption('v3.1')) {
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/connexion.inc', $this->container['root.path'].'/config/connexion.inc'); $this->container['filesystem']->copy($this->container['root.path'].'/resources/hudson/connexion.inc', $this->container['root.path'].'/config/connexion.inc');
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/_GV.php', $this->container['root.path'].'/config/_GV.php'); $this->container['filesystem']->copy($this->container['root.path'].'/resources//hudson/_GV.php', $this->container['root.path'].'/config/_GV.php');
$command = $this->getApplication()->find('dbal:import'); $command = $this->getApplication()->find('dbal:import');
$content = file_get_contents($this->container['root.path'] . '/hudson/fixtures.sql'); $content = file_get_contents($this->container['root.path'] . '/resources//hudson/fixtures.sql');
$content = str_replace('ab_test', $dbs['ab'], $content); $content = str_replace('ab_test', $dbs['ab'], $content);
$content = str_replace('db_test', $dbName, $content); $content = str_replace('db_test', $dbName, $content);

View File

@@ -30,12 +30,12 @@ class JsFixtures extends Command
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)
{ {
$dbRefPath = __DIR__ . '/../../../../../tests/db-ref.sqlite'; $dbRefPath = sys_get_temp_dir() . '/db-ref.sqlite';
if (!file_exists($dbRefPath)) { if (!file_exists($dbRefPath)) {
throw new RuntimeException('You must generate sqlite db first, run "bin/console phraseanet:regenerate-sqlite" command.'); throw new RuntimeException('You must generate sqlite db first, run "bin/console phraseanet:regenerate-sqlite" command.');
} }
copy($dbRefPath, '/tmp/db.sqlite'); copy($dbRefPath, sys_get_temp_dir().'/db.sqlite');
$sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id(); $sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id();
$this->writeResponse($output, 'GET', '/login/', '/home/login/index.html'); $this->writeResponse($output, 'GET', '/login/', '/home/login/index.html');

View File

@@ -54,16 +54,16 @@ class RegenerateSqliteDb extends Command
{ {
parent::__construct('phraseanet:regenerate-sqlite'); parent::__construct('phraseanet:regenerate-sqlite');
$this->setDescription("Updates the sqlite 'tests/db-ref.sqlite' database with current database definition."); $this->setDescription("Updates the sqlite 'db-ref.sqlite' database with current database definition.");
} }
public function doExecute(InputInterface $input, OutputInterface $output) public function doExecute(InputInterface $input, OutputInterface $output)
{ {
$fs = new Filesystem(); $fs = new Filesystem();
$source = __DIR__ . '/../../../../../tests/db-ref.sqlite'; $source = sys_get_temp_dir().'/db-ref.sqlite';
$target = __DIR__ . '/../../../../../tests/db-ref.sqlite.bkp'; $target = sys_get_temp_dir().'/db-ref.sqlite.bkp';
$json = __DIR__ . '/../../../../../tests/fixtures.json'; $json = sys_get_temp_dir().'/fixtures.json';
$renamed = false; $renamed = false;
if (is_file($source)) { if (is_file($source)) {

View File

@@ -37,7 +37,7 @@ class SetupTestsDbs extends Command
)); ));
} }
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../hudson/InstallDBs.yml')); $settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../resources/hudson/InstallDBs.yml'));
$dbs = array(); $dbs = array();

View File

@@ -33,7 +33,6 @@ class Uninstaller extends Command
$root = $this->container['root.path']; $root = $this->container['root.path'];
foreach ([ foreach ([
$root.'/tmp/configuration-compiled.php',
$root.'/config/configuration.yml', $root.'/config/configuration.yml',
$root.'/config/services.yml', $root.'/config/services.yml',
$root.'/config/connexions.yml', $root.'/config/connexions.yml',
@@ -42,27 +41,48 @@ class Uninstaller extends Command
$root.'/config/connexion.inc', $root.'/config/connexion.inc',
$root.'/config/_GV.php', $root.'/config/_GV.php',
$root.'/config/_GV.php.old', $root.'/config/_GV.php.old',
$root.'/tmp/cache_registry.php', $root.'/config/configuration-compiled.php',
$root.'/tmp/cache_registry.yml',
] as $file) { ] as $file) {
if (is_file($file)) { if ($this->container['filesystem']->exists($file)) {
unlink($file); unlink($file);
} }
} }
foreach ([ foreach ([
$root.'/tmp/serializer', $this->container['tmp.download.path'],
$root.'/tmp/cache_twig', $this->container['tmp.lazaret.path'],
$root.'/tmp/translations', $this->container['tmp.caption.path'],
$root.'/tmp/cache_minify', $this->container['tmp.path'].'/sessions',
$root.'/tmp/download', $this->container['tmp.path'].'/locks',
$root.'/tmp/locks', ] as $resource) {
$root.'/tmp/cache', if (is_dir($resource)) {
] as $dir) {
if (is_dir($dir)) {
$finder = new Finder(); $finder = new Finder();
foreach ($finder->files()->in($dir) as $file) { foreach ($finder->files()->in($resource) as $file) {
unlink($file); $this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
}
}
foreach ($this->container['cache.paths'] as $path) {
foreach ([
$path.'/cache_registry.php',
$path.'/cache_registry.yml',
$path.'/serializer',
$path.'/doctrine',
$path.'/twig',
$path.'/translations',
$path.'/minify',
$path.'/profiler',
] as $resource) {
if (is_dir($resource)) {
$finder = new Finder();
foreach ($finder->files()->in($resource) as $file) {
$this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
} }
} }
} }

View File

@@ -72,8 +72,8 @@ class XSendFileMappingGenerator extends Command
private function computeMapping($paths) private function computeMapping($paths)
{ {
return array_merge([ return array_merge([
['mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'], ['mount-point' => 'protected_lazaret', 'directory' => $this->container['tmp.lazaret.path']],
['mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'], ['mount-point' => 'protected_download', 'directory' => $this->container['tmp.download.path']],
], array_map([$this, 'pathsToConf'], array_unique($paths))); ], array_map([$this, 'pathsToConf'], array_unique($paths)));
} }

View File

@@ -52,7 +52,7 @@ class SchedulerRun extends Command
} }
$this->container['signal-handler']->register([SIGINT, SIGTERM], [$this, 'signalHandler']); $this->container['signal-handler']->register([SIGINT, SIGTERM], [$this, 'signalHandler']);
$this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['root.path'].'/tmp/locks')); $this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['tmp.path'].'/locks'));
$this->container['task-manager']->start(); $this->container['task-manager']->start();
} }
} }

View File

@@ -61,7 +61,7 @@ class TaskRun extends Command
$logger->pushHandler(new RotatingFileHandler($file->getPath(), $this->container['task-manager.logger.configuration']['max-files'], $this->container['task-manager.logger.configuration']['level'])); $logger->pushHandler(new RotatingFileHandler($file->getPath(), $this->container['task-manager.logger.configuration']['max-files'], $this->container['task-manager.logger.configuration']['level']));
} }
$job->addSubscriber(new LockFileSubscriber('task-'.$task->getId(), $logger, $this->container['root.path'].'/tmp/locks')); $job->addSubscriber(new LockFileSubscriber('task-'.$task->getId(), $logger, $this->container['tmp.path'].'/locks'));
$job->addSubscriber(new StopSignalSubscriber($this->container['signal-handler'], $logger)); $job->addSubscriber(new StopSignalSubscriber($this->container['signal-handler'], $logger));
if ($input->getOption('listen-signal')) { if ($input->getOption('listen-signal')) {

View File

@@ -795,7 +795,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/csv/', function (Application $app) { $controllers->get('/import/example/csv/', function (Application $app) {
$file = new \SplFileInfo($app['root.path'] . '/lib/Fixtures/exampleImportUsers.csv'); $file = new \SplFileInfo($app['root.path'] . '/resources/examples/example_import_users.csv');
if (!$file->isFile()) { if (!$file->isFile()) {
$app->abort(400); $app->abort(400);
@@ -814,7 +814,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/rtf/', function (Application $app) { $controllers->get('/import/example/rtf/', function (Application $app) {
$file = new \SplFileInfo($app['root.path'] . '/lib/Fixtures/Fields.rtf'); $file = new \SplFileInfo($app['root.path'] . '/resources/examples/fields.rtf');
if (!$file->isFile()) { if (!$file->isFile()) {
$app->abort(400); $app->abort(400);

View File

@@ -519,8 +519,8 @@ class V1 implements ControllerProviderInterface
'report' => [ 'report' => [
'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']), 'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']),
], ],
'filesystem' => [ 'storage' => [
'noWeb' => $app['conf']->get(['main', 'storage', 'subdefs', 'default-dir']), 'documents' => $app['conf']->get(['main', 'storage', 'subdefs']),
], ],
'searchEngine' => [ 'searchEngine' => [
'configuration' => [ 'configuration' => [

View File

@@ -26,9 +26,10 @@ class Minifier implements ControllerProviderInterface
$controllers = $app['controllers_factory']; $controllers = $app['controllers_factory'];
$controllers->get('/', function (Application $app, Request $request) { $controllers->get('/', function (Application $app, Request $request) {
// cache directory path // cache directory path
$min_cachePath = $app['root.path'] . '/tmp/cache_minify'; $min_cachePath = $app['cache.path'].'/minify';
// ensure path is created
$app['filesystem']->mkdir($min_cachePath);
/** /**
* Cache file locking. Set to false if filesystem is NFS. On at least one * Cache file locking. Set to false if filesystem is NFS. On at least one

View File

@@ -136,7 +136,7 @@ class DoDownload implements ControllerProviderInterface
$mime = $subdef['mime']; $mime = $subdef['mime'];
$list['complete'] = true; $list['complete'] = true;
} else { } else {
$exportFile = $app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip'; $exportFile = $app['tmp.download.path'].'/'.$token->getValue() . '.zip';
$mime = 'application/zip'; $mime = 'application/zip';
} }
@@ -184,7 +184,7 @@ class DoDownload implements ControllerProviderInterface
$app, $app,
$token, $token,
$list, $list,
sprintf($app['root.path'] . '/tmp/download/%s.zip', $token->getValue()) // Dest file sprintf($app['tmp.download.path'].'/%s.zip', $token->getValue()) // Dest file
); );
return $app->json([ return $app->json([

View File

@@ -223,7 +223,7 @@ class Export implements ControllerProviderInterface
$app, $app,
$token, $token,
$list, $list,
$app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip' $app['tmp.download.path'].'/'. $token->getValue() . '.zip'
); );
$remaingEmails = $destMails; $remaingEmails = $destMails;

View File

@@ -126,7 +126,7 @@ class Lazaret implements ControllerProviderInterface
'base_id' => $lazaretFile->getBaseId(), 'base_id' => $lazaretFile->getBaseId(),
'created' => $lazaretFile->getCreated()->format(\DateTime::ATOM), 'created' => $lazaretFile->getCreated()->format(\DateTime::ATOM),
'updated' => $lazaretFile->getUpdated()->format(\DateTime::ATOM), 'updated' => $lazaretFile->getUpdated()->format(\DateTime::ATOM),
'pathname' => $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(), 'pathname' => $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename(),
'sha256' => $lazaretFile->getSha256(), 'sha256' => $lazaretFile->getSha256(),
'uuid' => $lazaretFile->getUuid(), 'uuid' => $lazaretFile->getUuid(),
]; ];
@@ -174,8 +174,8 @@ class Lazaret implements ControllerProviderInterface
return $app->json($ret); return $app->json($ret);
} }
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(); $lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename(); $lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
try { try {
$borderFile = Border\File::buildFromPathfile( $borderFile = Border\File::buildFromPathfile(
@@ -294,8 +294,8 @@ class Lazaret implements ControllerProviderInterface
protected function denyLazaretFile(Application $app, LazaretFile $lazaretFile) protected function denyLazaretFile(Application $app, LazaretFile $lazaretFile)
{ {
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(); $lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename(); $lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
$app['EM']->remove($lazaretFile); $app['EM']->remove($lazaretFile);
$app['EM']->flush(); $app['EM']->flush();
@@ -386,8 +386,8 @@ class Lazaret implements ControllerProviderInterface
return $app->json($ret); return $app->json($ret);
} }
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(); $lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename(); $lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
try { try {
$media = $app['mediavorus']->guess($lazaretFileName); $media = $app['mediavorus']->guess($lazaretFileName);
@@ -437,7 +437,7 @@ class Lazaret implements ControllerProviderInterface
return new Response(null, 404); return new Response(null, 404);
} }
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename(); $lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
return $app['phraseanet.file-serve']->deliverFile($lazaretThumbFileName, $lazaretFile->getOriginalName(), DeliverDataInterface::DISPOSITION_INLINE, 'image/jpeg', 3600); return $app['phraseanet.file-serve']->deliverFile($lazaretThumbFileName, $lazaretFile->getOriginalName(), DeliverDataInterface::DISPOSITION_INLINE, 'image/jpeg', 3600);
} }

View File

@@ -252,11 +252,9 @@ class Tools implements ControllerProviderInterface
$dataUri = DataURI\Parser::parse($request->request->get('image', '')); $dataUri = DataURI\Parser::parse($request->request->get('image', ''));
$path = $app['root.path'] . '/tmp';
$name = sprintf('extractor_thumb_%s', $record->get_serialize_key()); $name = sprintf('extractor_thumb_%s', $record->get_serialize_key());
$fileName = sprintf('%s/%s.png', $path, $name); $fileName = sprintf('%s/%s.png', sys_get_temp_dir(), $name);
file_put_contents($fileName, $dataUri->getData()); file_put_contents($fileName, $dataUri->getData());

View File

@@ -22,12 +22,10 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHa
class SessionHandlerFactory class SessionHandlerFactory
{ {
private $connectionFactory; private $connectionFactory;
private $root;
public function __construct(ConnectionFactory $connectionFactory, $root = null) public function __construct(ConnectionFactory $connectionFactory)
{ {
$this->connectionFactory = $connectionFactory; $this->connectionFactory = $connectionFactory;
$this->root = __DIR__ . '/../../../../..';
} }
/** /**
@@ -62,7 +60,7 @@ class SessionHandlerFactory
) )
); );
case 'file': case 'file':
return new NativeFileSessionHandler($this->root.'/tmp/sessions'); return new NativeFileSessionHandler(isset($options['save-path']) ? $options['save-path'] : null);
case 'redis': case 'redis':
return new WriteCheckSessionHandler( return new WriteCheckSessionHandler(
new RedisSessionHandler( new RedisSessionHandler(

View File

@@ -21,7 +21,9 @@ class CacheServiceProvider implements ServiceProviderInterface
{ {
public function register(Application $app) public function register(Application $app)
{ {
$app['phraseanet.cache-registry'] = $app['root.path'] . '/tmp/cache_registry.php'; $app['phraseanet.cache-registry'] = $app->share(function () use ($app) {
return $app['cache.path'].'/cache_registry.php';
});
$app['phraseanet.cache-compiler'] = $app->share(function () { $app['phraseanet.cache-compiler'] = $app->share(function () {
return new Compiler(); return new Compiler();

View File

@@ -34,8 +34,8 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
$app['phraseanet.configuration.compiler'] = $app->share(function (SilexApplication $app) { $app['phraseanet.configuration.compiler'] = $app->share(function (SilexApplication $app) {
return new Compiler(); return new Compiler();
}); });
$app['phraseanet.configuration.config-path'] = $app['root.path'] . '/config/configuration.yml'; $app['phraseanet.configuration.config-path'] = $app['root.path'].'/config/configuration.yml';
$app['phraseanet.configuration.config-compiled-path'] = $app['root.path'] . '/tmp/configuration-compiled.php'; $app['phraseanet.configuration.config-compiled-path'] = $app['root.path'].'/config/configuration-compiled.php';
$app['configuration.store'] = $app->share(function (SilexApplication $app) { $app['configuration.store'] = $app->share(function (SilexApplication $app) {
return new HostConfiguration(new Configuration( return new HostConfiguration(new Configuration(

View File

@@ -21,7 +21,10 @@ class JMSSerializerServiceProvider implements ServiceProviderInterface
{ {
public function register(Application $app) public function register(Application $app)
{ {
$app['serializer.cache-directory'] = $app['root.path'] . '/tmp/serializer/'; $app['serializer.cache-directory'] = $app->share(function () use ($app) {
return $app['cache.path'].'/serializer/';
});
$app['serializer.src_directory'] = $app['root.path'] . '/vendor/jms/serializer/src/'; $app['serializer.src_directory'] = $app['root.path'] . '/vendor/jms/serializer/src/';
$app['serializer.metadata.annotation_reader'] = $app->share(function () use ($app) { $app['serializer.metadata.annotation_reader'] = $app->share(function () use ($app) {

View File

@@ -37,7 +37,9 @@ class ORMServiceProvider implements ServiceProviderInterface
{ {
public function register(Application $app) public function register(Application $app)
{ {
$app['EM.sql-logger.file'] = $app['root.path'] . '/logs/doctrine-log.log'; $app['EM.sql-logger.file'] = $app->share(function (Application $app) {
return $app['log.path'].'/doctrine-log.log';
});
$app['EM.sql-logger.max-files'] = 5; $app['EM.sql-logger.max-files'] = 5;
$app['EM.sql-logger'] = $app->share(function (Application $app) { $app['EM.sql-logger'] = $app->share(function (Application $app) {
@@ -55,7 +57,7 @@ class ORMServiceProvider implements ServiceProviderInterface
$annotationReader = new AnnotationReader(); $annotationReader = new AnnotationReader();
$fileCacheReader = new FileCacheReader( $fileCacheReader = new FileCacheReader(
$annotationReader, $annotationReader,
$app['root.path']."/tmp/doctrine", $app['cache.path'].'/doctrine',
$app['debug'] $app['debug']
); );
@@ -97,7 +99,7 @@ class ORMServiceProvider implements ServiceProviderInterface
$config->setMetadataDriverImpl($app['EM.driver']); $config->setMetadataDriverImpl($app['EM.driver']);
$config->setProxyDir($app['root.path'] . '/tmp/doctrine-proxies'); $config->setProxyDir($app['root.path'].'/resources/proxies');
$config->setProxyNamespace('Alchemy\Phrasea\Model\Proxies'); $config->setProxyNamespace('Alchemy\Phrasea\Model\Proxies');
$config->setAutoGenerateProxyClasses($app['debug']); $config->setAutoGenerateProxyClasses($app['debug']);
$config->addEntityNamespace('Phraseanet', 'Alchemy\Phrasea\Model\Entities'); $config->addEntityNamespace('Phraseanet', 'Alchemy\Phrasea\Model\Entities');

View File

@@ -23,7 +23,7 @@ class SessionHandlerServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['session.storage.handler.factory'] = $app->share(function (Application $app) { $app['session.storage.handler.factory'] = $app->share(function (Application $app) {
return new SessionHandlerFactory($app['cache.connection-factory'], $app['root.path']); return new SessionHandlerFactory($app['cache.connection-factory']);
}); });
} }

View File

@@ -58,7 +58,7 @@ class TasksServiceProvider implements ServiceProviderInterface
}); });
$app['task-manager.log-file.root'] = $app->share(function (Application $app) { $app['task-manager.log-file.root'] = $app->share(function (Application $app) {
return $app['root.path'].'/logs'; return $app['log.path'];
}); });
$app['task-manager.log-file.factory'] = $app->share(function (Application $app) { $app['task-manager.log-file.factory'] = $app->share(function (Application $app) {

View File

@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Core;
class Version class Version
{ {
protected static $number = '3.9.0-alpha.18'; protected static $number = '3.9.0-alpha.19';
protected static $name = 'Gorgosaurus'; protected static $name = 'Gorgosaurus';
public static function getNumber() public static function getNumber()

View File

@@ -205,7 +205,7 @@ class TokenManipulator implements ManipulatorInterface
switch ($token->getType()) { switch ($token->getType()) {
case 'download': case 'download':
case 'email': case 'email':
$file = $this->app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip'; $file = $this->app['tmp.download.path'].'/' . $token->getValue() . '.zip';
if (is_file($file)) { if (is_file($file)) {
unlink($file); unlink($file);
} }

View File

@@ -59,13 +59,16 @@ class Installer
private function populateRegistryData($serverName, $dataPath) private function populateRegistryData($serverName, $dataPath)
{ {
if (null === realpath($dataPath)) { if (null === $dataPath = realpath($dataPath)) {
throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $dataPath)); throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $dataPath));
} }
$dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR; $this->app['conf']->set(['main', 'storage', 'subdefs'], $dataPath);
$this->app['conf']->set(['main', 'storage', 'cache'], realpath(__DIR__ . '/../../../../cache'));
$this->app['conf']->set(['main', 'storage', 'subdefs', 'default-dir'], $dataPath); $this->app['conf']->set(['main', 'storage', 'log'], realpath(__DIR__ . '/../../../../logs'));
$this->app['conf']->set(['main', 'storage', 'download'], realpath(__DIR__ . '/../../../../tmp/download'));
$this->app['conf']->set(['main', 'storage', 'lazaret'], realpath(__DIR__ . '/../../../../tmp/lazaret'));
$this->app['conf']->set(['main', 'storage', 'caption'], realpath(__DIR__ . '/../../../../tmp/caption'));
$this->app['conf']->set('servername', $serverName); $this->app['conf']->set('servername', $serverName);
$this->app['conf']->set('registry', $this->app['registry.manipulator']->getRegistryData()); $this->app['conf']->set('registry', $this->app['registry.manipulator']->getRegistryData());
} }

View File

@@ -35,8 +35,8 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface
); );
} }
if ($conf->has(['main', 'storage', 'subdefs', 'default-dir'])) { if ($conf->has(['main', 'storage', 'subdefs'])) {
$paths[] = $conf->get(['main', 'storage', 'subdefs', 'default-dir']); $paths[] = $conf->get(['main', 'storage', 'subdefs']);
} }
foreach ($paths as $path) { foreach ($paths as $path) {

View File

@@ -31,16 +31,12 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen
$baseDir . '/config/wm', $baseDir . '/config/wm',
$baseDir . '/logs', $baseDir . '/logs',
$baseDir . '/tmp', $baseDir . '/tmp',
$baseDir . '/www/custom',
$baseDir . '/tmp/locks', $baseDir . '/tmp/locks',
$baseDir . '/tmp/cache_twig', $baseDir . '/tmp/caption',
$baseDir . '/tmp/serializer',
$baseDir . '/tmp/doctrine',
$baseDir . '/tmp/cache_minify',
$baseDir . '/tmp/lazaret', $baseDir . '/tmp/lazaret',
$baseDir . '/tmp/desc_tmp',
$baseDir . '/tmp/download', $baseDir . '/tmp/download',
$baseDir . '/tmp/batches' $baseDir . '/cache',
$baseDir . '/www/custom',
]; ];
foreach ($paths as $path) { foreach ($paths as $path) {

View File

@@ -190,14 +190,14 @@ class FtpJob extends AbstractJob
if ($subdef == 'caption') { if ($subdef == 'caption') {
$desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_XML, $exportElement->isBusinessfields()); $desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_XML, $exportElement->isBusinessfields());
$localfile = $app['root.path'] . '/tmp/' . md5($desc . time() . mt_rand()); $localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) { if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire'); throw new \Exception('Impossible de creer un fichier temporaire');
} }
} elseif ($subdef == 'caption-yaml') { } elseif ($subdef == 'caption-yaml') {
$desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields()); $desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields());
$localfile = $app['root.path'] . '/tmp/' . md5($desc . time() . mt_rand()); $localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) { if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire'); throw new \Exception('Impossible de creer un fichier temporaire');
} }
@@ -272,7 +272,7 @@ class FtpJob extends AbstractJob
$buffer .= $root . '/' . $folder . $filename . "\n"; $buffer .= $root . '/' . $folder . $filename . "\n";
} }
$tmpfile = $app['root.path'] . '/tmp/tmpftpbuffer' . $date->format('U') . '.txt'; $tmpfile = sys_get_temp_dir().'/tmpftpbuffer' . $date->format('U') . '.txt';
file_put_contents($tmpfile, $buffer); file_put_contents($tmpfile, $buffer);

View File

@@ -45,11 +45,17 @@ class CachedTranslator extends Translator
return; return;
} }
if (null === $this->options['cache_dir']) { if (is_callable($this->options['cache_dir'])) {
$cache_dir = call_user_func($this->options['cache_dir'], $this->app);
} else {
$cache_dir = $this->options['cache_dir'];
}
if (null === $cache_dir) {
return parent::loadCatalogue($locale); return parent::loadCatalogue($locale);
} }
$cache = new ConfigCache($this->options['cache_dir'].'/catalogue.'.$locale.'.php', $this->options['debug']); $cache = new ConfigCache($cache_dir.'/catalogue.'.$locale.'.php', $this->options['debug']);
if (!$cache->isFresh()) { if (!$cache->isFresh()) {
parent::loadCatalogue($locale); parent::loadCatalogue($locale);

View File

@@ -17,9 +17,9 @@ class Setup_Upgrade
{ {
/** /**
* *
* @var appbox * @var Applications
*/ */
private $appbox; private $app;
/** /**
* *
@@ -30,16 +30,16 @@ class Setup_Upgrade
public function __construct(Application $app, $force = false) public function __construct(Application $app, $force = false)
{ {
if ($force) { if ($force) {
self::remove_lock_file(); $this->remove_lock_file();
} }
if (self::lock_exists()) { if ($this->lock_exists()) {
throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started'); throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started');
} }
$this->appbox = $app['phraseanet.appbox']; $this->app = $app;
if (version_compare($this->appbox->get_version(), '3.9', '<') if (version_compare($this->app['phraseanet.appbox']->get_version(), '3.9', '<')
&& count(MailChecker::getWrongEmailUsers($app)) > 0) { && count(MailChecker::getWrongEmailUsers($app)) > 0) {
throw new \Exception_Setup_FixBadEmailAddresses('Please fix the database before starting'); throw new \Exception_Setup_FixBadEmailAddresses('Please fix the database before starting');
} }
@@ -55,7 +55,7 @@ class Setup_Upgrade
*/ */
public function __destruct() public function __destruct()
{ {
self::remove_lock_file(); $this->remove_lock_file();
return; return;
} }
@@ -93,9 +93,9 @@ class Setup_Upgrade
'last_update' => $date_obj->format(DATE_ATOM), 'last_update' => $date_obj->format(DATE_ATOM),
], 1); ], 1);
if (!file_put_contents(self::get_lock_file(), $datas)) if (!file_put_contents($this->get_lock_file(), $datas))
throw new Exception_Setup_CannotWriteLockFile( throw new Exception_Setup_CannotWriteLockFile(
sprintf('Cannot write lock file to %s', self::get_lock_file()) sprintf('Cannot write lock file to %s', $this->get_lock_file())
); );
return $this; return $this;
@@ -106,11 +106,11 @@ class Setup_Upgrade
* *
* @return boolean * @return boolean
*/ */
private static function lock_exists() private function lock_exists()
{ {
clearstatcache(); clearstatcache();
return file_exists(self::get_lock_file()); return file_exists($this->get_lock_file());
} }
/** /**
@@ -118,19 +118,19 @@ class Setup_Upgrade
* *
* @return string * @return string
*/ */
private static function get_lock_file() private function get_lock_file()
{ {
return __DIR__ . '/../../../tmp/upgrade.lock'; return $this->app['tmp.path'].'/locks/upgrade.lock';
} }
/** /**
* *
* @return Void * @return Void
*/ */
private static function remove_lock_file() private function remove_lock_file()
{ {
if (self::lock_exists()) { if ($this->lock_exists()) {
unlink(self::get_lock_file()); unlink($this->get_lock_file());
} }
return; return;

View File

@@ -288,30 +288,33 @@ class appbox extends base
$app['phraseanet.pre-schema-upgrader']->apply($app); $app['phraseanet.pre-schema-upgrader']->apply($app);
$finder = new Finder(); $finder = new Finder();
$finder->in([ $in = [];
$this->app['root.path'] . '/tmp/cache_minify/', foreach ($app['cache.paths'] as $path) {
$this->app['root.path'] . '/tmp/cache_twig/', $in[] = $path.'/minify/';
$this->app['root.path'] . '/tmp/translations/', $in[] = $path.'/twig/';
$this->app['root.path'] . '/tmp/cache/profiler/', $in[] = $path.'/translations/';
$this->app['root.path'] . '/tmp/doctrine/', $in[] = $path.'/profiler/';
$this->app['root.path'] . '/tmp/serializer/', $in[] = $path.'/doctrine/';
]) $in[] = $path.'/serializer/';
};
$finder->in(array_filter($in, function($path) {
return is_dir($path);
}))
->depth(0) ->depth(0)
->ignoreVCS(true) ->ignoreVCS(true)
->ignoreDotFiles(true); ->ignoreDotFiles(true);
foreach ($finder as $file) {
$app['filesystem']->remove($file); $app['filesystem']->remove($finder);
}
foreach ([ foreach ([
'config/custom_files/' => 'www/custom/', 'config/custom_files/' => 'www/custom/',
'config/minilogos/' => 'www/custom/minilogos/', 'config/minilogos/' => 'www/custom/minilogos/',
'config/stamp/' => 'www/custom/stamp/', 'config/stamp/' => 'www/custom/stamp/',
'config/status/' => 'www/custom/status/', 'config/status/' => 'www/custom/status/',
'config/wm/' => 'www/custom/wm/', 'config/wm/' => 'www/custom/wm/',
] as $source => $target) { ] as $source => $target) {
$app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target); $app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target, null, array('override' => true));
} }
$advices = $this->upgradeDB(true, $app); $advices = $this->upgradeDB(true, $app);

View File

@@ -594,7 +594,7 @@ class databox extends base
$databox = $app['phraseanet.appbox']->get_databox($sbas_id); $databox = $app['phraseanet.appbox']->get_databox($sbas_id);
$databox->insert_datas(); $databox->insert_datas();
$databox->setNewStructure( $databox->setNewStructure(
$data_template, $app['conf']->get(['main', 'storage', 'subdefs', 'default-dir']) $data_template, $app['conf']->get(['main', 'storage', 'subdefs'])
); );
return $databox; return $databox;
@@ -934,7 +934,7 @@ class databox extends base
$contents = str_replace( $contents = str_replace(
["{{basename}}", "{{datapathnoweb}}"] ["{{basename}}", "{{datapathnoweb}}"]
, [$this->dbname, $path_doc] , [$this->dbname, rtrim($path_doc, '/').'/']
, $contents , $contents
); );

View File

@@ -42,7 +42,7 @@ class module_console_sphinxGenerateSuggestion extends Command
) )
)); ));
$tmp_file = $this->container['root.path'] . '/tmp/dict' . $index . '.txt'; $tmp_file = sys_get_temp_dir().'/dict' . $index . '.txt';
$databox = $this->getService('phraseanet.appbox')->get_databox($sbas_id); $databox = $this->getService('phraseanet.appbox')->get_databox($sbas_id);

View File

@@ -31,21 +31,16 @@ class module_console_systemClearCache extends Command
{ {
$finder = new Finder(); $finder = new Finder();
$in = [];
foreach ($this->container['cache.paths'] as $path) {
$in[] = $path;
};
$finder $finder
->exclude('.git') ->exclude('.git')
->exclude('.svn') ->exclude('.svn')
->in([ ->in($in);
$this->container['root.path'] . '/tmp/cache_minify/',
$this->container['root.path'] . '/tmp/cache_twig/',
$this->container['root.path'] . '/tmp/translations/',
$this->container['root.path'] . '/tmp/cache/profiler/',
$this->container['root.path'] . '/tmp/doctrine/',
$this->container['root.path'] . '/tmp/serializer/',
]);
$filesystem = new Filesystem(); $this->container['filesystem']->remove($finder);
$filesystem->remove($finder);
if ($this->container['phraseanet.configuration-tester']->isInstalled()) { if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
$this->getService('phraseanet.cache-service')->flushAll(); $this->getService('phraseanet.cache-service')->flushAll();

View File

@@ -89,7 +89,7 @@ class patch_370alpha7a extends patchAbstract
$i = 0; $i = 0;
foreach ($rs as $row) { foreach ($rs as $row) {
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath']; $filePath = $app['tmp.lazaret.path'].'/'.$row['filepath'];
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) { if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
continue; continue;
} }
@@ -100,7 +100,7 @@ class patch_370alpha7a extends patchAbstract
$spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO); $spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO);
$spec->setDimensions(375, 275); $spec->setDimensions(375, 275);
$thumbPath = $app['root.path'] . '/tmp/lazaret/' . sprintf("thumb_%s", $row['filepath']); $thumbPath = $app['tmp.lazaret.path'].'/'.sprintf("thumb_%s", $row['filepath']);
try { try {
$app['media-alchemyst']->turnInto($filePath, $thumbPath, $spec); $app['media-alchemyst']->turnInto($filePath, $thumbPath, $spec);

View File

@@ -63,11 +63,11 @@ class patch_380alpha16a extends patchAbstract
} }
$xsendfile['mapping'][] = [ $xsendfile['mapping'][] = [
'directory' => $app['root.path'] . '/tmp/lazaret/', 'directory' => $app['tmp.lazaret.path'],
'mount-point' => '/lazaret/', 'mount-point' => '/lazaret/',
]; ];
$xsendfile['mapping'][] = [ $xsendfile['mapping'][] = [
'directory' => $app['root.path'] . '/tmp/download/', 'directory' => $app['tmp.download.path'],
'mount-point' => '/download/', 'mount-point' => '/download/',
]; ];

View File

@@ -0,0 +1,100 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_390alpha19a extends patchAbstract
{
/** @var string */
private $release = '3.9.0-alpha.19';
/** @var array */
private $concern = [base::APPLICATION_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$storage = $app['conf']->get(['main', 'storage']);
$storage['cache'] = $app['root.path'].'/cache';
$storage['log'] = $app['root.path'].'/logs';
$storage['download'] = $app['root.path'].'/tmp/download';
$storage['lazaret'] = $app['root.path'].'/tmp/lazaret';
$storage['caption'] = $app['root.path'].'/tmp/caption';
$app['conf']->set(['main', 'storage'], $storage);
// update file structure
$this->removeDirectory($app, $app['root.path'].'/tmp/cache_twig');
$this->removeDirectory($app, $app['root.path'].'/tmp/doctrine');
$this->removeDirectory($app, $app['root.path'].'/tmp/profiler');
$this->removeDirectory($app, $app['root.path'].'/tmp/serializer');
$this->removeDirectory($app, $app['root.path'].'/tmp/translations');
$this->removeDirectory($app, $app['root.path'].'/tmp/cache_minify');
$this->removeDirectory($app, $app['root.path'].'/features');
$this->removeDirectory($app, $app['root.path'].'/hudson');
$this->removeDirectory($app, $app['root.path'].'/locales');
$this->removeDirectory($app, $app['root.path'].'/vagrant');
$this->removeDirectory($app, $app['root.path'].'/tmp/doctrine-proxies');
$this->copyFile($app, $app['root.path'].'/tmp/cache_registry.php', $app['cache.path'].'/cache_registry.php');
$this->copyFile($app, $app['root.path'].'/tmp/configuration-compiled.php', $app['root.path'].'/config/configuration-compiled.php');
return true;
}
private function removeDirectory(Application $app, $originDir)
{
if (is_dir($originDir)) {
$app['filesystem']->remove($originDir);
}
}
private function copyFile(Application $app, $originFile, $targetFile)
{
if ($app['filesystem']->exists($originFile)) {
$app['filesystem']->copy($originFile, $targetFile);
}
}
}

View File

@@ -165,7 +165,7 @@ class patch_390alpha9b extends patchAbstract
'GV_smtp_secure' => ['registry', 'email', 'smtp-secure-mode'], 'GV_smtp_secure' => ['registry', 'email', 'smtp-secure-mode'],
'GV_smtp_user' => ['registry', 'email', 'smtp-user'], 'GV_smtp_user' => ['registry', 'email', 'smtp-user'],
'GV_smtp_password' => ['registry', 'email', 'smtp-password'], 'GV_smtp_password' => ['registry', 'email', 'smtp-password'],
'GV_base_datapath_noweb' => ['main', 'storage', 'subdefs', 'default-dir'], 'GV_base_datapath_noweb' => ['main', 'storage', 'subdefs'],
'GV_youtube_api' => ['main', 'bridge', 'youtube', 'enabled'], 'GV_youtube_api' => ['main', 'bridge', 'youtube', 'enabled'],
'GV_youtube_client_id' => ['main', 'bridge', 'youtube', 'client_id'], 'GV_youtube_client_id' => ['main', 'bridge', 'youtube', 'client_id'],
'GV_youtube_client_secret' => ['main', 'bridge', 'youtube', 'client_secret'], 'GV_youtube_client_secret' => ['main', 'bridge', 'youtube', 'client_secret'],

View File

@@ -41,7 +41,7 @@ class random
switch ($row['type']) { switch ($row['type']) {
case 'download': case 'download':
case 'email': case 'email':
$file = $this->app['root.path'] . '/tmp/download/' . $row['value'] . '.zip'; $file = $this->app['tmp.download.path'].'/'.$row['value'].'.zip';
if (is_file($file)) if (is_file($file))
unlink($file); unlink($file);
break; break;

View File

@@ -631,8 +631,7 @@ class set_export extends set_abstract
$files[$id]["export_name"] = $tmp_name; $files[$id]["export_name"] = $tmp_name;
if (in_array('caption', $subdefs)) { if (in_array('caption', $subdefs)) {
$caption_dir = $this->app['root.path'] . '/tmp/desc_tmp/' $caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
. time() . $this->app['authentication']->getUser()->getId() . '/';
$filesystem->mkdir($caption_dir, 0750); $filesystem->mkdir($caption_dir, 0750);
@@ -653,8 +652,7 @@ class set_export extends set_abstract
} }
if (in_array('caption-yaml', $subdefs)) { if (in_array('caption-yaml', $subdefs)) {
$caption_dir = $this->app['root.path'] . '/tmp/desc_tmp/' $caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
. time() . $this->app['authentication']->getUser()->getId() . '/';
$filesystem->mkdir($caption_dir, 0750); $filesystem->mkdir($caption_dir, 0750);

View File

@@ -72,8 +72,12 @@ main:
swftools_timeout: 60 swftools_timeout: 60
unoconv_timeout: 60 unoconv_timeout: 60
storage: storage:
subdefs: subdefs: null
default-dir: null cache: null
log : null
download: null
lazaret: null
caption: null
bridge: bridge:
youtube: youtube:
enabled: false enabled: false

2
logs/.gitignore vendored
View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
logs/.gitkeep Normal file
View File

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="BuildSourceHudson" default="Main" basedir="."> <project name="BuildSourceHudson" default="Main" basedir="">
<property file="build.properties"/> <property file="build.properties"/>
<target name="Main"> <target name="Main">
<delete includeemptydirs="true" verbose="false" failonerror="false"> <delete includeemptydirs="true" verbose="false" failonerror="false">

View File

@@ -1,8 +1,8 @@
<?php <?php
require __DIR__ . '/../lib/autoload.php'; require __DIR__ . '/../../lib/autoload.php';
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; $app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php';
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
$structure = $databox->get_subdef_structure(); $structure = $databox->get_subdef_structure();

View File

View File

@@ -0,0 +1,210 @@
servername: 'http://local.phrasea/'
languages:
available: []
default: 'fr'
main:
maintenance: false
key: ''
database:
host: 'sql-host'
port: 3306
user: 'sql-user'
password: 'sql-password'
dbname: ab_phraseanet
driver: pdo_mysql
charset: UTF8
database-test:
driver: pdo_sqlite
path: '/tmp/db.sqlite'
charset: UTF8
cache:
type: ArrayCache
options: []
opcodecache:
type: ArrayCache
options: []
search-engine:
type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine
options: []
task-manager:
status: started
enabled: true
logger:
max-files: 10
enabled: true
level: INFO
listener:
protocol: tcp
host: 127.0.0.1
port: 6660
linger: 500
websocket-server:
host: local.phrasea
port: 9090
ip: 0.0.0.0
subscriber:
protocol: tcp
host: 127.0.0.1
port: 13598
session:
type: 'redis'
options:
host: localhost
port: 6379
ttl: 86400
binaries:
ghostscript_binary: null
php_binary: null
swf_extract_binary: null
pdf2swf_binary: null
swf_render_binary: null
unoconv_binary: null
ffmpeg_binary: null
ffprobe_binary: null
mp4box_binary: null
pdftotext_binary: null
recess_binary: null
phraseanet_indexer: null
ffmpeg_timeout: 3600
ffprobe_timeout: 60
gs_timeout: 60
mp4box_timeout: 60
swftools_timeout: 60
unoconv_timeout: 60
storage:
subdefs: null
cache: /tmp/phraseanet/cache
log : /tmp/phraseanet/log
download: /var/www/phraseanet/tmp/download
lazaret: /var/www/phraseanet/tmp/lazaret
caption: /var/www/phraseanet/tmp/caption
bridge:
youtube:
enabled: false
client_id: null
client_secret: null
developer_key: null
flickr:
enabled: false
client_id: null
client_secret: null
dailymotion:
enabled: false
client_id: null
client_secret: null
trusted-proxies: ['127.0.0.1']
debugger:
allowed-ips: ['192.168.56.1']
border-manager:
enabled: true
extension-mapping: { }
checkers:
-
type: Checker\Sha256
enabled: true
-
type: Checker\UUID
enabled: true
-
type: Checker\Colorspace
enabled: false
options:
colorspaces: [cmyk, grayscale, rgb]
-
type: Checker\Dimension
enabled: false
options:
width: 80
height: 160
-
type: Checker\Extension
enabled: false
options:
extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2]
-
type: Checker\Filename
enabled: false
options:
sensitive: true
-
type: Checker\MediaType
enabled: false
options:
mediatypes: [Audio, Document, Flash, Image, Video]
authentication:
auto-create:
templates: { }
captcha:
enabled: true
trials-before-display: 9
providers:
facebook:
enabled: false
options:
app-id: ''
secret: ''
twitter:
enabled: false
options:
consumer-key: ''
consumer-secret: ''
google-plus:
enabled: false
options:
client-id: ''
client-secret: ''
github:
enabled: false
options:
client-id: ''
client-secret: ''
viadeo:
enabled: false
options:
client-id: ''
client-secret: ''
linkedin:
enabled: false
options:
client-id: ''
client-secret: ''
registration-fields:
-
name: company
required: true
-
name: lastname
required: true
-
name: firstname
required: true
-
name: geonameid
required: true
xsendfile:
enabled: false
type: nginx
mapping: []
h264-pseudo-streaming:
enabled: false
type: nginx
mapping: []
plugins: []
api_cors:
enabled: false
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
session:
idle: 0
# 1 week
lifetime: 604800
crossdomain:
allow-access-from:
-
domain: '*.cooliris.com'
secure: 'false'

View File

@@ -26,12 +26,12 @@ vagrantfile-local:
cpus: 1 cpus: 1
provision: provision:
puppet: puppet:
manifests_path: vagrant/vms/phraseanet-php54-nginx/puphpet/puppet manifests_path: resources/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet
manifest_file: manifest.pp manifest_file: manifest.pp
module_path: vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules module_path: resources/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules
options: options:
- '--verbose' - '--verbose'
- '--hiera_config /vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/hiera.yaml' - '--hiera_config /vagrant/resources/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/hiera.yaml'
- '--parser future' - '--parser future'
synced_folder: synced_folder:
KaPfJ4CzfgFk: KaPfJ4CzfgFk:
@@ -150,12 +150,11 @@ nginx:
proxy_buffers: '4 256k' proxy_buffers: '4 256k'
vhosts: vhosts:
issDOx17O4bn: issDOx17O4bn:
server_name: nginx.phraseanet server_name: phraseanet-php54-nginx
server_aliases: server_aliases:
- nginx.phrasea.net - nginx.phraseanet.php54
- nginx.alchemyasp.com
www_root: /var/www/phraseanet/www www_root: /var/www/phraseanet/www
listen_port: '8080' listen_port: '80'
index_files: index_files:
- index.html - index.html
- index.htm - index.htm

Some files were not shown because too many files have changed in this diff Show More