Skip to content

Commit

Permalink
[php8-compat] fix Upgrade call back issues by making functions static…
Browse files Browse the repository at this point in the history
… and also fixing an issue with an array key not existing when checking obsolete extensions
  • Loading branch information
seamuslee001 committed Jun 4, 2021
1 parent c1f3628 commit adcd515
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
65 changes: 35 additions & 30 deletions CRM/Extension/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,36 +382,41 @@ public function disable($keys) {
$this->addProcess($keys, 'disable');

foreach ($keys as $key) {
switch ($origStatuses[$key]) {
case self::STATUS_INSTALLED:
$this->addProcess([$key], 'disabling');
// throws Exception
list ($info, $typeManager) = $this->_getInfoTypeHandler($key);
$typeManager->onPreDisable($info);
$this->_setExtensionActive($info, 0);
$typeManager->onPostDisable($info);
$this->popProcess([$key]);
break;

case self::STATUS_INSTALLED_MISSING:
// throws Exception
list ($info, $typeManager) = $this->_getMissingInfoTypeHandler($key);
$typeManager->onPreDisable($info);
$this->_setExtensionActive($info, 0);
$typeManager->onPostDisable($info);
break;

case self::STATUS_DISABLED:
case self::STATUS_DISABLED_MISSING:
case self::STATUS_UNINSTALLED:
// ok, nothing to do
// Remove the 'disable' process as we're not doing that.
$this->popProcess([$key]);
break;

case self::STATUS_UNKNOWN:
default:
throw new CRM_Extension_Exception("Cannot disable unknown extension: $key");
if (isset($origStatuses[$key])) {
switch ($origStatuses[$key]) {
case self::STATUS_INSTALLED:
$this->addProcess([$key], 'disabling');
// throws Exception
list ($info, $typeManager) = $this->_getInfoTypeHandler($key);
$typeManager->onPreDisable($info);
$this->_setExtensionActive($info, 0);
$typeManager->onPostDisable($info);
$this->popProcess([$key]);
break;

case self::STATUS_INSTALLED_MISSING:
// throws Exception
list ($info, $typeManager) = $this->_getMissingInfoTypeHandler($key);
$typeManager->onPreDisable($info);
$this->_setExtensionActive($info, 0);
$typeManager->onPostDisable($info);
break;

case self::STATUS_DISABLED:
case self::STATUS_DISABLED_MISSING:
case self::STATUS_UNINSTALLED:
// ok, nothing to do
// Remove the 'disable' process as we're not doing that.
$this->popProcess([$key]);
break;

case self::STATUS_UNKNOWN:
default:
throw new CRM_Extension_Exception("Cannot disable unknown extension: $key");
}
}
else {
throw new CRM_Extension_Exception("Cannot disable unknown extension: $key");
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static function updateContributeSettings($ctx) {
*
* @return bool
*/
public function updateSmartGroups($ctx, $actions) {
public static function updateSmartGroups($ctx, $actions) {
$groupUpdateObject = new CRM_Upgrade_Incremental_SmartGroups();
$groupUpdateObject->updateGroups($actions);
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/php/FiveSeventeen.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function upgrade_5_17_1($rev) {
/**
* Update safe file types.
*/
public function updateFileTypes() {
public static function updateFileTypes() {
CRM_Core_BAO_OptionValue::ensureOptionValueExists([
'option_group_id' => 'safe_file_extension',
'label' => 'pptx',
Expand Down
4 changes: 2 additions & 2 deletions CRM/Upgrade/Incremental/php/FiveTwentySeven.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function upgrade_5_27_alpha1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
}

public function priceFieldValueLabelRequired($ctx) {
public static function priceFieldValueLabelRequired($ctx) {
$locales = CRM_Core_I18n::getMultilingual();
if ($locales) {
foreach ($locales as $locale) {
Expand All @@ -86,7 +86,7 @@ public function priceFieldValueLabelRequired($ctx) {
return TRUE;
}

public function nameMembershipTypeRequired($ctx) {
public static function nameMembershipTypeRequired($ctx) {
$locales = CRM_Core_I18n::getMultilingual();
if ($locales) {
foreach ($locales as $locale) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/php/FiveTwentySix.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function upgrade_5_26_alpha1($rev) {
/**
* Update workflow_name based on workflow_id values.
*/
public function populateWorkflowName() {
public static function populateWorkflowName() {
CRM_Core_DAO::executeQuery('UPDATE civicrm_msg_template
LEFT JOIN civicrm_option_value ov ON ov.id = workflow_id
SET workflow_name = ov.name'
Expand Down

0 comments on commit adcd515

Please sign in to comment.