jfcherng-roundcube / plugin-cloudview

A Roundcube plugin which lets you view documents with cloud viewers.
https://packagist.org/packages/jfcherng-roundcube/cloudview
MIT License
10 stars 5 forks source link

exception when saving settings without enabling any `cloudview_view_button_layouts` #21

Closed Dmitry422 closed 12 months ago

Dmitry422 commented 12 months ago

Plugin drop down when user try change settings and message preview not work after this (RC fall with "Ooops something wrong"). Problem exist only on users who try change plugin settings.

root@mail:~# tail -f /var/log/syslog |grep roundcube
Sep  7 17:46:39 mail roundcube: PHP Fatal error:  Uncaught TypeError: in_array() expects parameter 2 to be array, null given in /var/www/html/webmail/plugins/cloudview/cloudview.php:264
Sep  7 17:46:39 mail roundcube: Stack trace:
Sep  7 17:46:39 mail roundcube: #0 /var/www/html/webmail/plugins/cloudview/cloudview.php(264): in_array()
Sep  7 17:46:39 mail roundcube: #1 /var/www/html/webmail/program/include/rcmail_output_html.php(1484): cloudview->getSettingsForm()
Sep  7 17:46:39 mail roundcube: #2 [internal function]: rcmail_output_html->xml_command()
Sep  7 17:46:39 mail roundcube: #3 /var/www/html/webmail/program/include/rcmail_output_html.php(1322): preg_replace_callback()
Sep  7 17:46:39 mail roundcube: #4 /var/www/html/webmail/program/include/rcmail_output_html.php(825): rcmail_output_html->parse_xml()
Sep  7 17:46:39 mail roundcube: #5 /var/www/html/webmail/program/include/rcmail_output_html.php(654): rcmail_output_html->parse()
Sep  7 17:46:39 mail roundcube: #6 /var/www/html/webmail/plugins/cloudview/cloudview.php(193): rcmail_output_html->send()
Sep  7 17:46:39 mail roundcube: #7 /var/www/html/webmail/program/lib/Roundcube/rcube_plugin_api.php(577): cloudview->settingsAction()
Sep  7 17:46:39 mail roundcube: #8 /var/www/html/webmail/program/include/rcmail.php(257): rcube_plugin_api->exec_action()
Sep  7 17:46:39 mail roundcube: #9 /var/www/html/webmail/index.php(278): rcmail->action_handler()
Sep  7 17:46:39 mail roundcube:  in /var/www/html/webmail/plugins/cloudview/cloudview.php on line 264
Dmitry422 commented 12 months ago

Im sorry problem on Roundcube Webmail 1.7-git

jfcherng commented 12 months ago

RoundCube v1.7 isn't even a beta version yet so I doubt I should fix that. Or is there a related changelog saying there is a breaking change so this is broken?

Fwiw, I can't reproduce this with 1.7-git, which is a very vague description of a version though.

jfcherng commented 12 months ago

What are in your config files? config.inc.php.dist and config.inc.php

Dmitry422 commented 12 months ago

I has some problem with 1.6.2 (LDAP address book problems) so Alec recomend to me use one of last git version with changes that repair my bugs. I use your plugin as I remember from 1.5.3 or from 1.6.0 - its work perfect, and on 1.7 it work fine except case when user try change plugin settings (one of two checkboxes). After user change it - they can't open Plugin setup page, and can't open message text preview and message.

Dmitry422 commented 12 months ago

config.inc.php.dist

use Jfcherng\Roundcube\Plugin\CloudView\Helper\PluginConst;

/**
 * This file is mean to specify all default settings.
 *
 * To use your customized config, you should copied this file into
 * "config.inc.php" and modify config in it.
 */
$config = [];

/**
 * You may want to set this if your Roundcube is set under a subdirectory or behind a reverse proxy.
 * Here's a subdirectory example: https://example.com/roundcube/
 *
 * @type string
 */
$config['custom_site_url'] = '';

/**
 * The default viewer order if the user has not set one.
 *
 * @type string
 *
 * @values PluginConst::VIEWER_GOOGLE_DOCS
 * @values PluginConst::VIEWER_MICROSOFT_OFFICE_WEB
 *
 * For more values, see "Helper/PluginConst.php"
 */
$config['viewer_order'] = implode(',', [
    PluginConst::VIEWER_MICROSOFT_OFFICE_WEB,
    PluginConst::VIEWER_GOOGLE_DOCS,
]);

/**
 * The default view button layouts if the user has not set one.
 *
 * @type int[]
 *
 * @values PluginConst::VIEW_BUTTON_IN_ATTACHMENTSLIST
 * @values PluginConst::VIEW_BUTTON_IN_ATTACHMENTOPTIONSMENU
 *
 * For more values, see "Helper/PluginConst.php"
 */
$config['view_button_layouts'] = [
    PluginConst::VIEW_BUTTON_IN_ATTACHMENTSLIST,
];

////////////////////////////////////
// for localhost dev test purpose //
////////////////////////////////////

$config['is_dev_mode'] = false;
$config['dev_mode_file_base_url'] = 'https://4272fd88.ngrok.io/';
Dmitry422 commented 12 months ago

config.inc.php

use Jfcherng\Roundcube\Plugin\CloudView\Helper\PluginConst;

/**
 * This file is mean to specify all default settings.
 *
 * To use your customized config, you should copied this file into
 * "config.inc.php" and modify config in it.
 */
$config = [];

/**
 * You may want to set this if your Roundcube is set under a subdirectory or behind a reverse proxy.
 * Here's a subdirectory example: https://example.com/roundcube/
 *
 * @type string
 */
$config['custom_site_url'] = '';

/**
 * The default viewer order if the user has not set one.
 *
 * @type string
 *
 * @values PluginConst::VIEWER_GOOGLE_DOCS
 * @values PluginConst::VIEWER_MICROSOFT_OFFICE_WEB
 *
 * For more values, see "Helper/PluginConst.php"
 */
$config['viewer_order'] = implode(',', [
    PluginConst::VIEWER_MICROSOFT_OFFICE_WEB,
    PluginConst::VIEWER_GOOGLE_DOCS,
]);

/**
 * The default view button layouts if the user has not set one.
 *
 * @type int[]
 *
 * @values PluginConst::VIEW_BUTTON_IN_ATTACHMENTSLIST
 * @values PluginConst::VIEW_BUTTON_IN_ATTACHMENTOPTIONSMENU
 *
 * For more values, see "Helper/PluginConst.php"
 */
$config['view_button_layouts'] = [
    PluginConst::VIEW_BUTTON_IN_ATTACHMENTSLIST,
];

////////////////////////////////////
// for localhost dev test purpose //
////////////////////////////////////

$config['is_dev_mode'] = false;
$config['dev_mode_file_base_url'] = 'https://4272fd88.ngrok.io/';
Dmitry422 commented 12 months ago

I remove problem users settings from RC database - so user can work again on their default plugin settings.

Dmitry422 commented 12 months ago

I repeat problem on my current version 1.7. Its begin when I switch off "In the attachments list" in section "Preferred view button layouts"

working setting from users database ...."cloudview";a:3:{s:7:"enabled";b:1;s:19:"view_button_layouts";a:1:{i:0;i:1;}s:12:"viewer_order";s:13:"2,1,3,4,5,6,7";}}"

and broken settings ..."cloudview";a:3:{s:7:"enabled";b:1;s:19:"view_button_layouts";N;s:12:"viewer_order";s:13:"2,1,3,4,5,6,7";}}

jfcherng commented 12 months ago

I repeat problem on my current version 1.7. Its begin when I switch off "In the attachments list" in section "Preferred view button layouts"

working setting from users database ...."cloudview";a:3:{s:7:"enabled";b:1;s:19:"view_button_layouts";a:1:{i:0;i:1;}s:12:"viewer_order";s:13:"2,1,3,4,5,6,7";}}"

and broken settings ..."cloudview";a:3:{s:7:"enabled";b:1;s:19:"view_button_layouts";N;s:12:"viewer_order";s:13:"2,1,3,4,5,6,7";}}

This is it. Thanks. This bug should've been fixed in the latest 0.6.17 release.