Cas Server Error SQLSTATE [HY093]

Created on 13 September 2019, about 5 years ago
Updated 19 October 2023, about 1 year ago

Hi everyone, I'm trying to implement authentication between D8 and Moodle 3.7.2
D8 as a CAS Server, I use the CAS server module for moodle https://github.com/middlebury/Moodle-auth_casattras

The initial error was the following Drupal \ Core \ Database \ DatabaseExceptionWrapper: SQLSTATE [22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "2019-09-12 18:56:46" LINE 1: ... 'ST -hZUec08prWhJWrfbvIp7eJ_e6NYg4_ItZRoXtx3N4hs ',' 2019-09-1 ... ^: INSERT INTO cas_server_ticket_store (id, expiration, type, session, uid, "user", service, renew) VALUES (: db_place_place_place_place_b_place_ins ,: db_insert_placeholder_4,: db_insert_placeholder_5,: db_insert_placeholder_6,: db_insert_placeholder_7); Array () in Drupal \ cas_server \ Ticket \ TicketFactory-> createServiceTicket () (line 111 of /var/www/example.com/web/modules/contrib/cas_server/src/Ticket/TicketFactory.php).

When trying to use the patch https://www.drupal.org/project/cas_server/issues/2811661 I got an application error, but I added everything with my hands where - removed where + added. Now the DatabaseTicketStorage.php file
looks at line 39-46
  public function storeServiceTicket (ServiceTicket $ ticket) {
    $ this-> connection-> insert ('cas_server_ticket_store')
      -> fields (
array ('id', 'expiration', 'type', 'session', 'uid', 'user', 'service', 'renew'),
array ($ ticket-> getId (), date ('Ymd H: i: s', $ ticket-> getExpirationTime ()), 'service', $ ticket-> getSession (), $ ticket-> getUser (), $ ticket-> getService (), (int) $ ticket-> getRenew ())
      )
      -> execute ();
  }
In line 92-99

  public function storeProxyTicket (ProxyTicket $ ticket) {
    $ this-> connection-> insert ('cas_server_ticket_store')
      -> fields (
array ('id', 'expiration', 'type', 'session', 'uid', 'user', 'service', 'renew', 'proxy_chain'),
array ($ ticket-> getId (), date ('Ymd H: i: s', $ ticket-> getExpirationTime ()), 'proxy', $ ticket-> getSession (), $ ticket-> getUser (), $ ticket-> getService (), (int) $ ticket-> getRenew (), serialize ($ ticket-> getProxyChain ()))
      )
      -> execute ();
  }

The error then disappeared.
But another appeared
Drupal \ Core \ Database \ DatabaseExceptionWrapper: SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match number of tokens: INSERT INTO cas_server_ticket_store (id, expiration, type, session, uid, "user", service, renew) VALUES (: db_insert_placeholder_0,: db_insert_placeholder_1,: db_insert_placeholder_2,: db_insert_placeholder_3,: db_insert_placeholder_4,: db_insert_placeholder_5,: db_insert_placeholder_6); Array () in Drupal \ cas_server \ Ticket \ TicketFactory-> createServiceTicket () (line 111 of /var/www/example.com/web/modules/contrib/cas_server/src/Ticket/TicketFactory.php).

Both sites use https
URL D8 example.com
URL Moodle 3.7.2
moodle.example.com

Time corresponds to the region, the date is correct.
Settings with D8 and Moodle wise
Please help.

💬 Support request
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇷🇺Russia vadim.burux

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia elc

    It looks like you didn't transcribe the patch from #2811661: Unexpected error while trying to logout correctly. You've got an extra ) or missing, somewhere because you have 8 fields to insert into and only 6 values resulting in sql error.

    That patch has been committed and released so you should be able just use the downloaded code. Since this is 4 years old, I'm guessing you figured it out.

Production build 0.71.5 2024