knop-project / knop

Web application framework for Lasso 8 and 9
18 stars 46 forks source link

knop_database -> getrecord does not clear stale lockvalue #53

Closed stevepiercy closed 12 years ago

stevepiercy commented 12 years ago

To repeat this issue, use the Knop 8 demo, login, go to Advanced, select a record, and try to delete it.

When a record is requested and a stale lockvalue exists in the database object, knop_form incorrectly generates a lockvalue instead of a keyvalue. This prevents the record from being saved or deleted.

In addition, when trying to delete a record, the $s_user variable "disappears". An error is returned:

No tag, type or constant was defined under the name string->trace with arguments: array: (-html) at: /index.lasso on line: 115 at position: 13

Line 115: $s_user -> trace(-html);

Then if one refreshes the error page:

No tag, type or constant was defined under the name string->auth. at: /_config/cfg__nav.inc on line: 38 at position: 16

Line38: if: $s_user -> auth;

Inserting this at line 37:

$__html_reply__ = $s_user->isa('string');
abort;

Returns: true

It's as if the knop_user type gets redefined as type string and loses all of its knop_user methods. Now we need to find where that happens while deleting a record with a lock.

In fact, I think I found the problem, in global__config.inc:

test 1

// Configure user
var: 's_user'=(knop_user: -userdb=$d, -userfield='email', -passwordfield='password'),
    's_lang'=null;

$__html_reply__ = $s_user->type;
abort;

session_start: -name='knopdemo';
session_addvar: -name='knopdemo', 's_user', 's_lang';

=> user

test 2

// Configure user
var: 's_user'=(knop_user: -userdb=$d, -userfield='email', -passwordfield='password'),
    's_lang'=null;

session_start: -name='knopdemo';
$__html_reply__ = $s_user->type;
abort;
session_addvar: -name='knopdemo', 's_user', 's_lang';

=> string

That result makes ZERO sense, because this file gets loaded whether the action is a save or delete.

jolle-c commented 12 years ago

Note that the bug only appears if an anonymous user tries to edit a record that was previously locked by a logged in user.

stevepiercy commented 12 years ago

We done dood it! YAY TEAM!