Removing PHPCI's attempt to install plugins via composer automatically, as it usually doesn't work. See #395

This commit is contained in:
Dan Cryer 2014-05-12 18:26:44 +01:00
parent 5ba629e874
commit 9d58add843
2 changed files with 3 additions and 43 deletions

View file

@ -37,20 +37,6 @@ class PluginController extends \PHPCI\Controller
protected $canInstall;
protected $composerPath;
public function init()
{
parent::init();
$this->canInstall = function_exists('shell_exec');
if ($this->canInstall) {
$this->composerPath = $this->findBinary(array('composer', 'composer.phar'));
if (!$this->composerPath) {
$this->canInstall = false;
}
}
}
public function index()
{
if (!$_SESSION['user']->getIsAdmin()) {
@ -58,7 +44,6 @@ class PluginController extends \PHPCI\Controller
}
$this->view->canWrite = is_writable(APPLICATION_PATH . 'composer.json');
$this->view->canInstall = $this->canInstall;
$this->view->required = $this->required;
$json = $this->getComposerJson();
@ -93,13 +78,6 @@ class PluginController extends \PHPCI\Controller
unset($json['require'][$package]);
$this->setComposerJson($json);
if ($this->canInstall) {
$home = 'COMPOSER_HOME='.APPLICATION_PATH . ' ';
$action = ' update --working-dir=' . APPLICATION_PATH;
$toLog = APPLICATION_PATH . '/phpci_composer_remove.log 2>&1 &';
shell_exec($home . $this->composerPath . $action . ' > /' . $toLog);
}
header('Location: ' . PHPCI_URL . 'plugin?r=' . $package);
die;
}
@ -121,16 +99,6 @@ class PluginController extends \PHPCI\Controller
$json['require'][$package] = $version;
$this->setComposerJson($json);
if ($this->canInstall) {
$home = 'COMPOSER_HOME='.APPLICATION_PATH . ' ';
$action = ' update --working-dir=' . APPLICATION_PATH;
$toLog = ' > /' . APPLICATION_PATH . '/phpci_composer_install.log 2>&1 &';
shell_exec($home . $this->composerPath . $action . $toLog);
header('Location: ' . PHPCI_URL . 'plugin?i=' . $package);
die;
}
header('Location: ' . PHPCI_URL . 'plugin?w=' . $package);
die;
}
@ -179,7 +147,7 @@ class PluginController extends \PHPCI\Controller
{
$searchQuery = $this->getParam('q', '');
$http = new \b8\HttpClient();
$http->setHeaders(array('User-Agent: PHPCI/1.0 (+http://www.phptesting.org)'));
$http->setHeaders(array('User-Agent: PHPCI/1.0 (+https://www.phptesting.org)'));
$res = $http->get('https://packagist.org/search.json', array('q' => $searchQuery));
die(json_encode($res['body']));
@ -189,7 +157,7 @@ class PluginController extends \PHPCI\Controller
{
$name = $this->getParam('p', '');
$http = new \b8\HttpClient();
$http->setHeaders(array('User-Agent: PHPCI/1.0 (+http://www.phptesting.org)'));
$http->setHeaders(array('User-Agent: PHPCI/1.0 (+https://www.phptesting.org)'));
$res = $http->get('https://packagist.org/packages/'.$name.'.json');
die(json_encode($res['body']));

View file

@ -1,8 +1,4 @@
<h1 id="title">Packages and Provided Plugins</h1>
<?php if (!$canInstall): ?>
<p class="alert alert-danger">PHPCI cannot automatically install/remove plugins for you, as either the <strong>shell_exec()</strong>
function is disabled or PHPCI could not find Composer. PHPCI will update composer.json for you, but you will need to run Composer manually to make the changes.</p>
<?php endif; ?>
<?php if (!$canWrite): ?>
<p class="alert alert-danger">PHPCI cannot update composer.json for you as it is not writable.</p>
@ -12,12 +8,8 @@
<p class="alert alert-success"><strong><?php echo $_GET['r']; ?></strong> has been removed.</p>
<?php endif; ?>
<?php if (isset($_GET['i'])): ?>
<p class="alert alert-success"><strong><?php echo $_GET['i']; ?></strong> has been installed.</p>
<?php endif; ?>
<?php if (isset($_GET['w'])): ?>
<p class="alert alert-success"><strong><?php echo $_GET['w']; ?></strong> has been added to composer.json and will be installed next time you run composer update.</p>
<p class="alert alert-success"><strong><?php echo $_GET['w']; ?></strong> has been added to composer.json for you and will be installed next time you run composer update.</p>
<?php endif; ?>
<div class="box">