Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Enumerated update statuses instead of binary #12

Open
wants to merge 6 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

waleedq
Copy link

@waleedq waleedq commented May 5, 2019

Enumerated update statuses instead of binary:

  1. CONFIG_NOT_FOUND
  2. CONFIG_ALREADY_APPLIED
  3. CONFIG_NOT_EXPECTED
  4. CONFIG_APPLIED_SUCCESSFULLY

This PR will make the module return more meaning full messages when it fails to apply the config updates.

@@ -62,10 +63,10 @@ function _update_helper_checklist_checklistapi_checklist_items() {
$entry = Update::load($update_key);

$status = ($entry && $entry->wasSuccessfulByHook()) ? TRUE : FALSE;
if ($status && !empty($update['#description_successful'])) {
if ($entry && $status && !empty($update['#description_successful'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to check for $entry in combination with $status, because it's already checked before with this statement: $status = ($entry && $entry->wasSuccessfulByHook()) ? TRUE : FALSE;

@@ -20,6 +20,12 @@ class Updater implements UpdaterInterface {

use StringTranslationTrait;

const CONFIG_NOT_FOUND = 0;
const CONFIG_ALREADY_APPLIED = 1;
const CONFIG_NOT_EXPECTED = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is a bit misleading. When I read it, I would expect it's the case when: configuration is there, but it should not be. I was thinking maybe EXPECTED_CONFIG_NOT_COMPLIANT or UNEXPECTED_CONFIG.

What do you think?

const CONFIG_ALREADY_APPLIED = 1;
const CONFIG_NOT_EXPECTED = 2;
const CONFIG_APPLIED_SUCCESSFULLY = 3;
const MODULES_FOUND = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave out module related states since we don't have any log messages related to that right now. And maybe we should add them with PR where we are adding expected modules functionality.

@@ -130,7 +136,7 @@ protected function logInfo($message) {
/**
* {@inheritdoc}
*/
public function executeUpdate($module, $update_definition_name) {
public function executeUpdate($module, $update_definition_name, $force = FALSE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep adding of force functionality outside this PR and add that in another feature request?

}
if (empty($expected_configuration) || !DiffArray::diffAssocRecursive($expected_configuration, $config_data)) {
// Delete configuration keys from config.
if($checkOnly){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I understand the purpose of $checkOnly. Is that something like dry-run or?

Additionally, it's not a real representation of an update result, because $config->save(); could throw an exception of real update execution.

$this->logWarning($this->t('Unable to update configuration for @configName.', ['@configName' => $configName]));

switch ($result) {
case Updater::CONFIG_APPLIED_SUCCESSFULLY:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one quick though - I'm not sure can we somehow propagate $result and send it in ConfigurationUpdateEvent. In that case, we could save it Update entity and use it for some nicer representation of update result.

What do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants