Lorsqu’on active ou désactive un plugin, lister les erreurs de dépendances. C’est plus pratique pour comprendre pourquoi un plugin ne s’active pas.

svn/root/trunk
marcimat@rezo.net 5 years ago
parent 69cd41f42a
commit b52a1af4d1

@ -16,7 +16,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class Application extends ConsoleApplication {
const NAME = "Spip Cli";
const VERSION = "0.5.0";
const VERSION = "0.5.1";
/** @var Container */
protected $container;

@ -182,6 +182,7 @@ class PluginsActiver extends PluginsLister
$actifs = $this->getPluginsActifs(['procure' => false, 'php' => false]);
$this->io->text("Plugins actifs après action :");
$this->showPlugins($actifs);
$this->showPluginsErrors();
$this->actualiserSVP();
}
}

@ -99,6 +99,7 @@ class PluginsDesactiver extends PluginsLister {
$actifs = $this->getPluginsActifs(['procure' => false, 'php' => false]);
$this->io->text("Plugins actifs après action :");
$this->showPlugins($actifs);
$this->showPluginsErrors();
$this->actualiserSVP();
}
}

@ -223,4 +223,50 @@ class PluginsLister extends Command {
}
}
}
/**
* Retourne un tableau ['message derreur' => [liste détaillée]]
*
* @return array
*/
public function getPluginsErrors() {
$alertes = [];
if (isset($GLOBALS['meta']['message_crash_plugins'])
and $GLOBALS['meta']['message_crash_plugins']
and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
) {
$msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
$msg = _T('plugins_erreur', array('plugins' => $msg));
$msg = $this->html_entity_to_utf8($msg);
$alertes[$msg] = [];
}
if (isset($GLOBALS['meta']['plugin_erreur_activation'])) {
include_spip('inc/plugin');
$erreurs = plugin_donne_erreurs(true);
foreach ($erreurs as $plugin => $liste) {
$msg = _T('plugin_impossible_activer', array('plugin' => $plugin));
$msg = $this->html_entity_to_utf8($msg);
$alertes[$msg] = $this->html_entity_to_utf8($liste);
}
}
return $alertes;
}
public function showPluginsErrors() {
if ($erreurs = $this->getPluginsErrors()) {
$this->io->error("Des erreurs sont présentes");
foreach($erreurs as $msg => $details) {
$this->io->fail($msg);
$this->io->listing($details, 2);
}
}
}
/** Transforme les > en > */
public function html_entity_to_utf8($msg) {
if (is_array($msg)) {
return array_map([$this, 'html_entity_to_utf8'], $msg);
}
return html_entity_decode($msg, ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
}

@ -10,15 +10,41 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class SpipCliStyle extends SymfonyStyle {
public function check($message) {
$this->prependText($message, ' <fg=green></> ');
$this->prependText($message, '<fg=green></> ');
}
public function fail($message) {
return $this->prependText($message, ' <fg=red></> ');
return $this->prependText($message, '<fg=red></> ');
}
public function care($message) {
return $this->prependText($message, ' <fg=yellow;options=bold>!</> ');
return $this->prependText($message, '<fg=yellow;options=bold>!</> ');
}
/**
* Listing, qui permet dindiquer une profondeur
*
* Pratique pour des sous listes avce check, fail ou care
*
* $io->fail('Mince vous avez des erreurs');
* $io->listing(['Erreur 1', 'Erreur 2'], 2);
*
* @param array $elements
* @param int $profondeur
*/
public function listing(array $elements, $profondeur = 1)
{
if ($profondeur == 1) {
parent::listing($elements);
} else {
$format = ' ' . str_repeat(' ', $profondeur - 1) . '* %s';
$elements = array_map(function ($element) use ($format) {
return sprintf($format, $element);
}, $elements);
$this->writeln($elements);
$this->newLine();
}
}
public function prependText($message, $prepend) {

Loading…
Cancel
Save