Skip to content

Commit

Permalink
Merge pull request #22638 from totten/master-ext-prose
Browse files Browse the repository at this point in the history
Extensions - Revise prose for status check
  • Loading branch information
eileenmcnaughton authored Jan 27, 2022
2 parents d8c1f86 + 173fa86 commit 02f8f19
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions CRM/Utils/Check/Component/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,21 @@ public function checkExtensions() {
sort($keys);
$updates = $errors = $okextensions = [];

$extPrettyLabel = function($key) use ($mapper) {
// We definitely know a $key, but we may not have a $label.
// Which is too bad - because it would be nicer if $label could be the reliable start of the string.
$keyFmt = '<code>' . htmlentities($key) . '</code>';
try {
$info = $mapper->keyToInfo($key);
if ($info->label) {
return sprintf('"<em>%s</em>" (%s)', htmlentities($info->label), $keyFmt);
}
}
catch (CRM_Extension_Exception $ex) {
return "($keyFmt)";
}
};

foreach ($keys as $key) {
try {
$obj = $mapper->keyToInfo($key);
Expand All @@ -619,12 +634,18 @@ public function checkExtensions() {
$row = CRM_Admin_Page_Extensions::createExtendedInfo($obj);
switch ($row['status']) {
case CRM_Extension_Manager::STATUS_INSTALLED_MISSING:
$errors[] = ts('%1 extension (%2) is installed but missing files.', [1 => $row['label'] ?? NULL, 2 => $key]);
$errors[] = ts('%1 is installed but missing files.', [1 => $extPrettyLabel($key)]);
break;

case CRM_Extension_Manager::STATUS_INSTALLED:
if (!empty($row['requires']) && array_diff($row['requires'], $enabled)) {
$errors[] = ts('%1 extension depends on %2, which is not enabled.', [1 => $row['label'] ?? $key, 2 => implode(', ', array_diff($row['requires'], $enabled))]);
$missingRequirements = array_diff($row['requires'], $enabled);
if (!empty($row['requires']) && $missingRequirements) {
$errors[] = ts('%1 has a missing dependency on %2', [
1 => $extPrettyLabel($key),
2 => implode(', ', array_map($extPrettyLabel, $missingRequirements)),
'plural' => '%1 has missing dependencies: %2',
'count' => count($missingRequirements),
]);
}
elseif (!empty($remotes[$key]) && version_compare($row['version'], $remotes[$key]->version, '<')) {
$updates[] = $row['label'] . ': ' . $mapper->getUpgradeLink($remotes[$key], $row);
Expand Down Expand Up @@ -659,8 +680,15 @@ public function checkExtensions() {
if ($errors) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__ . 'Error',
'<ul><li>' . implode('</li><li>', $errors) . '</li></ul>',
ts('Extension Error'),
ts('There is one extension error:', [
'count' => count($errors),
'plural' => 'There are %count extension errors:',
])
. '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'
. ts('To resolve any errors, go to <a %1>Manage Extensions</a>.', [
1 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1') . '"',
]),
ts('Extension Error', ['count' => count($errors), 'plural' => 'Extension Errors']),
\Psr\Log\LogLevel::ERROR,
'fa-plug'
);
Expand Down

0 comments on commit 02f8f19

Please sign in to comment.