roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.79k stars 1.62k forks source link

Hook "message_send_error": Can't overwrite error message #7914

Closed codegain closed 3 years ago

codegain commented 3 years ago

Hi,

I noticed that if hooking into "message_send_error" and changing the error message in a plugin like

function init() {
    $this->add_hook('message_send_error', array($this, 'message_send_error'));
}

function message_send_error($args) {
    $args['error']['label'] = 'smtpsomeothererror';

    return $args;
}

does not change the displayed error message (it still is "smtperror"). This is because here: https://github.com/roundcube/roundcubemail/blob/5ac44fd4ed0aa32858ef9b151373750ea846f027/program/lib/Roundcube/rcube.php#L1773

The $error is passed to the plugin, but can't be overwritten by the plugin. I temporarily fixed this for me by using 'error' => &$error, but I think there might be a better solution. Other hooks use $plugin = $this->plugins->exec_hook(...) and expect that the arguments will be returned. Maybe this should be implemented here as well?

(Using Roundcube 1.4.11)

alecpl commented 3 years ago

It wasn't intended for this hook, but we can do it. I'd prefer the latter from the proposed solutions. Could you create a pull request?

alecpl commented 3 years ago

Implemented.