/** * Implements \SiteAudit\Check\Abstract\calculateScore(). */ public function calculateScore() { $this->registry['extensions_disabled'] = array(); foreach ($this->registry['extensions'] as $extension) { if ($extension->type == 'module' && drush_get_extension_status($extension) == 'disabled') { $this->registry['extensions_disabled'][] = $extension->name; } } if (!empty($this->registry['extensions_disabled'])) { return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN; } return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS; }
/** * Implements \SiteAudit\Check\Abstract\calculateScore(). */ public function calculateScore() { $this->registry['extension_count'] = 0; $this->registry['extensions'] = drush_get_extensions(FALSE); foreach ($this->registry['extensions'] as $extension) { $status = drush_get_extension_status($extension); if (!in_array($status, array('enabled'))) { continue; } $this->registry['extension_count']++; } if ($this->registry['extension_count'] >= 150) { return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN; } return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS; }
<?php # config: name of the versions file $fileName = DRUPAL_ROOT . "/versions.json"; # get all module informations $modules = drush_get_extensions(false); # get all versions from enabled modules $versions = array(); foreach ($modules as $name => $module) { if ('enabled' === drush_get_extension_status($module)) { $versions[$name] = $module->info['version']; } } # write version to disc file_put_contents($fileName, json_encode($versions));
/** * Implements \SiteAudit\Check\Abstract\calculateScore(). */ public function calculateScore() { $this->registry['extensions_dev'] = array(); $extension_info = $this->registry['extensions']; uasort($extension_info, '_drush_pm_sort_extensions'); $dev_extensions = $this->getExtensions(); foreach ($extension_info as $key => $extension) { $row = array(); $status = drush_get_extension_status($extension); // Only enabled extensions. if (!in_array($status, array('enabled'))) { unset($extension_info[$key]); continue; } // Not in the list of known development modules. if (!array_key_exists($extension->name, $dev_extensions)) { unset($extension_info[$key]); continue; } // Do not report modules that are dependencies of other modules, such // as field_ui in Drupal Commerce. if (isset($extension->required_by) && !empty($extension->required_by)) { unset($extension_info[$key]); continue; } // Name. $row[] = $extension->label; // Reason. $row[] = $dev_extensions[$extension->name]; $this->registry['extensions_dev'][$extension->name] = $row; } if (!empty($this->registry['extensions_dev'])) { if (site_audit_env_is_dev()) { return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO; } return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN; } return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS; }
/** * Implements \SiteAudit\Check\Abstract\calculateScore(). */ 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; } // Exceptions for backup_migrate in installation profiles on Pantheon. if ($extension->name == 'backup_migrate' && drush_get_option('vendor') == 'pantheon') { $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; } // If enabled in dev, ignore. if ($status == 'enabled' && site_audit_env_is_dev()) { continue; } // If in profiles and enabled in non-dev, be more specific. if ($in_profile && $status == 'enabled' && !site_audit_env_is_dev()) { $this->registry['extensions_unrec'][$extension->name] = array($extension->label, dt('backup_migrate should only be on Pantheon in live environments used to facilitate migrations; disable when complete and this check will pass.')); 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; }