There seems to be an issue when anonymous page caching is enabled.

Duplication steps:
Enabled anonymous caching.
Refresh any page as an anonymous user.

PHP Fatal error: Call to undefined function drupal_session_started() in /Library/WebServer/Documents/achieve-client/profiles/openatrium/modules/contrib/og_session_context/og_session_context.module on line 108

Comments

Tristanwellz created an issue. See original summary.

mpotter’s picture

Status: Active » Postponed (maintainer needs more info)

That sounds more like a site-specific configuration problem, maybe an issue with APC or something. drupal_session_started() is a core function in Drupal and should always be available.

Can anybody else reproduce this?

shawn_smiley’s picture

Good morning mpotter,

Here is some additional information and context for this issue. Though I agree that this is an extremely odd error that shouldn't be possible.

This error is occurring on our Pantheon hosting Open Atrium 2 site. The errors started occurring after we upgraded OA2 from 2.43 to 2.44.

Here is the callstack logged by Pantheon when the error occurs:

1 og_session_context_exit() /profiles/openatrium/modules/contrib/og_session_context/og_session_context.module:108
2 og_session_context_exit() :null
3 call_user_func_array(og_session_context_exit, Array ()) /includes/module.inc:866
4 module_invoke(og_session_context, exit) /includes/bootstrap.inc:1116
5 bootstrap_invoke_all(exit) /includes/bootstrap.inc:2431
6 _drupal_bootstrap_page_cache() /includes/bootstrap.inc:2261
7 drupal_bootstrap(7) /index.php:20

We have had Pantheon completely restart our application containers thinking that it was a problem with the PHP 5.5 OpCache. But that did not resolve the issue.

Disabling Anonymous Page Caching does make the error go away though.

  • mpotter committed bd21d6a on 7.x-1.x
    Issue #2565319: Undefined function drupal_session_started
    
mpotter’s picture

Status: Postponed (maintainer needs more info) » Fixed

Hmm, I might have found this. There was a recent change to og_session_context and it looks like Drupal can call the hook_exit before the session.inc stuff is bootstrapped. Try the commit given in bd21d6a (or pull the -dev version of this module) and let me know if that fixes it. Then I'll roll a new release to get this into v2.45 in a few days.

Tristanwellz’s picture

HI Mpotter,

Thanks for pushing a fix so quickly. I updated our module and tested it in local environment and everything looks good.

Thanks,

dpoletto’s picture

Hi @mpotter!

Today observing - as maintenance practice - PHP error logs of a recently upgraded OA 2.45 site (from 2.44) I noticed that, since about (*) mid September (when the site was upgraded from 2.43 to 2.44 by me), various PHP Fatal Errors were reported (and currently the site continue to generate)...AFAIK...every time a user performs a site logout.

Here the error:

[22-Sep-2015 15:48:40 Europe/Berlin] PHP Fatal error:  Call to undefined function drupal_session_started() in /var/www/html/profiles/openatrium/modules/contrib/og_session_context/og_session_context.module on line 108

So I checked and I found the reference to above reported Commit bd21d6a for og_session_context and, cross-checking my OA 2.45, I noticed that its Session Context module still reports 7.x-1.0-beta3 version (so of mid August and shared with OA 2.44 at most) and so it hasn't that commit committed...at least this is what I see on my site.

Here its code:

103	 * Implements hook_exit().
104	 */
105	function og_session_context_exit($destination = NULL) {
106	  // Skip call to context if we have no session.
107	  global $user;
108	  if (($user->uid == 0) && !drupal_session_started()) {

Could you confirm the latest Commit subject of this thread has really been committed into OA 2.45?

Am I wrong and my site has something strange or what?

Thanks for watching.

Edit (*): ...when I enabled "Cache pages for anonymous users"...in the end I can live without it (disabled) but the issue will remain.

dpoletto’s picture

Below, just as reference, og_session_context.module versions provided with OA 2.2x, 2.3x and 2.4x versions, up to latest OA 2.45:

  • OA 2.23 released 29.10.2014 has Session Context 7.x-1.0-beta1 (29.08.2013)
  • OA 2.24 released 13.11.2014 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.25 released 20.11.2014 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.26 released 17.12.2014 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.30 released 11.02.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.31 released 23.02.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.32 released 27.02.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.33 released 20.03.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.40 released 07.05.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.41 released 09.05.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.42 released 22.06.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.43 released 09.07.2015 has Session Context 7.x-1.0-beta2 (30.10.2014)
  • OA 2.44 released 20.08.2015 has Session Context 7.x-1.0-beta3 (17.08.2015)
  • OA 2.45 released 17.09.2015 has Session Context 7.x-1.0-beta3 (17.08.2015)
rabithk’s picture

I have the same issue in "openatrium-7.x-2.45" also . If I clear the performance cache , this work , but if I load the anonymous page again and again , I am getting the same error . Any issue fix for this?

mpotter’s picture

The fix is to use the -dev version of the og_session_context module. We'll get a release of this put into the next Atrium update.

rabithk’s picture

you mean to say I can update only "og_session_context" 7.x-1.x-dev inside the "openatrium-7.x-2.45" core ?

dpoletto’s picture

Thanks Mike for clarifying.

mpotter’s picture

rabithk: yes, if you absolutely need this fix before the next release. Or, you can just apply the patch shown here http://cgit.drupalcode.org/og_session_context/commit/?id=bd21d6ab167af09... to og_session_context.

The issue was fixed, but we just forgot to tag a new release of that module and get it into Atrium.

mpotter’s picture

Or, just disabled the "Cache pages for anonymous users" until the next release.

rabithk’s picture

Thank you Mike . I will try with #13 ( applying patch or using new version of the module , - When I am comparing the dev and recommended version , there is no difference, the patch is already applied. ) , as I want to use cache for anonymous users.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.