We have moved to Github. Please open tickets there.

Opened 3 years ago

Closed 3 years ago

#1562 closed Defect (fixed)

Add default value for entities.last_action

Reported by: kkawahara Owned by:
Priority: normal Milestone: Elgg 1.7
Component: Core Version: 1.7
Severity: minor Keywords:
Cc: brettp Difficulty:

Description

trying to setup a new 1.7RC1 installation. After filling out system settings and clicking next, the following error appears:

Field 'last_action' doesn't have a default value

QUERY: INSERT into elgg_entities
(type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated) values
('site',0, 0, 0, 0, 2, 1267356443, 1267356443)

Checking the SQL create script (mysql.sql) shows this table with an additional column (last_action) and it does not have a default value assigned.

The update SQL in the entity class does not include this column:
(from entities.sql)
return insert_data("insert into {$CONFIG->dbprefix}entity_subtypes (type, subtype, class) values ('$type','$subtype','$class')");

Upgrading from a 1.6.1 installation seems to work fine.

Change History (13)

comment:1 Changed 3 years ago by cash

This brings up a point that I've been meaning to ask about: why was last_action added to the entities table? It doesn't seem to belong there and isn't used by anything.

comment:2 Changed 3 years ago by dave

@cash this is something we plan on using in the near future so seeing as v1.7 is all about core changes, we decided to put it in there now. At the moment, you can access objects by time_updated but it will also be handy to pull out objects ordered by the last action to be carried out on them such as comments, ratings etc.

comment:3 Changed 3 years ago by kkawahara

upgrade from 1.6 actually doesn't work - first time you try and do anything, the error shows up again (Field 'last_action' doesn't have a default value).

comment:4 Changed 3 years ago by brettp

I see the potential problem but it's not causing an error for me. Can anyone else confirm this error?

comment:5 Changed 3 years ago by costelloc

I think kkawahara probably has the sql mode set to traditional. You can probably reproduce by issuing this command: set sql_mode = 'traditional' and then creating an entity.

http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html

comment:6 Changed 3 years ago by kkawahara

mode is set to strict (STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION)

is there any documentation that describes the proper mode to be in?

comment:7 Changed 3 years ago by brettp

  • Type changed from unconfirmed defect to confirmed defect

This can be configured either per-instance or server-wide. To configure this at a per-instance level for Elgg, put this in engine/lib/database.php around line 62 (in 1.7), after the UTF8 call:

// Set DB for UTF8
mysql_query("SET NAMES utf8");
mysql_query("SET sql_mode = ''");

To configure for server wide, view Cash's link above.

I'm hesitant to add another SQL query to the init functions in Elgg Core, so this should be corrected on the server side. I will update the documentation for the installation requirements, though.

comment:8 Changed 3 years ago by brettp

(In [svn:3981]) Refs #1562: Updated requirements for Elgg.

comment:9 Changed 3 years ago by brettp

  • Resolution set to wontfix
  • Status changed from new to closed

comment:10 Changed 3 years ago by cash

  • Severity changed from blocker to minor

If he is getting errors, I believe that means a warning is being thrown on every entity creation. Wouldn't a better fix be to set the default value or specify a value for the column in the create entity query?

comment:11 Changed 3 years ago by brettp

  • Summary changed from clean install of 1.7RC1 had incompatible table script/update syntax in class to Add default value for entities.last_action

Since column is completely unused in core, I'm fine putting a default value on it. I'd rather not touch all the update/create queries this late in 1.7's development.

comment:12 Changed 3 years ago by cash

  • Milestone set to Elgg 1.7
  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:13 Changed 3 years ago by brettp

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [svn:3984]) Fixes #1562: Added a default value for entities.last_action in the schema and as an upgraded. Bumped version number to 1.7 final.

Note: See TracTickets for help on using tickets.