I ran the 6.x-2.x version of the Salesforce Suite modules through coder upgrade using only the coding style extensions.

The generated patch had the following hunk in it.

@@ -554,19 +570,19 @@ function salesforce_api_fieldmap_edit_fo
     }
 
     if ($value['type'] & SALESFORCE_FIELD_CREATEABLE
-    && !($value['type'] & SALESFORCE_FIELD_UPDATEABLE)) {
+     && !($value['type'] & SALESFORCE_FIELD_UPDATEABLE)) {
       $type = 'optional';
       $required = ' <span class="form-required" title="' .
         t('This field will only be set for new records.') . '">' . t('Create-only') . '</span>';
     }
     elseif (!($value['type'] & SALESFORCE_FIELD_CREATEABLE)
-    && $value['type'] & SALESFORCE_FIELD_UPDATEABLE) {
+     && $value['type'] & SALESFORCE_FIELD_UPDATEABLE) {
       $type = 'optional';
       $required = ' <span class="form-required" title="' .
         t('This field can only be set for existing records.') . '">' . t('Update-only') . '</span>';
     }
-    elseif (!($value['type'] & (SALESFORCE_FIELD_CREATEABLE | SALESFORCE_FIELD_UPDATEABLE))) {
-      $type = 'optional';
+    elseif (!($value['type'] & SALESFORCE_FIELD_CREATEABLE | SALESFORCE_FIELD_UPDATEABLE) {
+      $type 'optional';
       $required = ' <span class="form-required" title="' .
         t('This field will be available for imports only.') . '">' . t('Read-only') . '</span>';
     }

Note the third set of substitutions. It changed the logic from:

(!($a & ($b | $c)))

to:

(!($a & $b | $c)

Three things wrong:

1. Final logic is wrong.
2. Missing a closing round bracket at the end of the elseif line.
3. The second line is changed to $type 'optional'; from $type = 'optional'; which is also incorrect syntax.

Comments

solotandem’s picture

Project: Coder » Grammar Parser
Component: Upgrade Routines » Code

Apparently, this is the first piece of code encountered with these nested bitwise expressions. Thanks for reporting this.

solotandem’s picture

Title: Coder Upgrade breaks bitwise order of operations / syntax » Parser does not handle nested bitwise operators
Assigned: Unassigned » solotandem
Status: Active » Fixed

Fixed in next dev release.

Thanks for reporting this.

brianV’s picture

Thanks for the quick fix on this!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.