Opened 21 months ago
Closed 20 months ago
#1488063 closed Bugs (fixed)
session error still sets task to "mail"
| Reported by: | paullckby | Owned by: | |
|---|---|---|---|
| Priority: | 4 | Milestone: | 0.7-beta |
| Component: | Plugin API | Version: | 0.6-beta |
| Severity: | major | Keywords: | |
| Cc: |
Description
When there is a session error, the task still gets set to "mail" or whatever the task was when the session expired. This causes plugins to be executed as though the user were still logged in.
To reproduce: log in. Delete all Roundcube cookies. Refresh the page and look at the $_SESSION.
Change History (10)
comment:1 Changed 21 months ago by alec
- Milestone changed from later to 0.6-stable
comment:2 Changed 21 months ago by thomasb
comment:3 Changed 21 months ago by paullckby
The gist of the plugin I've got is that it is supposed to run whenever the user is logged in. That is, whenever the user is NOT in the task 'login' or 'logout'.
So I've got in config/main.inc.php this:
$rcmail_config['plugins'] = array('foobar');
Then I have in plugins/foobar/foobar.php this:
<?php
class foobar extends rcube_plugin {
function init() {
$rcmail = rcmail::get_instance();
if ($rcmail->task != 'login' && $rcmail->task != 'logout') {
print_r($_SESSION);
}
}
}
?>
If the user is logged in, I expect to see it print the $_SESSION var, which I use to get the username and password to run in my plugin. If the user is NOT logged in, I expect it to print nothing.
In cases where the user explicitly logs out, the $_SESSION var gets erased and replaced with something that is pretty empty. However in the case of a session error that logs the user out automatically, the $rcmail->task variable is still set to whatever it was before it force logged out the user (e.g. 'mail' or 'settings') and the $_SESSION still indicates that the user is logged in, with all the username and password information still in it.
comment:4 follow-up: ↓ 7 Changed 21 months ago by alec
But what does your plugin? As Thomas said, plugins are initialized before session validity check. Maybe we should provide some global hook which will be executed after the check (ca. line 213 of index.php file).
comment:5 follow-up: ↓ 6 Changed 21 months ago by paullckby
I really feel as though the actions of my plugin are pretty irrelevant to the bigger problem that the task is being set incorrectly. In index.php, line 184, just after it sends a session error notification, it sets the task to 'login', but the plugin is not getting that. It's still getting what it would have been had there not been a session error.
But for the record, the plugin is one that initiates a jabber chat client. The chat client appears on any page that is not login or logout or an ajax call. So when a session error happens, my plugin still gets the wrong task and then you have a login screen with a chat window on it which is wrong.
comment:6 in reply to: ↑ 5 Changed 21 months ago by alec
Replying to paullckby:
In index.php, line 184, just after it sends a session error notification, it sets the task to 'login', but the plugin is not getting that.
It's not getting that, because plugin's init() function is executed before that. Do you read our comments?
comment:7 in reply to: ↑ 4 Changed 21 months ago by alec
Replying to alec:
Maybe we should provide some global hook which will be executed after the check (ca. line 213 of index.php file).
... or maybe a flag which will make that a plugin will be initialized after session check.
comment:8 Changed 21 months ago by alec
- Milestone changed from 0.6-stable to 0.7-beta
comment:9 Changed 21 months ago by alec
- Component changed from Core functionality to Plugin API
comment:10 Changed 20 months ago by alec
- Resolution set to fixed
- Status changed from new to closed
Added 'ready' hook in [37030217]. Use it.

$_SESSION['task'] is irrelevant and only used internally.
Plugins are loaded before session validity is checked and this cannot be changed in general. What plugin hooks are you talking about? Please describe your concrete use case and what is going wrong.