phpList / rest-api

This module is the REST API for phpList, powered by phpList 4
https://www.phplist.com/
GNU Affero General Public License v3.0
22 stars 12 forks source link

Sessions error: "Field 'entered' doesn't have a default value" #59

Closed samtuke closed 6 years ago

samtuke commented 6 years ago

Short problem description

When logging in using the API via the /sessions route, correct credientials are provided, but the following error is returned:

{
    "code": 500,
    "message": "An exception occurred while executing 'INSERT INTO phplist_admintoken (expires, value, adminid) VALUES (?, ?, ?)' with params [\"2017-12-04 15:09:49\", \"15574d49a0c75ff3f2f498e92ec9ca46\", 1]:\n\nSQLSTATE[HY000]: General error: 1364 Field 'entered' doesn't have a default value"
}

Steps to reproduce

  1. Install using base-distribution via composer
  2. Attempt to log in using Postman and the REST API using valid credentials, and an existing phpList 3 database

Expected behaviour

Login successful, token info is returned

Actual behaviour

Exception is returned postman_340

oliverklee commented 6 years ago

By the way, for testing the rest-api package, you don't need the base-distribution package - you can test the rest-api package in isolation.

samtuke commented 6 years ago

@oliverklee What would be the setup steps for that be (from scratch)?

oliverklee commented 6 years ago

Clone the repository, enter the directory, do a composer install, enter the DB credentials in the local configuration file, then run the local web server:

bin/console server:run -d web/
oliverklee commented 6 years ago

(Or use Composer instead of cloning the repository.)

oliverklee commented 6 years ago

Basically, the setup is the same for all four packages.

oliverklee commented 6 years ago

@samtuke When you're running composer show, which version of symfon/symfony do you see? 3.3.x or 3.4.x?

oliverklee commented 6 years ago

This works fine for me. My educated guess is that your MySQL is configured to be more strict than mine. @samtuke What is the setting for sql_mode in your MySQL server configuration?

Mine is:

sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

oliverklee commented 6 years ago

Ah, if I add the STRICT_TRANS_TABLES option, I get the same error. I'm on it.

samtuke commented 6 years ago

Nice work

oliverklee commented 6 years ago

(It looks like the MySQL on Travis also is not very strict.)

samtuke commented 6 years ago

sql_mode does not seem to be defined in my mariadb config files, but as I recall the default behavior of this setting changed in mariadb packages at some point.

oliverklee commented 6 years ago

https://github.com/phpList/phplist4-core/pull/224 should fix this.

oliverklee commented 6 years ago

Fixed.