Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The hook oe_editorial_corporate_workflow_post_update_00001() fails if the module oe_translation is not enabled #51

Closed
milioce opened this issue Jan 22, 2020 · 3 comments

Comments

@milioce
Copy link
Contributor

milioce commented Jan 22, 2020

Description

The hooks _post_update_NAME in oe_editorial_corporate_workflow load a role "oe_translator" and call to a method without checking if the role exists.

If the oe_translation module is not enabled, the role e_translator don't exist and the hook throws an error.

The oe_translation module is not a dependency of oe_editorial module.

Error

Error: Call to a member function set() on null in oe_editorial_corporate_workflow_post_update_00001()
(line 29 of .../web/modules/contrib/oe_editorial/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.post_update.php).

Suggested soluction

Change dependencies or check the role object

// Current code
function oe_editorial_corporate_workflow_post_update_00001(): void {
  \Drupal::entityTypeManager()
    ->getStorage('user_role')
    ->load('oe_translator') 
    ->set('label', 'Translate content')
    ->save();

// New code
function oe_editorial_corporate_workflow_post_update_00001(): void {
  $role = \Drupal::entityTypeManager()
    ->getStorage('user_role')
    ->load('oe_translator');

  if ($role) {
    $role
      ->set('label', 'Translate content')
      ->save();
  }
}
@milioce
Copy link
Contributor Author

milioce commented Jan 22, 2020

Pull Request #52

@ademarco
Copy link
Member

@milioce from which version to which version of the module you are trying to update?

@upchuk
Copy link
Contributor

upchuk commented Feb 4, 2020

Hey @milioce. Thanks for this, we have included a fix for this in 1.2.1.

@upchuk upchuk closed this as completed Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants