3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2017
33 class CRM_Utils_Check_Component_Env
extends CRM_Utils_Check_Component
{
38 public function checkPhpVersion() {
40 $phpVersion = phpversion();
42 if (version_compare($phpVersion, CRM_Upgrade_Incremental_General
::RECOMMENDED_PHP_VER
) >= 0) {
43 $messages[] = new CRM_Utils_Check_Message(
45 ts('This system uses PHP version %1 which meets or exceeds the recommendation of %2.',
48 2 => CRM_Upgrade_Incremental_General
::RECOMMENDED_PHP_VER
,
51 \Psr\Log\LogLevel
::INFO
,
55 elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General
::MIN_RECOMMENDED_PHP_VER
) >= 0) {
56 $messages[] = new CRM_Utils_Check_Message(
58 ts('This system uses PHP version %1. This meets the minimum recommendations and you do not need to upgrade immediately, but the preferred version is %2.',
61 2 => CRM_Upgrade_Incremental_General
::RECOMMENDED_PHP_VER
,
63 ts('PHP Out-of-Date'),
64 \Psr\Log\LogLevel
::NOTICE
,
68 elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General
::MIN_INSTALL_PHP_VER
) >= 0) {
69 $messages[] = new CRM_Utils_Check_Message(
71 ts('This system uses PHP version %1. This meets the minimum requirements for CiviCRM to function but is not recommended. At least PHP version %2 is recommended; the preferrred version is %3.',
74 2 => CRM_Upgrade_Incremental_General
::MIN_RECOMMENDED_PHP_VER
,
75 3 => CRM_Upgrade_Incremental_General
::RECOMMENDED_PHP_VER
,
77 ts('PHP Out-of-Date'),
78 \Psr\Log\LogLevel
::WARNING
,
83 $messages[] = new CRM_Utils_Check_Message(
85 ts('This system uses PHP version %1. To ensure the continued operation of CiviCRM, upgrade your server now. At least PHP version %2 is recommended; the preferrred version is %3.',
88 2 => CRM_Upgrade_Incremental_General
::MIN_RECOMMENDED_PHP_VER
,
89 3 => CRM_Upgrade_Incremental_General
::RECOMMENDED_PHP_VER
,
91 ts('PHP Out-of-Date'),
92 \Psr\Log\LogLevel
::ERROR
,
103 public function checkPhpMysqli() {
106 if (!extension_loaded('mysqli')) {
107 $messages[] = new CRM_Utils_Check_Message(
109 ts('Future versions of CiviCRM may require the PHP extension "%2". To ensure that your system will be compatible, please install it in advance. For more explanation, see <a href="%1">the announcement</a>.',
111 1 => 'https://civicrm.org/blog/totten/psa-please-verify-php-extension-mysqli',
114 ts('Forward Compatibility: Enable "mysqli"'),
115 \Psr\Log\LogLevel
::WARNING
,
124 * Check that the MySQL time settings match the PHP time settings.
126 * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
128 public function checkMysqlTime() {
129 //CRM-19115 - Always set MySQL time before checking it.
130 CRM_Core_Config
::singleton()->userSystem
->setMySQLTimeZone();
133 $phpNow = date('Y-m-d H:i');
134 $sqlNow = CRM_Core_DAO
::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')");
135 if (!CRM_Utils_Time
::isEqual($phpNow, $sqlNow, 2.5 * 60)) {
136 $messages[] = new CRM_Utils_Check_Message(
138 ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.<br /><a href="%1">Read more about this warning</a>', array(
139 1 => CRM_Utils_System
::getWikiBaseURL() . 'checkMysqlTime',
143 ts('Timestamp Mismatch'),
144 \Psr\Log\LogLevel
::ERROR
,
155 public function checkDebug() {
156 $config = CRM_Core_Config
::singleton();
157 if ($config->debug
) {
158 $message = new CRM_Utils_Check_Message(
160 ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.',
161 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/debug', 'reset=1'))),
162 ts('Debug Mode Enabled'),
163 \Psr\Log\LogLevel
::WARNING
,
167 ts('Disable Debug Mode'),
168 ts('Disable debug mode now?'),
170 array('Setting', 'create', array('debug_enabled' => 0))
172 return array($message);
181 public function checkOutboundMail() {
184 $mailingInfo = Civi
::settings()->get('mailing_backend');
185 if (($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_REDIRECT_TO_DB
186 ||
(defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG
)
187 ||
$mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_DISABLED
188 ||
$mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_MOCK
)
190 $messages[] = new CRM_Utils_Check_Message(
192 ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.',
193 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))),
194 ts('Outbound Email Disabled'),
195 \Psr\Log\LogLevel
::WARNING
,
204 * Check that domain email and org name are set
207 public function checkDomainNameEmail() {
210 list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain
::getNameAndEmail(TRUE);
211 $domain = CRM_Core_BAO_Domain
::getDomain();
212 $domainName = $domain->name
;
213 $fixEmailUrl = CRM_Utils_System
::url("civicrm/admin/domain", "action=update&reset=1");
215 if (!$domainEmailAddress ||
$domainEmailAddress == 'info@EXAMPLE.ORG') {
216 if (!$domainName ||
$domainName == 'Default Domain Name') {
217 $msg = ts("Please enter your organization's <a href=\"%1\">name, primary address, and default FROM Email Address</a> (for system-generated emails).",
218 array(1 => $fixEmailUrl));
221 $msg = ts('Please enter a <a href="%1">default FROM Email Address</a> (for system-generated emails).',
222 array(1 => $fixEmailUrl));
225 elseif (!$domainName ||
$domainName == 'Default Domain Name') {
226 $msg = ts("Please enter your organization's <a href=\"%1\">name and primary address</a>.",
227 array(1 => $fixEmailUrl));
231 $messages[] = new CRM_Utils_Check_Message(
234 ts('Complete Setup'),
235 \Psr\Log\LogLevel
::WARNING
,
244 * Checks if a default bounce handling mailbox is set up
247 public function checkDefaultMailbox() {
249 $config = CRM_Core_Config
::singleton();
251 if (in_array('CiviMail', $config->enableComponents
) &&
252 CRM_Core_BAO_MailSettings
::defaultDomain() == "EXAMPLE.ORG"
254 $message = new CRM_Utils_Check_Message(
256 ts('Please configure a <a href="%1">default mailbox</a> for CiviMail.',
257 array(1 => CRM_Utils_System
::url('civicrm/admin/mailSettings', "reset=1"))),
258 ts('Configure Default Mailbox'),
259 \Psr\Log\LogLevel
::WARNING
,
262 $docUrl = 'target="_blank" href="' . CRM_Utils_System
::docURL(array('page' => 'user/advanced-configuration/email-system-configuration/', 'URLonly' => TRUE)) . '""';
264 ts('A default mailbox must be configured for email bounce processing.') . '<br />' .
265 ts("Learn more in the <a %1>online documentation</a>.", array(1 => $docUrl))
267 $messages[] = $message;
274 * Checks if cron has run in a reasonable amount of time
277 public function checkLastCron() {
280 $statusPreference = new CRM_Core_DAO_StatusPreference();
281 $statusPreference->domain_id
= CRM_Core_Config
::domainID();
282 $statusPreference->name
= 'checkLastCron';
284 if ($statusPreference->find(TRUE) && !empty($statusPreference->check_info
)) {
285 $lastCron = $statusPreference->check_info
;
286 $msg = ts('Last cron run at %1.', array(1 => CRM_Utils_Date
::customFormat(date('c', $lastCron))));
290 $msg = ts('No cron runs have been recorded.');
293 if ($lastCron > gmdate('U') - 3600) {
294 $messages[] = new CRM_Utils_Check_Message(
297 ts('Cron Running OK'),
298 \Psr\Log\LogLevel
::INFO
,
303 $message = new CRM_Utils_Check_Message(
306 ts('Cron Not Running'),
307 ($lastCron > gmdate('U') - 86400) ? \Psr\Log\LogLevel
::WARNING
: \Psr\Log\LogLevel
::ERROR
,
310 $docUrl = 'target="_blank" href="' . CRM_Utils_System
::docURL(array('resource' => 'wiki', 'page' => 'Managing Scheduled Jobs', 'URLonly' => TRUE)) . '""';
312 ts('Configuring cron on your server is necessary for running scheduled jobs such as sending mail and scheduled reminders.') . '<br />' .
313 ts("Learn more in the <a %1>online documentation</a>.", array(1 => $docUrl))
315 $messages[] = $message;
322 * Recommend that sites use path-variables for their directories and URLs.
325 public function checkUrlVariables() {
327 $hasOldStyle = FALSE;
328 $settingNames = array(
329 'userFrameworkResourceURL',
335 foreach ($settingNames as $settingName) {
336 $settingValue = Civi
::settings()->get($settingName);
337 if (!empty($settingValue) && $settingValue{0} != '[') {
344 $message = new CRM_Utils_Check_Message(
346 ts('<a href="%1">Resource URLs</a> may use absolute paths, relative paths, or variables. Absolute paths are more difficult to maintain. To maximize portability, consider using a variable in each URL (eg "<tt>[cms.root]</tt>" or "<tt>[civicrm.files]</tt>").',
347 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/url', "reset=1"))),
348 ts('Resource URLs: Make them portable'),
349 \Psr\Log\LogLevel
::NOTICE
,
352 $messages[] = $message;
359 * Recommend that sites use path-variables for their directories and URLs.
362 public function checkDirVariables() {
364 $hasOldStyle = FALSE;
365 $settingNames = array(
368 'customFileUploadDir',
374 foreach ($settingNames as $settingName) {
375 $settingValue = Civi
::settings()->get($settingName);
376 if (!empty($settingValue) && $settingValue{0} != '[') {
383 $message = new CRM_Utils_Check_Message(
385 ts('<a href="%1">Directories</a> may use absolute paths, relative paths, or variables. Absolute paths are more difficult to maintain. To maximize portability, consider using a variable in each directory (eg "<tt>[cms.root]</tt>" or "<tt>[civicrm.files]</tt>").',
386 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/path', "reset=1"))),
387 ts('Directory Paths: Make them portable'),
388 \Psr\Log\LogLevel
::NOTICE
,
391 $messages[] = $message;
398 * Check that important directories are writable.
401 * Any CRM_Utils_Check_Message instances that need to be generated.
403 public function checkDirsWritable() {
404 $notWritable = array();
406 $config = CRM_Core_Config
::singleton();
407 $directories = array(
408 'uploadDir' => ts('Temporary Files Directory'),
409 'imageUploadDir' => ts('Images Directory'),
410 'customFileUploadDir' => ts('Custom Files Directory'),
411 'extensionsDir' => ts('CiviCRM Extensions Directory'),
414 foreach ($directories as $directory => $label) {
415 $file = CRM_Utils_File
::createFakeFile($config->$directory);
417 if ($file === FALSE) {
418 $notWritable[] = "$label ({$config->$directory})";
421 $dirWithSlash = CRM_Utils_File
::addTrailingSlash($config->$directory);
422 unlink($dirWithSlash . $file);
428 if (!empty($notWritable)) {
429 $messages[] = new CRM_Utils_Check_Message(
431 ts('The %1 is not writable. Please check your file permissions.', array(
432 1 => implode(', ', $notWritable),
433 'count' => count($notWritable),
434 'plural' => 'The following directories are not writable: %1. Please check your file permissions.',
436 ts('Directory not writable', array(
437 'count' => count($notWritable),
438 'plural' => 'Directories not writable',
440 \Psr\Log\LogLevel
::ERROR
,
449 * Checks if new versions are available
452 public function checkVersion() {
455 $vc = new CRM_Utils_VersionCheck();
458 catch (Exception
$e) {
459 $messages[] = new CRM_Utils_Check_Message(
461 ts('Directory %1 is not writable. Please change your file permissions.',
462 array(1 => dirname($vc->cacheFile
))),
463 ts('Directory not writable'),
464 \Psr\Log\LogLevel
::ERROR
,
470 // Show a notice if the version_check job is disabled
471 if (empty($vc->cronJob
['is_active'])) {
472 $args = empty($vc->cronJob
['id']) ?
array('reset' => 1) : array('reset' => 1, 'action' => 'update', 'id' => $vc->cronJob
['id']);
473 $messages[] = new CRM_Utils_Check_Message(
474 'checkVersionDisabled',
475 ts('The check for new versions of CiviCRM has been disabled. <a %1>Re-enable the scheduled job</a> to receive important security update notifications.', array(1 => 'href="' . CRM_Utils_System
::url('civicrm/admin/job', $args) . '"')),
476 ts('Update Check Disabled'),
477 \Psr\Log\LogLevel
::NOTICE
,
482 if ($vc->isInfoAvailable
) {
483 $newerVersion = $vc->isNewerVersionAvailable();
484 if ($newerVersion['version']) {
486 1 => $newerVersion['version'],
487 2 => $vc->localVersion
,
489 // LTS = long-term support version
490 if ($newerVersion['status'] == 'lts') {
491 $vInfo[1] .= ' ' . ts('(long-term support)');
494 if ($newerVersion['upgrade'] == 'security') {
496 $severity = \Psr\Log\LogLevel
::CRITICAL
;
497 $title = ts('CiviCRM Security Update Required');
498 $message = ts('New security release %1 is available. The site is currently running %2.', $vInfo);
500 elseif ($newerVersion['status'] == 'eol') {
502 $severity = \Psr\Log\LogLevel
::WARNING
;
503 $title = ts('CiviCRM Update Needed');
504 $message = ts('New version %1 is available. The site is currently running %2, which has reached its end of life.', $vInfo);
507 // For most new versions, just make them notice
508 $severity = \Psr\Log\LogLevel
::NOTICE
;
509 $title = ts('CiviCRM Update Available');
510 $message = ts('New version %1 is available. The site is currently running %2.', $vInfo);
513 elseif (!empty($vc->cronJob
['is_active'])) {
514 $vNum = $vc->localVersion
;
515 // LTS = long-term support version
516 if ($newerVersion['status'] == 'lts') {
517 $vNum .= ' ' . ts('(long-term support)');
520 $severity = \Psr\Log\LogLevel
::INFO
;
521 $title = ts('CiviCRM Up-to-Date');
522 $message = ts('CiviCRM version %1 is up-to-date.', array(1 => $vNum));
525 if (!empty($message)) {
526 $messages[] = new CRM_Utils_Check_Message(
540 * Checks if extensions are set up properly
543 public function checkExtensions() {
545 $extensionSystem = CRM_Extension_System
::singleton();
546 $mapper = $extensionSystem->getMapper();
547 $manager = $extensionSystem->getManager();
549 if ($extensionSystem->getDefaultContainer()) {
550 $basedir = $extensionSystem->getDefaultContainer()->baseDir
;
553 if (empty($basedir)) {
554 // no extension directory
555 $messages[] = new CRM_Utils_Check_Message(
557 ts('Your extensions directory is not set. Click <a href="%1">here</a> to set the extensions directory.',
558 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/path', 'reset=1'))),
559 ts('Directory not writable'),
560 \Psr\Log\LogLevel
::NOTICE
,
566 if (!is_dir($basedir)) {
567 $messages[] = new CRM_Utils_Check_Message(
569 ts('Your extensions directory path points to %1, which is not a directory. Please check your file system.',
570 array(1 => $basedir)),
571 ts('Extensions directory incorrect'),
572 \Psr\Log\LogLevel
::ERROR
,
577 elseif (!is_writable($basedir)) {
578 $messages[] = new CRM_Utils_Check_Message(
580 ts('Directory %1 is not writable. Please change your file permissions.',
581 array(1 => $basedir)),
582 ts('Directory not writable'),
583 \Psr\Log\LogLevel
::ERROR
,
589 if (empty($extensionSystem->getDefaultContainer()->baseUrl
)) {
590 $messages[] = new CRM_Utils_Check_Message(
592 ts('The extensions URL is not properly set. Please go to the <a href="%1">URL setting page</a> and correct it.',
593 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/url', 'reset=1'))),
594 ts('Extensions url missing'),
595 \Psr\Log\LogLevel
::ERROR
,
601 if (!$extensionSystem->getBrowser()->isEnabled()) {
602 $messages[] = new CRM_Utils_Check_Message(
604 ts('Not checking remote URL for extensions since ext_repo_url is set to false.'),
605 ts('Extensions check disabled'),
606 \Psr\Log\LogLevel
::NOTICE
,
613 $remotes = $extensionSystem->getBrowser()->getExtensions();
615 catch (CRM_Extension_Exception
$e) {
616 $messages[] = new CRM_Utils_Check_Message(
619 ts('Extension download error'),
620 \Psr\Log\LogLevel
::ERROR
,
627 // CRM-13141 There may not be any compatible extensions available for the requested CiviCRM version + CMS. If so, $extdir is empty so just return a notice.
628 $messages[] = new CRM_Utils_Check_Message(
630 ts('There are currently no extensions on the CiviCRM public extension directory which are compatible with version %1. If you want to install an extension which is not marked as compatible, you may be able to <a %2>download and install extensions manually</a> (depending on access to your web server).', array(
631 1 => CRM_Utils_System
::majorVersion(),
632 2 => 'href="http://wiki.civicrm.org/confluence/display/CRMDOC/Extensions"',
634 ts('No Extensions Available for this Version'),
635 \Psr\Log\LogLevel
::NOTICE
,
641 $keys = array_keys($manager->getStatuses());
643 $updates = $errors = $okextensions = array();
645 foreach ($keys as $key) {
647 $obj = $mapper->keyToInfo($key);
649 catch (CRM_Extension_Exception
$ex) {
650 $errors[] = ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key));
653 $row = CRM_Admin_Page_Extensions
::createExtendedInfo($obj);
654 switch ($row['status']) {
655 case CRM_Extension_Manager
::STATUS_INSTALLED_MISSING
:
656 $errors[] = ts('%1 extension (%2) is installed but missing files.', array(1 => CRM_Utils_Array
::value('label', $row), 2 => $key));
659 case CRM_Extension_Manager
::STATUS_INSTALLED
:
660 if (!empty($remotes[$key]) && version_compare($row['version'], $remotes[$key]->version
, '<')) {
661 $updates[] = ts('%1 (%2) version %3 is installed. <a %4>Upgrade to version %5</a>.', array(
662 1 => CRM_Utils_Array
::value('label', $row),
664 3 => $row['version'],
665 4 => 'href="' . CRM_Utils_System
::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"',
666 5 => $remotes[$key]->version
,
670 if (empty($row['label'])) {
671 $okextensions[] = $key;
674 $okextensions[] = ts('%1 (%2) version %3', array(
677 3 => $row['version'],
685 if (!$okextensions && !$updates && !$errors) {
686 $messages[] = new CRM_Utils_Check_Message(
688 ts('No extensions installed. <a %1>Browse available extensions</a>.', array(
689 1 => 'href="' . CRM_Utils_System
::url('civicrm/admin/extensions', 'reset=1') . '"',
692 \Psr\Log\LogLevel
::INFO
,
698 $messages[] = new CRM_Utils_Check_Message(
700 '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>',
701 ts('Extension Error'),
702 \Psr\Log\LogLevel
::ERROR
,
708 $messages[] = new CRM_Utils_Check_Message(
710 '<ul><li>' . implode('</li><li>', $updates) . '</li></ul>',
711 ts('Extension Update Available', array('plural' => '%count Extension Updates Available', 'count' => count($updates))),
712 \Psr\Log\LogLevel
::WARNING
,
718 if ($updates ||
$errors) {
719 $message = ts('1 extension is up-to-date:', array('plural' => '%count extensions are up-to-date:', 'count' => count($okextensions)));
722 $message = ts('All extensions are up-to-date:');
724 $messages[] = new CRM_Utils_Check_Message(
726 $message . '<ul><li>' . implode('</li><li>', $okextensions) . '</li></ul>',
728 \Psr\Log\LogLevel
::INFO
,
738 * Checks if there are pending extension upgrades.
742 public function checkExtensionUpgrades() {
743 if (CRM_Extension_Upgrades
::hasPending()) {
744 $message = new CRM_Utils_Check_Message(
746 ts('Extension upgrades should be run as soon as possible.'),
747 ts('Extension Upgrades Pending'),
748 \Psr\Log\LogLevel
::ERROR
,
753 ts('Run extension upgrades now?'),
755 array('path' => 'civicrm/admin/extensions/upgrade', 'query' => array('reset' => 1, 'destination' => CRM_Utils_System
::url('civicrm/a/#/status')))
757 return array($message);
763 * Checks if CiviCRM database version is up-to-date
766 public function checkDbVersion() {
768 $dbVersion = CRM_Core_BAO_Domain
::version();
769 $upgradeUrl = CRM_Utils_System
::url("civicrm/upgrade", "reset=1");
773 $messages[] = new CRM_Utils_Check_Message(
775 ts('Version information found to be missing in database. You will need to determine the correct version corresponding to your current database state.'),
776 ts('Database Version Missing'),
777 \Psr\Log\LogLevel
::ERROR
,
781 elseif (!CRM_Utils_System
::isVersionFormatValid($dbVersion)) {
782 $messages[] = new CRM_Utils_Check_Message(
784 ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'),
785 ts('Database Version Invalid'),
786 \Psr\Log\LogLevel
::ERROR
,
790 elseif (stripos($dbVersion, 'upgrade')) {
791 // if db.ver indicates a partially upgraded db
792 $messages[] = new CRM_Utils_Check_Message(
794 ts('Database check failed - the database looks to have been partially upgraded. You must reload the database with the backup and try the <a href=\'%1\'>upgrade process</a> again.', array(1 => $upgradeUrl)),
795 ts('Database Partially Upgraded'),
796 \Psr\Log\LogLevel
::ALERT
,
801 $codeVersion = CRM_Utils_System
::version();
803 // if db.ver < code.ver, time to upgrade
804 if (version_compare($dbVersion, $codeVersion) < 0) {
805 $messages[] = new CRM_Utils_Check_Message(
807 ts('New codebase version detected. You must visit <a href=\'%1\'>upgrade screen</a> to upgrade the database.', array(1 => $upgradeUrl)),
808 ts('Database Upgrade Required'),
809 \Psr\Log\LogLevel
::ALERT
,
814 // if db.ver > code.ver, sth really wrong
815 if (version_compare($dbVersion, $codeVersion) > 0) {
816 $messages[] = new CRM_Utils_Check_Message(
818 ts('Your database is marked with an unexpected version number: %1. The v%2 codebase may not be compatible with your database state.
819 You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase
820 you were using until you resolve this problem.<br/>OR if this is a manual install from git, you might want to fix civicrm-version.php file.',
821 array(1 => $dbVersion, 2 => $codeVersion)
823 ts('Database In Unexpected Version'),
824 \Psr\Log\LogLevel
::ERROR
,
834 * ensure that all CiviCRM tables are InnoDB
837 public function checkDbEngine() {
840 if (CRM_Core_DAO
::isDBMyISAM(150)) {
841 $messages[] = new CRM_Utils_Check_Message(
843 ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues.'),
844 ts('MyISAM Database Engine'),
845 \Psr\Log\LogLevel
::ERROR
,
853 * Check for required mbstring extension
856 public function checkMbstring() {
859 if (!function_exists('mb_substr')) {
860 $messages[] = new CRM_Utils_Check_Message(
862 ts('The PHP Multibyte String extension is needed for CiviCRM to correctly handle user input among other functionality. Ask your system administrator to install it.'),
863 ts('Missing mbstring Extension'),
864 \Psr\Log\LogLevel
::WARNING
,
872 * Check if environment is Production.
875 public function checkEnvironment() {
878 $environment = CRM_Core_Config
::environment();
879 if ($environment != 'Production') {
880 $messages[] = new CRM_Utils_Check_Message(
882 ts('The environment of this CiviCRM instance is set to \'%1\'. Certain functionality like scheduled jobs has been disabled.', array(1 => $environment)),
883 ts('Non-Production Environment'),
884 \Psr\Log\LogLevel
::ALERT
,
892 * Check that the resource URL points to the correct location.
895 public function checkResourceUrl() {
897 // Skip when run during unit tests, you can't check without a CMS.
898 if (CRM_Core_Config
::singleton()->userFramework
== 'UnitTests') {
901 // CRM-21629 Set User Agent to avoid being blocked by filters
902 stream_context_set_default(array(
903 'http' => array('user_agent' => 'CiviCRM'),
906 // Does arrow.png exist where we expect it?
907 $arrowUrl = CRM_Core_Config
::singleton()->userFrameworkResourceURL
. 'packages/jquery/css/images/arrow.png';
908 $headers = get_headers($arrowUrl);
909 $fileExists = stripos($headers[0], "200 OK") ?
1 : 0;
911 $messages[] = new CRM_Utils_Check_Message(
913 ts('The Resource URL is not set correctly. Please set the <a href="%1">CiviCRM Resource URL</a>.',
914 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/url', 'reset=1'))),
915 ts('Incorrect Resource URL'),
916 \Psr\Log\LogLevel
::ERROR
,