diff --git a/CHANGELOG.md b/CHANGELOG.md index e64e017cc8..0961b8d4e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - BC Break : Removed `bin/console check:config` command. - BC Break : Removed `bin/console check:system` command, replaced by `bin/setup check:system`. - BC Break : Removed `bin/console system:upgrade` command, replaced by `bin/setup system:upgrade`. + - BC Break : Removed `bin/console check:ensure-production-settings` and `bin/console check:ensure-dev-settings` + commands, replaced by `bin/console check:config`. - BC break : Configuration simplification, optimized for performances. - BC Break : Time limits are now applied on templates application. diff --git a/bin/console b/bin/console index 15fbe40d52..fc96f20a29 100755 --- a/bin/console +++ b/bin/console @@ -27,6 +27,7 @@ use Alchemy\Phrasea\Command\UpgradeDBDatas; use Alchemy\Phrasea\CLI; use Alchemy\Phrasea\Command\Plugin\AddPlugin; use Alchemy\Phrasea\Command\Plugin\RemovePlugin; +use Alchemy\Phrasea\Command\CheckConfig; require_once __DIR__ . '/../lib/autoload.php'; @@ -60,6 +61,7 @@ try { $app->command(new \module_console_aboutLicense('about:license')); $app->command(new \module_console_checkExtension('check:extension')); + $app->command(new CheckConfig('check:config')); $app->command(new UpgradeDBDatas('system:upgrade-datas')); diff --git a/lib/Alchemy/Phrasea/Command/CheckConfig.php b/lib/Alchemy/Phrasea/Command/CheckConfig.php new file mode 100644 index 0000000000..63ffb03f47 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/CheckConfig.php @@ -0,0 +1,80 @@ +setDescription("Checks environment"); + + return $this; + } + + /** + * {@inheritdoc} + */ + protected function doExecute(InputInterface $input, OutputInterface $output) + { + $ret = parent::doExecute($input, $output); + + foreach ($this->container['phraseanet.appbox']->get_databoxes() as $databox) { + $output->writeln("\nDatabox ".$databox->get_viewname()." fields configuration\n"); + foreach ($databox->get_meta_structure() as $field) { + if ($field->get_original_source() !== $field->get_tag()->getTagname()) { + $status = ' WARNING '; + $info = sprintf(" (Described as '%s', this source does not seem to exist)", $field->get_original_source()); + } else { + $status = ' OK '; + $info = ''; + } + $output->writeln($status.$databox->get_viewname() . "::".$field->get_name().$info); + } + $output->writeln("\n"); + } + + $output->writeln("\nCache configuration\n"); + + $cache = str_replace('Alchemy\\Phrasea\\Cache\\', '', get_class($this->container['cache'])); + $opCodeCache = str_replace('Alchemy\\Phrasea\\Cache\\', '', get_class($this->container['opcode-cache'])); + + if ('ArrayCache' === $cache) { + $output->writeln(' WARNING Current cache configuration uses ArrayCache (Or cache server is unreachable). Please check your cache configuration to use a cache server.'); + } else { + $output->writeln(' OK Current cache configuration uses '. $cache .''); + } + + if ('ArrayCache' === $opCodeCache) { + $output->writeln(' WARNING Current opcode cache configuration uses ArrayCache. Please check your cache configuration to use an opcode cache.'); + } else { + $output->writeln(' OK Current opcode cache configuration uses '. $opCodeCache .''); + } + + return $ret; + } +} diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index ed845a5944..0202f3bc5e 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -379,7 +379,7 @@ class Fields implements ControllerProviderInterface private function validateTagField(array $field) { try { - \databox_field::loadClassFromTagName($field['tag']); + \databox_field::loadClassFromTagName($field['tag'], true); } catch (\Exception_Databox_metadataDescriptionNotFound $e) { throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown.', $field['tag']))); } diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index 41736ed9c1..944b8d04df 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -143,6 +143,7 @@ class databox_field implements cache_cacheableInterface protected $Vocabulary; protected $VocabularyRestriction = false; protected $on_error = false; + protected $original_src; const TYPE_TEXT = "text"; const TYPE_DATE = "date"; @@ -200,7 +201,8 @@ class databox_field implements cache_cacheableInterface $this->id = (int) $id; - $this->tag = self::loadClassFromTagName($row['src']); + $this->original_src = $row['src']; + $this->tag = self::loadClassFromTagName($row['src'], false); if ($row['src'] != $this->tag->getTagname()) { $this->on_error = true; @@ -315,6 +317,11 @@ class databox_field implements cache_cacheableInterface return $this->databox->get_connection(); } + public function get_original_source() + { + return $this->original_src; + } + /** * * @return databox @@ -527,7 +534,7 @@ class databox_field implements cache_cacheableInterface * @return \PHPExiftool\Driver\Tag * @throws Exception_Databox_metadataDescriptionNotFound */ - public static function loadClassFromTagName($tagName) + public static function loadClassFromTagName($tagName, $throwException = true) { $tagName = str_replace('/rdf:rdf/rdf:description/', '', $tagName); @@ -545,15 +552,22 @@ class databox_field implements cache_cacheableInterface $classname = '\\Alchemy\\Phrasea\\Metadata\\Tag\\' . $tagName; if ( ! class_exists($classname)) { - throw new Exception_Databox_metadataDescriptionNotFound(sprintf("tagname %s not found", $tagName)); + if ($throwException) { + throw new Exception_Databox_metadataDescriptionNotFound(sprintf("tagname %s not found", $tagName)); + } else { + $tag = new Alchemy\Phrasea\Metadata\Tag\Nosource(); + } + } else { + $tag = new $classname(); } - - $tag = new $classname(); } else { try { $tag = TagFactory::getFromRDFTagname($tagName); } catch (TagUnknown $e) { - throw new NotFoundHttpException(sprintf("Tag %s not found", $tagName), $e); + if ($throwException) { + throw new NotFoundHttpException(sprintf("Tag %s not found", $tagName), $e); + } + $tag = new Alchemy\Phrasea\Metadata\Tag\Nosource(); } }