CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • CiviCRM kills Varnish!
Pages: [1]

Author Topic: CiviCRM kills Varnish!  (Read 2942 times)

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
CiviCRM kills Varnish!
March 04, 2012, 08:47:30 am
Original title: CiviCRM defaultWysiwygEditor leaving anonymous cookie causing Varnish miss

Drupal 7.12, Civi 4.1

I've been trying to get Varnish working; we've been consistently getting a "miss" on account of an anonymous cookie issue. It took my hosting company (Imageleet) a while to track it down, but it looks like they've found the culprit. (See below.)

How would I go about removing the anonymous cookie here? Thanks much for any help!

Quote
I just wanted to give heads up that i found the module in your site which is generating session cookie for anonymous users, Adding debug code in includes/session.inc file produced following message on screen for anonymous users where CiviCRM defaultWysiwygEditor var seem to be the culprit.

Code: [Select]
Array
(
[CiviCRM] => Array
(
[defaultWysiwygEditor] => 1
)

)

Above variable need to be removed from module or specific module need to be disabled.
« Last Edit: March 11, 2012, 09:17:18 am by bcobin »

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
CiviCRM kills Varnish!
March 11, 2012, 09:16:15 am
Bumping this and changing the title - I think this is a major issue for anyone trying to use Varnish and Civi. (Which won't currently work.)

I've verified that Varnish works with Civi disabled - does anyone have any idea what code I could comment out so that Civi doesn't drop the cookie for anonymous user as described above? Waiting... and hoping... thanks for any help!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM kills Varnish!
March 11, 2012, 11:23:23 am

Might want to to start tracking the code referenced via this issue:

http://issues.civicrm.org/jira/browse/CRM-8765

and see what is happening and why

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 11, 2012, 12:00:02 pm
Thank you for the quick response, Donald - the second solution looks to have already been implemented in 4.1.1 (without solving the problem) and the first seems to have no effect either. Perhaps I'm pasting it in wrong (which is very possible).

Here's the suggested code, with surrounding lines:

Code: [Select]
require_once 'CRM/Core/BAO/Preferences.php';
        //fixme - after 3.4 is discontinued remove 3.4 support
        //As this file may be shared between 3.4 & 4.1 releases use the BAO_Preferences::value legacy function if it exists
        // in future only CRM_Core_BAO_Setting::getItem will be required
        $args = explode( '/', $_GET['q'] );
        if (( ! isset( $args[1] ) OR $args[1] != 'upgrade') &&
            (method_exists('CRM_Core_BAO_Preferences','value') && CRM_Core_BAO_Preferences::value( 'editor_id' ) == 4)
             || ( method_exists('CRM_Core_BAO_Setting','getItem') && CRM_Core_BAO_Setting::getItem( CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
  'editor_id' ) == 4 )) { //drupal wysiwyg
            //we have to ensure that wysiwyg is loaded since
            //pages load only with ajax callbacks
            $formats = filter_formats();
            foreach ($formats as $id => $format) {
                wysiwyg_get_profile($id);
            }
            $path = drupal_get_path('module', 'filter');
            drupal_add_js($path . '/filter.js');
            drupal_add_css($path . '/filter.css');
        }
    }
   
    if(empty($_SESSION['CiviCRM'])) {
   unset($_SESSION['CiviCRM']); }

    return true;
}

Please feel free to reach out to me if you'd like to take a look at the site "in the wild" - it's amazing that one little cookie can ruin an otherwise great party. Thanks for your response... standing by!
« Last Edit: March 11, 2012, 04:15:59 pm by bcobin »

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 13, 2012, 07:51:47 am
Bumping this, because while this is reported as fixed in http://issues.civicrm.org/jira/browse/CRM-8765, it's not. Not for 7.12 and 4.1.1 anyway. So I guess either the issue should be reopened or a new one started, right?

The discussion there has to do with disabling anonymous cookies in general (which I presume is a good idea in any event), but in this case, defaultWysiwygEditor seems to be the offender. I'd be happy just to get rid of that particular code to get Varnish to run.

If someone wants to see this "in the wild" (the site launched yesterday), just reach out - this would be a good case to verify a fix. Regardless, any ideas greatly appreciated... thanks!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM kills Varnish!
March 13, 2012, 08:56:06 am

civicrm.org is also running varnish

If you goto the home page without any cookies, there is no session cookie set by drupal / civicrm (there are other tracking cookies by google analytics and jquery)

so can u reproduce this on civicrm.org

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 13, 2012, 09:19:33 am
Thanks for the quick response, Donald!

The answer is Yes - if you go to http://civicrm.org from http://isvarnishworking.com, you'll get a "Yes - Sort of" message, which means a Varnish miss. (Although the reason seems to be different.)

The site in question is http://bishopforcongress.com. We're still working on stuff, but we're pretty much there. With Civi disabled, the site hits Varnish, so it must be a Civi thing. As to the actual culprit, the defaultWhyswygEditor looks like a good bet, but what do I know?

(And speaking of new sites, congrats on the new Civi site... nicely done! I got a sneak peek from the good folks at Rayogram a little while back - good work!)

Thanks again for taking the time... fingers crossed on this...

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM kills Varnish!
March 13, 2012, 09:39:03 am

U'll need to get someone more skilled in varnish and figure out whats happening on your site and why. For the civicrm.org site, definitely the GA / has_js cookies is probably blocking the site from being cached

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 13, 2012, 09:45:24 am
Yeah - that's a pretty standard exception that can by included in the .vcl file, as I understand it. My host has been working with me on all of this, so I don't have access to (or the skills to operate) at that level; you certainly do.

They've included the exception in the .vcl file, so in our case, that's not it.

If I were to start poking around to look where defaultWysiwygEditor might be dropping a cookie, where do you think would be a good place to start? Thanks again for responding and good luck... for both of us!

« Last Edit: March 14, 2012, 04:01:03 pm by bcobin »

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 14, 2012, 09:31:21 am
This just in from Raul at Imageleet Hosting - Raul is wonderful:

Quote
Session variable for defaultWysiwygEditor i found in two php files
public_html/sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Display.php
public_html/sites/all/modules/civicrm/CRM/Core/Smarty.php

Session was specified for defaultWysiwygEditor in these files which i commented as you can also see commented code for defaultWysiwygEditor in these files. However now debug has removed defaultWysiwygEditor from session but its still there.

Note nothing in [CiviCRM] => Array () instead of defaultWysiwygEditor before, so this is still specified somewhere in the script.

Code: [Select]
Array
(
[CiviCRM] => Array
(
)

)

Again, it's definitely a Civi thing that's stopping Varnish - before the site went live I was able to disable Civi and Varnish ran fine.

Hope this helps... thanks!

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: CiviCRM kills Varnish!
March 14, 2012, 04:03:22 pm
OK - I see that Varnish is working on Civi now - what did you do?

Dying to know... thanks and congrats!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • CiviCRM kills Varnish!

This forum was archived on 2017-11-26.