View Issue Details

IDProjectCategoryView StatusLast Update
0017415mantisbtdb schemapublic2017-08-15 03:58
Reportervboctor Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary0017415: Token type as string rather than int
Description

Tokens can be a useful tool for plugins. It allow savings tokens into the database that persist or expire over time. Does it make sense to open this up for plugins?

If so, then we should move away from using some constants integer as the key and using a string instead. Hence, the token name can be plugin_xyz_token rather than 700 with the hope that no one else is using such number.

We trick here is to figure out when a token is the right solution vs. a new table. I guess the same applies ever for our own usage. Some advantages of tokens:

  • Can add more tokens without schema changes.
  • Have generic expiry concept.

Disadvantages:

  • Not first class schema, not as easy to visualize from a schema file.
Additional Information

Token Table Structure:

$upgrade[ 42] = array('CreateTableSQL',array(db_get_table('tokens'),"
id I NOTNULL PRIMARY AUTOINCREMENT,
owner I NOTNULL,
type I NOTNULL,
timestamp T NOTNULL,
expiry T,
value XL NOTNULL",

Tagsschema

Activities

cproensa

cproensa

2017-08-14 18:33

developer   ~0057457

FYI.
I needed the token functionality for one plugin and found the described limitation, so i had to use an arbitrary integer:
https://github.com/cproensa/timetracking/blob/a82773d8e2dd2910fa607a9179f01df3c0b25534/TimeTracking/core/constants.php#L8