RESTful-Drupal / restful

RESTful best practices for Drupal
https://drupal.org/project/restful
419 stars 173 forks source link

token authentication entity query failure #1058

Closed arysom closed 3 years ago

arysom commented 5 years ago

After the latest upgrade I've received the following error when trying to authenticate with token:

PDOException: SQLSTATE[HY000]: General error: user-supplied class does not have a constructor, use NULL for the ctor_params parameter, or simply omit it in EntityAPIController->query() (line 189 of /Users/arysom/Sites/drupal/sites/all/modules/contrib/entity/includes/entity.controller.inc).

I've traced the issue and changed inside the entity controller:

$result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType));

to:

$result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], NULL);

It has something to do something with the restful_token_auth/src/Plugin/authentication/TokenAuthentication.php around 46th line.

I'm unable to draw any conclusions from it. Maybe someone could help me understand?

Entity API 7.x-1.9, and Restful 7.x-2.17

arysom commented 5 years ago

Hi @e0ipso

I've tried to find were to update without modifying the entity module, I've added empty constructor in restful/modules/restful_token_auth/src/Entity/RestfulTokenAuth.php and now it works properly.

<?php

/**
 * @file
 * Contains Drupal\restful_token_auth\Entity\RestfulTokenAuth.
 */

namespace Drupal\restful_token_auth\Entity;

class RestfulTokenAuth extends \Entity {
    public function __construct()
    {
    }
}

I could commit it, but I have no clue where - I only see the latest updates to 7.x-2.16 tag here and inside gitlab.