Problem/Motivation

When trying to use the Entity Save action in rules with simplenews installed the site crashes with a 500 error.

Detail

This action calls entity_access() for all entity types with 'save' as the $op and NULL as the $entity.
This calls simplenews_newsletter_access() with 'save' as the $op and NULL as the $entity. However, simplenews_newsletter_access() requires the second argument to be an instance of SimplenewsNewsletter.

Solution

Remove type hinting from the second argument of simplenews_newsletter_access()

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rlmumford’s picture

Here's a patch.

rlmumford’s picture

Status: Active » Needs review
rlmumford’s picture

This is also a problem for subscribers.

miro_dietiker’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/simplenews.module
@@ -962,7 +962,7 @@ function simplenews_newsletter_access($op, SimplenewsNewsletter $newsletter, $ac
  * Entity access callback for simplenews newsletter entity.

Unrelated, but here's a wrong comment: newsletter => subscriber

In 8.x the interface typing is intended: http://drupalfunctions.com/api/drupal/drupal!core!modules!system!entity....
But in 7.x this is the definition:
$entity: Optionally an entity to check access for. If no entity is given, it will be determined whether access is allowed for all entities of the given type.
So yes, it's optional. Any other occurence of hook_access() we need to fix?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: 2116719-3-fix_rules_and_simplenews.patch, failed testing.

Status: Needs work » Needs review
miro_dietiker’s picture

Issue summary: View changes
Issue tags: +needs test

Hmm, i like to see a test for this issue.