When i'm logged in as administrator image captcha generates fine, but i noticed that there is no image if i go to site as anonymous user. Watchdog reports the following:

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary.

Any ideas?

Comments

phpcoder2015’s picture

Issue summary: View changes
phpcoder2015’s picture

I noticed that if i comment 1 line at PageCache.php, then it works fine

    // Only allow page caching on master request.
    //if ($type === static::MASTER_REQUEST && $this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) {
      //$response = $this->lookup($request, $type, $catch);
    //}
    //else {
      $response = $this->pass($request, $type, $catch);
    //}

But i have no clue what lies behind all this (and why page caching is used at all when we generate captcha image)..

phpcoder2015’s picture

Issue summary: View changes
phpcoder2015’s picture

Priority: Normal » Critical

I'm using Drupal 8 beta10. I see no page_cache module in previous beta i have installed. CAPTCHA works well there. So something is definitely changed in beta10.

phpcoder2015’s picture

Had to disable "Internal page cache" module added to beta10 while it is not fixed.

phpcoder2015’s picture

Even using this (hack) currently to keep other caching functionality for anonymous users:


// core\modules\page_cache\src\StackMiddleware\PageCache.php

  /**
   * {@inheritdoc}
   */
  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
    // Only allow page caching on master request.          
    if ($type === static::MASTER_REQUEST && $this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW
        && strpos($request->getRequestUri(), 'image-captcha-generate') === false) {
      $response = $this->lookup($request, $type, $catch);
    }
    else {
      $response = $this->pass($request, $type, $catch);
    }

    return $response;
  }
phpcoder2015’s picture

Another nightmare i face now is that i'm using image captcha in the block, so i switched off block caching for that particular block. Same image is generated over and over it probably means it takes image from cache even if block caching is disabled. WTF drupal ... :(

P.S. with "Internal page cache" module disabled everything works fine.

berdir’s picture

The caching issue is known, that's because the disable caching functionality hasn't been properly ported, we'll look into that.

elachlan’s picture

elachlan’s picture

Caching should be fixed. Could someone please test this again with the latest dev?

elachlan’s picture

Title: Strange bug for anonymous user. LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. » Anonymous users receive error 'LogicException: The database connection is not serializable.'

Updated title to be less obtrusive.

sumitmadan’s picture

Working fine for me. I think issue can be closed now. :)

berdir’s picture

Status: Active » Closed (duplicate)

Yes, we fixed that as part of the page cache issue.