When trying to revert a feature the following error is thrown:

Error: Cannot use object of type stdClass as array in workbench_email/workbench_email.features.inc, line 98:
$role = workbench_email_get_role_by_name($transition['role']);

This error locks the feature in "rebuilding" state, because the workbench_email component cannot be reverted.

I am attaching a patch for this.

Comments

Petrica created an issue. See original summary.

frosev’s picture

Hi @petrica,

Could you elaborate on how you have currently configured workbench_email? What modules you currently have installed on your site? I'm trying to reproduce the issue.

jyraya’s picture

Version: 7.x-3.5 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new292.5 KB
new140.2 KB
new350.07 KB
new1.14 KB

Hello,

I met the same issue.

To reproduce the issue, I have the following environment:

  • workbench_moderation: 7.x-3.0
  • workbench_email: 7.x-3.12 or 7.x-3.x
  • feature: 7.x-2.10
  • drupal: 7.59
  • php: 5.6

The "worbench_email_admin_form_1.png" and "worbench_email_admin_form_2.png" screenshots show the workbench-email configuration, and worbench_email_feature.png one what I exported in my test feature.

If I make modifications into the workbench-email configuration and I trigger the feature revert, I got the fatal error.

According to what I observe in the feature file, the settings are included in my feature files as array containing array that are casted as objects:

/**
 * Implements hook_workbench_email_export().
 */
function w_workbench_email_export() {
  $items = array(
    'draft:needs_review:administrator' => (object) array(
      'from_name' => 'draft',
      'to_name' => 'needs_review',
      'author' => 0,
      'automatic' => 0,
      'subject' => 'DRAFT TO NEEDS REVIEW',
      'message' => 'Adminstrator!',
      'role' => 'administrator',
    ),
    'needs_review:draft:contributor' => (object) array(
      'from_name' => 'needs_review',
      'to_name' => 'draft',
      'author' => 0,
      'automatic' => 0,
      'subject' => 'NEEDS REVIEW TO DRAFT',
      'message' => 'Contributor!',
      'role' => 'contributor',
    ),
    'needs_review:validated:editor' => (object) array(
      'from_name' => 'needs_review',
      'to_name' => 'validated',
      'author' => 0,
      'automatic' => 1,
      'subject' => 'NEEDS REVIEW TO VALIDATED',
      'message' => 'Editor!',
      'role' => 'editor',
    ),
  );
  return $items;
}

It is exported as is because in the workbench_email_features_export_render hook, we assigned directly the output of the SQL query in feature export via a "fetchObject" (see line from 60 to 71 of workbench_email.features.inc:

...
      ->execute()
      ->fetchObject();

    if (!empty($item)) {
      $item->role = $role->name;
      $items[$item->from_name . ':' . $item->to_name . ':' . $role->name] = $item;
    }

The patch takes this into account.

Status: Needs review » Needs work

The last submitted patch, 3: workbench_email-feature_revert_lock-3.patch, failed testing. View results

jyraya’s picture

Version: 7.x-1.x-dev » 7.x-3.12
jyraya’s picture

Status: Needs work » Needs review

Ok. The version 7.x-3.x-dev does not exist for the automated test environment.

Can a maintainer fix this in order to continue the issue workflow?

frosev’s picture

Thank you @jyraya. I created the branch I'll test the patch and apply it to the 7.x-3.x version. I'll put a release out in the next week or so.

larowlan’s picture

Status: Needs review » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.