Problem/Motivation
Strange error
Notice: Only variables should be passed by reference in Drupal\adsense\Plugin\Filter\AdsenseFilter->process() (line 81 of modules/contrib/adsense/src/Plugin/Filter/AdsenseFilter.php)
when using 'tags' to insert Adsense snippet into nodes / views via Drupal's content filtering system. The notice appears to be generated just after the point where the method call ad->display() returns.
This was outputting to the message area during development (notices etc being printed to screen) & writing lots to the log even in production mode with warnings / notices suppressed.
I managed to reproduce the error on a fresh install of Drupal 8.2.5, in a pretty standard 'Drupal VM' development environment (Apache 2.4.18 / PHP 7.0.8 using PHP-FPM / MySQL 5.7.16 / Ubuntu 16.04 / Virtualbox 5.1.12 / Vagrant 1.8.6)
Proposed resolution
Have managed to fix the error on my system by a small change to the code, but I cant quite work why it is making any difference! Stumbled upon the solution after breaking down a single line of code with chained methods / inline method calls into several lines so I could get a better idea of what was happening via the debugger. (Debugger wasn't jumping into the method code and showing the internal workings whilst evaluating the line of code with the chained methods etc...)
I will attach a patch showing the difference that fixes the issue for me.
Remaining tasks
Would be interesting to see if anybody else is getting the same issue, maybe it's just a quirk of my environment. Would be worth people checking their logs too as the message might not show up if warnings / notices have been suppressed.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | adsense-notice-error-2844017.patch | 638 bytes | bombjack |
Comments
Comment #2
bombjack commentedComment #4
jcnventuraMakes sense, as Renderer::render(&$elements, $is_root_call = FALSE) requires the first element to be a variable since it's passed by reference.