Suite de 75573f6 : il existait un code qui présentait les erreurs correctement dans plugins:activer. On le partage.

pull/19/head
Matthieu Marcillaud 3 years ago
parent 75573f64d0
commit d5e7583c56

@ -3,6 +3,7 @@
namespace Spip\Cli\Command;
use Spip\Cli\Console\Command;
use Spip\Cli\Plugins\ErrorsTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@ -10,6 +11,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class PluginsLister extends Command {
use ErrorsTrait;
protected function configure() {
$this->setName("plugins:lister")
->setDescription("Liste les plugins du site.")
@ -254,49 +257,4 @@ 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');
}
}

@ -2,10 +2,14 @@
namespace Spip\Cli\Command;
use Spip\Cli\Plugins\ErrorsTrait;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'CoreMajBdd.php';
class PluginsMajBdd extends CoreMajBdd
{
use ErrorsTrait;
protected function configure() {
$this
->setName('plugins:maj:bdd')
@ -34,12 +38,7 @@ class PluginsMajBdd extends CoreMajBdd
$this->produireCacheCouteauKiss();
// on purge les eventuelles erreurs d'activation
$erreurs = plugin_donne_erreurs(true);
if ($erreurs and is_array($erreurs)) {
$erreurs_plat = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($erreurs));
$erreurs = array_map(function($e) { return "* " . trim($e); }, iterator_to_array($erreurs_plat));
$this->io->error($erreurs);
}
$this->showPluginsErrors();
if (trim($content)) {
$this->io->text("Fin mise à jour des plugins");

Loading…
Cancel
Save