Fix bug in extracting required plugins from composer.json that led to spurious error in log (#7364)

pull/7370/head
Aleksander Machniak 4 years ago
parent 12d4705935
commit c39081b6a1

@ -17,6 +17,7 @@ CHANGELOG Roundcube Webmail
- Templates: Add support for nested if conditions (#6818)
- Templates: Make [space][slash] ending of condition objects optional (#6954)
- Fix so messages in threads with no root aren't displayed separately (#4999)
- Fix bug in extracting required plugins from composer.json that led to spurious error in log (#7364)
RELEASE 1.4.4
-------------

@ -245,7 +245,7 @@ class rcube_plugin_api
/**
* Get information about a specific plugin.
* This is either provided my a plugin's info() method or extracted from a package.xml or a composer.json file
* This is either provided by a plugin's info() method or extracted from a package.xml or a composer.json file
*
* @param string Plugin name
* @return array Meta information about a plugin or False if plugin was not found
@ -316,17 +316,29 @@ class rcube_plugin_api
if (!$info) {
$composer = INSTALL_PATH . "/plugins/$plugin_name/composer.json";
if (is_readable($composer) && ($json = @json_decode(file_get_contents($composer), true))) {
// Build list of plugins required
$require = array();
foreach (array_keys((array) $json['require']) as $dname) {
if (!preg_match('|^([^/]+)/([a-zA-Z0-9_-]+)$|', $dname, $m)) {
continue;
}
$vendor = $m[1];
$name = $m[2];
if ($name != 'plugin-installer' && $vendor != 'pear' && $vendor != 'pear-pear') {
$dpath = unslashify($dir->path) . "/$name/$name.php";
if (is_readable($dpath)) {
$require[] = $name;
}
}
}
list($info['vendor'], $info['name']) = explode('/', $json['name']);
$info['version'] = $json['version'];
$info['license'] = $json['license'];
$info['uri'] = $json['homepage'];
$info['require'] = array_filter(array_keys((array)$json['require']), function($pname) {
if (strpos($pname, '/') == false) {
return false;
}
list($vendor, $name) = explode('/', $pname);
return !($name == 'plugin-installer' || $vendor == 'pear-pear');
});
$info['require'] = $require;
}
// read local composer.lock file (once)

Loading…
Cancel
Save