Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We introduced a bug in #1895266: Convert views to use the ModuleHandler
// Let the themes play too, because pre render is a very themey thing.
foreach ($GLOBALS['base_theme_info'] as $base) {
- $function = $base->name . '_views_pre_render';
- if (function_exists($function)) {
- $function($this);
- }
- }
- $function = $GLOBALS['theme'] . '_views_pre_render';
- if (function_exists($function)) {
- $function($this);
+ $module_handler->invoke($base, 'views_pre_render', array($this));
}
// Let the themes play too, because post render is a very themey thing.
foreach ($GLOBALS['base_theme_info'] as $base) {
- $function = $base->name . '_views_post_render';
- if (function_exists($function)) {
- $function($this);
- }
- }
- $function = $GLOBALS['theme'] . '_views_post_render';
- if (function_exists($function)) {
- $function($this, $this->display_handler->output, $cache);
+ $module_handler->invoke($base, 'views_post_render', array($this));
}
Both hunks assume the ModuleHandler::invoke can accept an object as the first argument but it can't... the original code that did $base->name was correct.
/**
* Invokes a hook in a particular module.
*
* @param string $module
* The name of the module (without the .module extension).
* @param string $hook
* The name of the hook to invoke.
* @param ...
* Arguments to pass to the hook implementation.
*
* @return mixed
* The return value of the hook implementation.
*/
public function invoke($module, $hook, $args = array());
Comment | File | Size | Author |
---|---|---|---|
#10 | 1972768-10.patch | 2.4 KB | patrickd |
#10 | 1972768-10-fail.patch | 1.25 KB | patrickd |
#10 | 1972768-10-interdiff.txt | 3.6 KB | patrickd |
#9 | 1972768-9.patch | 1.86 KB | damiankloip |
#1 | 1972768.views-with-base-theme.1.patch | 1.15 KB | alexpott |
Comments
Comment #1
alexpotthere's a patch
Comment #2
xjmSweet, thanks @alexpott!
Comment #4
dawehnerMissing tag
Comment #5
patrickd CreditAttribution: patrickd commented#1: 1972768.views-with-base-theme.1.patch queued for re-testing.
Comment #6
patrickd CreditAttribution: patrickd commentedsimple bug, simple patch, lets get this in
Comment #7
patrickd CreditAttribution: patrickd commentedawww.. needs tests
wondering what to test here though?
Comment #8
damiankloip CreditAttribution: damiankloip commentedI think I know what we can do here...
Comment #9
damiankloip CreditAttribution: damiankloip commentedSo, Maybe we could do something like this? Not sure if it's working.
Comment #10
patrickd CreditAttribution: patrickd commentedSome small errors, but basically it was the right direction
- The actual fix of the issue was missing (patch #1)
- The hooks were already implemented in the views_test_data module (but in views_test_data.views_execution.inc)
Comment #11
damiankloip CreditAttribution: damiankloip commentedYeha, sorry. That was a really rough patch to outline the method.
Nice, they look like good improvements to me, might as well re use the pre and post render hook implementations from views_test_data.
Comment #12
patrickd CreditAttribution: patrickd commentedNo probs, it was a good outline.
1972768-10.patch is already re-using these implementations!
Comment #13
dawehnerJust in case you want to rerole ... we could store $this->container->get('state') in a variable so that would be easier to read.
Comment #14
patrickd CreditAttribution: patrickd commentedoops, well when a patch is supposed to fail, for sure it passes XD
Turns out that using the existing hook implementations from views_test_data aren't a very good idea, because they always get called on views->render(), so to test whether they were called as "base theme", we have to count how often they've been called.
That kind of sucks and states are never good for testing..
someone spontaneously has a better approach to test this?
Comment #15
damiankloip CreditAttribution: damiankloip commentedYeah, it's a tricky thing, because we are dealing with good ol' fashioned hooks we can't mock anything :/
Unfortunately, I think we might need to go with a mixture of your last patch, and my initial patch (using different hooks that are called for the base theme).
Comment #16
BerdirI think this is a duplicate of #2084907: hook_views_pre_render() is broken if your theme implements a base theme.