Warning: Missing argument 4 for node_render_cache_entity_hash_alter(), called in [..]/includes/module.inc on line 1056 and defined in node_render_cache_entity_hash_alter() (line 159 of [..]/modules/render_cache/modules/render_cache_entity/render_cache_entity.module).

This is because drupal_alter() ignores the $context3 argument.

In RenderCacheControllerBase:

  protected function alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL) {
    drupal_alter('render_cache_' . $this->getType() . '_' . $type, $data, $context1, $context2, $context3);
  }

In drupal_alter():

  foreach ($functions[$cid] as $function) {
    $function($data, $context1, $context2);
  }

In render_cache_entity.module:

/**
 * Implements hook_render_cache_entity_hash_alter().
 */
function node_render_cache_entity_hash_alter(&$hash, $entity, $cache_info, $context) {
  ..

An alternative can be to provide a custom implementation of drupal_alter(), or to restructure the arguments.

Comments

donquixote’s picture

Solution:

  /**
   * {@inheritdoc}
   */
  protected function alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL) {
    $hook = 'render_cache_' . $this->getType() . '_' . $type . '_alter';
    foreach (module_implements($hook) as $module) {
      $function = $module . '_' . $hook;
      $function($data, $context1, $context2, $context3);
    }
  }

drupal_alter() is unnecessarily complex, allowing the $type argument to be an array of hook suggestions.
Making a custom version of that is a lot easier if we assume $type to always be a string. This also removes the need for extra caching, since module_implements() already covers that.

Btw, what about some docblock here and there? :)
The alter() method has an @inheritdoc, but then the base method (in the interface) has nothing..

donquixote’s picture

StatusFileSize
new917 bytes
donquixote’s picture

Status: Active » Needs review
donquixote’s picture

Status: Needs review » Closed (won't fix)

And this was again due to an older version of Drupal I had on localhost.
Sorry for the noise.