From: Tim Otten Date: Wed, 12 Jul 2017 02:51:41 +0000 (-0700) Subject: CRM-20600 - Upgrader - Display warning if asset-caching is likely to fail X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=17511f38d9ba4dfa0eb84d1c6e0031909d03e569;p=civicrm-core.git CRM-20600 - Upgrader - Display warning if asset-caching is likely to fail After releasing v4.7.21, there were several inquiries about sites in which Angular pages failed to load. In cases diagnosed so far, this has been a result of inconsistent configurations or overzealous HTTP restrictions applied to the `imageUploadDir`. Ordinarily, we would address this kind of thing with a status check. Unfortunately, the problem breaks that "Status" page... so we have to display a bit sooner. --- diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index a741cee00b..a549ee5acd 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -62,6 +62,16 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base if ($rev == '4.7.13') { $preUpgradeMessage .= '

' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '

'; } + if ($rev == '4.7.22') { + // Based on support inquiries for 4.7.21, show message during 4.7.22. + // For affected users, this issue prevents loading the regular status screen. + if (!$this->checkImageUploadDir()) { + $preUpgradeMessage .= '

' . ts('There appears to be an inconsistency in the configuration of "Image Upload URL" and "Image Upload Directory".') . '

' + . '

' + . ts('Further advice will be displayed at the end of the upgrade.') + . '

'; + } + } } /** @@ -122,6 +132,26 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base $postUpgradeMessage .= '

civicrm_sms_provider ' . ts('has now had a domain id column added. As there is more than 1 domains in this install you need to manually set the domain id for the providers in this install') . '

'; } } + if ($rev == '4.7.22') { + // Based on support inquiries for 4.7.21, show message during 4.7.22. + // For affected users, this issue prevents loading the regular status screen. + if (!$this->checkImageUploadDir()) { + $config = CRM_Core_Config::singleton(); + $postUpgradeMessage .= + '

' . ts('Warning') . '

' + . '

' . ts('There appears to be an inconsistency in the configuration of "Image Upload URL" and "Image Upload Directory".') . '

' + . sprintf("", htmlentities($config->imageUploadDir), htmlentities($config->imageUploadURL)) + . '

' + . ts('You may need to check that:

') + . '

' + . '

' + . ts('(Note: Although files should be readable, it is best if they are not listable or browseable.)') + . '

' + . '

' + . ts('If this remains unresolved, then some important screens may fail to load.') + . '

'; + } + } if ($rev == '4.7.23') { $postUpgradeMessage .= '

' . ts('Default version of the following System Workflow Message Templates have been modified: If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).'); } @@ -1158,4 +1188,13 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } + /** + * @return bool + */ + protected function checkImageUploadDir() { + $config = CRM_Core_Config::singleton(); + $check = new CRM_Utils_Check_Component_Security(); + return $config->imageUploadDir && $config->imageUploadURL && $check->isDirAccessible($config->imageUploadDir, $config->imageUploadURL); + } + }