There is a lot of duplicated code inside the includes folder.

Lets provide a single function to reduce the amount of code to review.

Comments

dagmar’s picture

Category: task » feature
Status: Active » Needs review
StatusFileSize
new25.95 KB

Here is the patch.

redndahead’s picture

Status: Needs review » Needs work
+++ b/configuration.module
@@ -1089,6 +1089,50 @@ function configuration_hook_info() {
+function configuration_update_compontent($component, $identifier, $items, $items_code, $from_activestore) {
+

component is misspelled, it says compontent Also all calls to that function is misspelled.

lucascaro’s picture

+++ b/configuration.module
@@ -1089,6 +1089,50 @@ function configuration_hook_info() {
 /**
+ * Updates the status of a component after it was updated.
+ */
+
+
+function configuration_update_compontent($component, $identifier, $items, $items_code, $from_activestore) {

Since we're changing the name already, would it make sense to call this function configuration_update_component_status() instead?

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new26.31 KB

Thanks, renamed the function. Added docs.

redndahead’s picture

Status: Needs review » Needs work

As an aside patches that look like this are always awesome: 9 files changed, 61 insertions, 315 deletions.

+++ b/configuration.module
@@ -1089,6 +1089,59 @@ function configuration_hook_info() {
+ *   The identifier for the componenet, usually the machine name.

componenet => component

Edit: I was wrong with what I typed here. I think I'll try and create a patch that makes some changes.

redndahead’s picture

StatusFileSize
new25.18 KB

Here is a patch that I believe accomplishes the same thing. It'll need a look over.

redndahead’s picture

Status: Needs work » Needs review
lucascaro’s picture

Status: Needs review » Needs work
+++ b/configuration.moduleundefined
@@ -1089,8 +1089,56 @@ function configuration_hook_info() {
+  // Configs in code are not the same as what was just saved in activestore.
+  if ($md5_datastore != $md5_activestore) {
+    $status = ($from_activestore == TRUE) ? $status | CONFIGURATION_ACTIVESTORE_OVERRIDDEN : $status | CONFIGURATION_DATASTORE_OVERRIDDEN;
+  }
+  // Config in the activestore is the same as what is in code.
+  else {
+    $status = CONFIGURATION_IN_SYNC;
+    configuration_set_hash($component, $identifier, $md5_activestore);

I like how this simplifies the logic, maybe we should break the long line with the (?:) into an if/else statement to make it even more readable?

lucascaro’s picture

StatusFileSize
new1.85 KB

@dagmar here's the interdiff just in case:

redndahead’s picture

StatusFileSize
new25.17 KB

This makes the ternary more readable. I'm assuming |= will accomplish the same thing.

dagmar’s picture

Status: Needs work » Needs review
redndahead’s picture

Status: Needs review » Needs work

Do you care if the $from_activestore is TRUE/FALSE or will 1 or something that evaluates to true work? Then we can remove the explicit == TRUE. Even if we leave it we should probably make it ===

lucascaro’s picture

StatusFileSize
new595 bytes

Indeed, that looks better. I'd say let's remove the redundant == TRUE

redndahead’s picture

Status: Needs work » Needs review
StatusFileSize
new25.16 KB

Here is the patch.

dagmar’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @redndahead

lucascaro’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks @redndahead, @dagmar.

GDrupal’s picture

Status: Fixed » Needs review
StatusFileSize
new1.56 KB

There is a new issue in tracking configurations that can be fixed with this patch.

GDrupal’s picture

Status: Needs review » Closed (fixed)

I'm rewriting much of the ctool code for another issue and a better fix will be provided here:
http://drupal.org/node/1538502