You are here

public function SiteAuditCheckExtensionsUnrecommended::calculateScore in Site Audit 7

Same name and namespace in other branches
  1. 8.2 Check/Extensions/Unrecommended.php \SiteAuditCheckExtensionsUnrecommended::calculateScore()

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Extensions/Unrecommended.php, line 87
Contains \SiteAudit\Check\Extensions\Unrecommended.

Class

SiteAuditCheckExtensionsUnrecommended
Class SiteAuditCheckExtensionsUnrecommended.

Code

public function calculateScore() {
  $this->registry['extensions_unrec'] = array();
  $extension_info = $this->registry['extensions'];
  uasort($extension_info, '_drush_pm_sort_extensions');
  $unrecommended_extensions = $this
    ->getExtensions();
  foreach ($extension_info as $extension) {
    $row = array();

    // Not in the list of known unrecommended modules.
    if (!array_key_exists($extension->name, $unrecommended_extensions)) {
      continue;
    }
    $in_profile = strpos($extension->filename, 'profiles/') === 0;
    $status = drush_get_extension_status($extension);

    // If in profiles and disabled, ignore.
    if ($in_profile && $status != 'enabled') {
      continue;
    }

    // Special check for APC; if PHP 5.5 and above, allow.
    if ($extension->name == 'apc' && version_compare(phpversion(), '5.5.0', '>=')) {
      continue;
    }

    // Name.
    $row[] = $extension->label;

    // Reason.
    $row[] = $unrecommended_extensions[$extension->name];
    $this->registry['extensions_unrec'][$extension->name] = $row;
  }
  if (!empty($this->registry['extensions_unrec'])) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}