Thanks for great module, there's a problem tho -
while having this module enabled, varnish cache gets missed because module creates user session even for anonymous users. text_resize module works smooth with caching, but it isn't as configurable as this module.
Comments
Comment #1
CZ commentedSessions are for textsize_check() and can be removed.
Comment #2
CZ commentedThanks! Fixed.
Comment #4
bcobin commentedSorry for reopening this - I'm having the same problem with 7.12 and Varnish won't run. How would I stop the module from setting a cookie for anonymous users? Thanks much!
Comment #5
CZ commentedDo you use the current 7.x-1.x-dev version?
Comment #6
bcobin commentedThank you, Christian - I am now.
textsize and has_js cookie is being set (has_js wasn't set before) and the module also now fails to work - it just seems to reload the page without changing text size. (Edit: clicking on "increase" makes the text tiny, actually; other buttons will reset, but text size doesn't change.)
Varnish fails (although I'm not certain it's this module.)
With the failure of the .dev to work, I probably tried it at some point and then "rolled back" to 1.0, which I've just done again now. Thank you for your response!
Comment #7
CZ commentedComment #8
andyf commentedHi,
I'd love to have this functionality. drupal_page_is_cacheable() is returning FALSE because of this on all pages. I'd prefer not to use dev if at all possible: could you point me to a commit/issue/patch?
Thanks in advance,
Comment #9
CZ commentedSet:
- "Scripting languages " to "PHP + JavaScript + Optimized for performance." and
- "Display message after changing text size"
Comment #10
andyf commentedThanks for the quick reply! That should work with 7.x-1.0?
Comment #11
CZ commentedAs you can see the "version" of this issue is "7.x-1.x-dev".
Comment #12
andyf commentedSorry, I wasn't clear in the original message. I'm hoping you can point me to a commit/patch that will give me the functionality without installing dev. Thanks.
Comment #13
mrfelton commentedThis is an issue for D6 too. setcookie is being unconditionally called in hook_block().
Comment #14
mrfelton commentedAttached is a patch for D6 that makes the setting of the cooke lazy - it only gets set when an attempt to change the textsize is made.
Comment #15
baysaa commentedLatest dev version fixes the caching issues.
However, with PHP+Javascript+Optimized setting, when the javascript runs it doesn't re-set the body class after reading the cookie. I think it relies on PHP to set it before the page load, but doesn't take into account that there might be a static html cache of the page.
Here's steps to reproduce: (Make sure you are browsing as Anonymous and have Boost or other caching which generates static html files for Anonymous users)
1. Clear your static HTML cache. Go to a page and reset textsize to default, then set text size to 120% or whatever value that will make you notice the difference. When you change textsize on this page, the cookie will be set.
2. Now go to a non-cached page. This time the cookie is read so notice the textsize is 120%, and body class is set to textsize-120. Now check if the cache of this page is generated.
3. Go to a different page, and reset the textsize back to default. The cookie should be changed now.
4. Go back to the page at step 2 and notice the textsize is still 120% due to it being cached with body class textsize-120
There's a simple fix I've managed to whip up:
in jquery.textsize.js file find (line 8 in dev version):
Replace with:
Comment #16
mrfelton commentedPatch updated against Drupal 7. Also updated so that the cookie gets deleted once the size is back to normal.
Comment #17
mrfelton commentedUpdated patch also adds a setting to control wether or not the session should be used to store textsize status for anonymous users.
Comment #18
mrfelton commentedMarked #1800512: Incompatible with Pressflow as a duplicate.
Comment #19
mrfelton commentedMissed a bit so sessions were still being set.
Comment #20
nicolas bouteille commentedupdating title so that more people can find this thread
Comment #21
nicolas bouteille commentedAccording to one of the maintainers of the Boost module, this could be a security issue so I am switching this as a bug until proven wrong.
Here's the explanation I got :
Boost maintainers « can only work within the scope of Drupal's login mechanism and if someone wants to add a module to do something custom, then they should use a differing cookie so that anonymous users are not assigned a login id, otherwise basically boost cannot work and also it does somewhat break the strict Drupal separation between anonymous and authenticated users which may also be a security issue with assigned roles.
I would submit a bug report to the module authors, pointing the above out. » by Philip_Clarke
Original discussion can be found here : http://drupal.org/node/1807818
Comment #22
nicolas bouteille commentedIn the mean time, patch #19 worked great for me! Thanks a lot mrfelton.
Comment #23
mrfelton commentedUpdated patch also switches to using hook_page_build to add the js, and drupal_add_library to add the jquery.cookie library, and sets every_page = TRUE for the js and css so that they can be aggregated better. I would have made these changes in a separate patch, but it would have to depend on this one so didn't seem worth it.
Comment #24
fastangel commentedI update the patch. I added a condition on the delete cookie. If you set a cookie with other path the cookie continue with the same value when you change to other path. For delete do you need use the root path
Comment #25
bcobin commentedUpon applying the patch from #24 to dev version, I get the following:
patching file textsize.module
patch unexpectedly ends in middle of line
Hunk #3 FAILED at 344.
1 out of 3 hunks FAILED -- saving rejects to file textsize.module.rej
Site then throws the following error:
Fatal error: Call to undefined function _textsize_set_session() in /home/icrmedia/public_html/[site]/sites/all/modules/textsize/textsize.module on line 109
Reversing the patch for now but will check back - thanks for diving into this!
Comment #26
CZ commented@bcobin the function _textsize_set_session() have to be defined first.
Comment #27
CZ commentedPatch 25 (and 24) give me an javascript display error "NaN" on "Current Text Size"
Comment #28
CZ commentedProblem found: "textsize_set(tsCurrent);" on line 11 in the jquery.textsize.js file.
Comment #29
CZ commentedFor the current dev version. Now it should be fixed.
Test it on the Demo Page.
Comment #30
CZ commentedCode is now in 7.x-1.1-rc1 release.