Issue summary last updated in comment #30.
Problem/Motivation
When viewing the Varnish module configuration at admin/config/development/varnish, the following PHP notice is output:
Notice: Undefined offset: 1 in theme_varnish_status() (line 264 of sites/all/modules/varnish/varnish.module).
... and, in the Status section, Varnish running. appears with a checkmark, but The Varnish control terminal is not responding at theme_hook_original on port . appears below it, with an error mark.
This happens on Drupal 7.33 and 7.34, running the Varnish module version 7.x-1.0-beta3, hooked up to varnishd version 3.0.2 revision cbf1284.
Upon investigation, it appears that there are multiple problems working together to cause these errors:
hook_theme()is not implemented correctly invarnish_theme(): the associative array of theme hook information contains a sub-array namedargumentswhich should actually be namedvariables- The call to
theme('varnish_status', ...)is incorrect: the arguments are passed straight to thetheme()function itself instead of inside the$variablesparameter. - The
theme_varnish_status()theme handler assumes the$statusargument is passed directly to the function, when it is really passed inside the first parameter to the function (which is a$variablesarray).
Proposed resolution
Correct the definition, implementation, and call to theme_varnish_status().
Remaining tasks
- Review the patch in #24.
- Commit the patch
- Release a new version of the Varnish module
User interface changes
None.
API changes
None.
Original report by @antoniomanco
Hello, i received this message in my varnish module options:
"The Varnish control terminal is not responding at theme_hook_original on port"
Notice: Undefined offset: 1 en theme_varnish_status() (línea 264 de /home/mysite/public_html/sites/all/modules/varnish/varnish.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | varnish-2371907-24.patch | 1.87 KB | markpavlitski |
Comments
Comment #1
antoniomanco commentedComment #2
rmccullough commentedI'm getting the same error
Notice: Undefined offset: 1 in theme_varnish_status() (line 264 of /var/www/mysite/sites/all/modules/varnish/varnish.module).
I have recently updated the core to 7.33 don't know if that was the issue was fine before
Comment #3
tkngdwn commentedI can confirm this is occuring as well. It appears to be related to the $status array containing the varnish server details as well as a reference the theme_hook_original.
Contents of the $status array as passed to theme_varnish_status():
Comment #4
andsigno82 commentedSame issue to me as updated to 7.33
Comment #5
shawnrosspeters commentedI'm having same problem. Just wanted to confirm that I'm also using Drupal 7.33.
Comment #6
WizardIP commentedFollowing, I have the same issue as updated to 7.33.
Comment #7
axle_foley00 commentedI believe I have the same issue "The Varnish control terminal is not responding at theme_hook_original on port ." after I updated to Drupal 7.33
Comment #8
LobsterJonn commentedThis seems to be due to the following change in Drupal 7.33
https://www.drupal.org/drupal-7.33-release-notes
I fixed it by adding this to the beginning of the function theme_varnish_status on line 261
so it looks like this:
Comment #9
tkngdwn commentedWhile unset will work for this, a more elegant solution would probably be to negate the item in the loop like so:
Comment #10
WizardIP commentedFixed, LobsterJonn's solution worked for me. Thank you.
Comment #11
tkngdwn commentedHere's a patch file for #9.
Comment #12
mitchelljj commentedI realize that this problem occurs with Drupal 7.33 only but when Drupal is eventually upgraded to 7.34 will this problem go away or will this continue to be a problem for all future versions of the Drupal core from 7.33 and higher for the current Varnish module?
Comment #13
vinmassaro commentedComment #14
retorque commentedThis problem also occurs in 7.34. Patch in #11 fixed it for me.
Comment #15
bartmcphersonPatch #11 worked for me as well in Drupal 7.34.
Comment #16
caspervoogt commentedHad this issue on 7.33 and 7.34 and the patch from #11 solved it for me. RTBC?
Comment #17
vacilando commentedPatch #11 works indeed; setting this to RTBC.
Comment #18
jlab commentedI can also confirm the patch worked me as well. Both 7.33 and 7.34.
Comment #19
misc commentedAdding tag for core incompatibility, think that should be done?
Comment #20
tkngdwn commentedI would most definitely say that this does not have a core incompatibility. The error is only appearing because of the core change mentioned in #8. However the error only appears due to iteration over the array. Everything still functions correctly without the patch. Fixing the error is a purely cosmetic fix.
Comment #21
imclean commentedWould it make more sense to have some validation for the server and port rather than specifically exclude a value?
Comment #22
tkngdwn commentedIf there were more than just the one additional key/value pair being passed to the function I might agree that it would merit additional code. However, given that we know the key/value pair will be passed with that specific key and it is the only key/value pair that is not a varnish server it wouldn't make much sense to perform validation on the passed data outside of what the function already does.
Comment #23
basvredelingTwo thumbs up for #11
Comment #24
markpavlitski commentedWhile the patch in #11 does fix this particular issue, the underlying problem comes from an incorrect use of Drupal's theme system and the same issue could reoccur in future.
This patch mitigates the issue by correcting the way the theme system is used, and avoids having a 'magic string' check for theme_hook_original.
Comment #25
webfunkin commentedHaving the same issue on Drupal 7.34
Comment #26
frankkessler commentedPatch #24 is working for me and I think it's the correct way to go. It will prevent any additional variables from causing issues in the future.
Comment #27
tkngdwn commentedI haven't had a chance to apply the patch in #24, but it does appear to negate passing the additional theme variable this way and would be a better solution.
Comment #28
caspervoogt commentedI can confirm the patch from #24 works well.
Comment #29
misc commented+1 for patch in #24, also in favor for that solution.
Comment #30
mparker17I was experiencing this on Drupal 7.34, running the Varnish module version 7.x-1.0-beta3, hooked up to varnishd version 3.0.2 revision cbf1284.
I've updated the issue summary with the information from the comments and the patch.
I've reviewed the code in #24 and I believe it to be the correct solution to the problem. It appears to conform to coding standards and the resulting code is clear. I have tested it on my site, it applies cleanly, and it works as-described.
I do not believe this change needs tests: it corrects problems with the way that this module uses the Drupal theming API, which is already well-tested in core.
I second @frankkessler's RTBC.
Comment #31
manumilou commented+1 for patch #24. More clean, and works just fine on 7.34.
Comment #32
wOOge commentedPatch in #24 applies cleanly and fixes the OP's error. Drupal 7.34, varnish-7.x-1.0-beta3
Comment #33
opratr commented+1 for RTBC. Patch #24 applied cleanly and corrected the issue. Drupal 7.34, varnish-7.x-1.0-beta3
Comment #34
damien_vancouver commentedanother +1 - Patch #24 fixed the error message for d7.34, varnish 7.x-1.0-beta3 against varnish 3.x.
Comment #35
bjcooper commentedPatch #24 worked for me. Thanks for the patch.
Comment #36
esolitosI can also confirm that the patch #24 is ok, thanks markpavlitski.
- Varnish-7.x-1.0-beta3
- Drupal 7.34
Comment #37
misc commentedI have contacted the module maintainer to check if help is needed to get this and other issues that is RTBC committed.
Comment #39
misc commentedThis is committed to latest dev, I will try to get a new release out in some days from now, need to take care of a couple other RTBC issues as well.
Comment #41
himanshupathak3 commentedThanks patch #24 worked for me :)
Comment #44
meshwetaHey! Great help for me. Patch attached to comment #24 helped me. Thanks a lot!!!
Comment #45
yngens2 commentedWill this ever be committed to the official version as we have to patch every time we download Varnish module?
Comment #46
jamesoakley@yngens2 - it's been committed. See comment #38.
Comment #47
bdupls commented#24 worked and helped me out. Hope to see this committed in next varnish update. Cheers
Comment #48
yngens2 commentedJamesOakley, however when Varnish module is installed with drush, the status page still shows "The Varnish control terminal is not responding at theme_hook_original on port ." error. Is drush pulling incorrect version?
Comment #49
jamesoakleyIt was committed on 17th March 2015, but there have been no numbered releases of the module since then.
So you'd need "drush dl varnish 7.x-1.x-dev", yes.
We could do with another point release of the module; I think there have been a few commits that could do with wider circulation.
Comment #50
esolitosCa we have this pushed to a release please?
Comment #51
jamesoakleySetting this back to Closed
@esolitos - I, like you, would love the module maintainers to tag a new release of the module so that we can have this fix without having to use the -dev release. However, the way Drupal issues work, is that this issue is marked as "Fixed" once a patch has been committed to the repository, and then moves to "Closed" if no further problems occur after 2 weeks. We reached that point, so this issue is closed.
Re-opening this issue is not the way to ask for a tagged release. If you want to, you could create a new issue in the issue queue, make it a "Task" not a "Bug Report", link it to this issue, and request a new tagged release that incorporates this and other changes.
Comment #52
ressaJust a little note to others, it is actually
drush dl varnish-7.x-1.x-dev(with a dash between name and version), but apart from that it does take care of the problem.Comment #53
imclean commenteddrush dl varnish --selectwill let you choose a version interactively.Comment #54
vbard commentedHi!
Sorry to open but installing 7.x-1.0-beta3+6-dev doesn't solve the problem.
Notice: Undefined offset: 1 in theme_varnish_status() (line 264 of sites/all/modules/varnish/varnish.module). still appears.
Comment #55
vbard commentedoops.. seems like everything works without errors :)
Comment #56
doitDave commentedPardon me bumping, I still receive this error with beta4 (using 3.x).
Comment #57
daemonchrist commentedSeems to be working fine with Varnish 4.x and 1.1 version of this module
Comment #58
doitDave commentedConfirmed now, there seemed to have been remainders of a former setting somewhere in the DB. After a cleanup it really works.