Fix missing $db when session write on exit #21

Merged
MrPetovan merged 4 commits from bug/fix-dba-missing-db into master 2017-05-17 14:33:18 +02:00
MrPetovan commented 2017-05-12 06:09:21 +02:00 (Migrated from github.com)

This PR fixes the case where exit; was called before session_write_close(). The DB was already unloaded, and the session handler tried to write the session data to the DB.

Using killme() instead avoid this pitfall.

This PR fixes the case where `exit;` was called before `session_write_close()`. The DB was already unloaded, and the session handler tried to write the session data to the DB. Using `killme()` instead avoid this pitfall.
annando commented 2017-05-12 06:44:13 +02:00 (Migrated from github.com)

Wouldn't it be better to have a _destruct() function where the database connection is closed? (Like we do in the core?)

Wouldn't it be better to have a ```_destruct()``` function where the database connection is closed? (Like we do in the core?)
MrPetovan commented 2017-05-12 16:30:07 +02:00 (Migrated from github.com)

It's already done this way: https://github.com/friendica/dir/blob/master/include/dba.php#L99

However, when simply exiting, the DB object is destroyed before the session handler function are called, which prevents the session to be written. The killme() function ensures that the session is written before the Database object is destroyed.

It's already done this way: https://github.com/friendica/dir/blob/master/include/dba.php#L99 However, when simply exiting, the DB object is destroyed before the session handler function are called, which prevents the session to be written. The `killme()` function ensures that the session is written before the Database object is destroyed.
MrPetovan commented 2017-05-17 13:22:14 +02:00 (Migrated from github.com)

@annando Can you merge this or do you have further comments?

@annando Can you merge this or do you have further comments?
annando commented 2017-05-17 14:32:48 +02:00 (Migrated from github.com)

Sorry, I had forgotten about this.

Sorry, I had forgotten about this.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: friendica/dir#21
No description provided.