diff --git a/carddav.php b/carddav.php index a0b87372..b0ca3546 100644 --- a/carddav.php +++ b/carddav.php @@ -206,7 +206,11 @@ public function inputValue(string $id, bool $allowHtml, int $source = rcube_util public function showMessage(string $msg, string $msgType = 'notice', bool $override = false, int $timeout = 0): void { $rcube = rcube::get_instance(); - $rcube->output->show_message($msg, $msgType, null, $override, $timeout); + $output = $rcube->output; + + if ($output instanceof rcmail_output) { + $output->show_message($msg, $msgType, null, $override, $timeout); + } } public function clientCommand(string $method, ...$arguments): void diff --git a/src/Addressbook.php b/src/Addressbook.php index 46833a31..d4cefafd 100644 --- a/src/Addressbook.php +++ b/src/Addressbook.php @@ -448,7 +448,7 @@ public function get_record($id, $assoc = false) * @param ?string $sort_order Sort order */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName -- method name defined by rcube_addressbook class - public function set_sort_order($sort_col, $sort_order = null): void + public function set_sort_order($sort_col = null, $sort_order = null): void { if (isset($sort_col) && key_exists($sort_col, $this->coltypes)) { $this->sort_col = $sort_col; @@ -564,8 +564,8 @@ public function update($id, $save_cols) /** * Mark one or more contact records as deleted * - * @param array $ids Record identifiers - * @param bool $force Remove records irreversible (see self::undelete) + * @param array|string $ids Record identifiers + * @param bool $force Remove records irreversible (see self::undelete) * * @return int|false Number of removed records, False on failure */ @@ -575,6 +575,10 @@ public function delete($ids, $force = true) $logger = $infra->logger(); $db = $infra->db(); + if (is_string($ids)) { + $ids = explode(self::SEPARATOR, $ids); + } + /** @var list $ids */ $deleted = 0; $logger->info("delete([" . implode(",", $ids) . "])"); @@ -691,7 +695,7 @@ public function delete_all($with_groups = false): void * This filter mechanism is applied in addition to other filter mechanisms, see the description of the count() * operation. * - * @param null|0|string $group_id Database identifier of the group. 0/"0"/null to reset the group filter. + * @param null|int|string $group_id Database identifier of the group. 0/"0"/null to reset the group filter. */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName -- method name defined by rcube_addressbook class public function set_group($group_id): void @@ -703,6 +707,7 @@ public function set_group($group_id): void $logger->debug("set_group($group_id)"); if ($group_id) { + $group_id = (string) $group_id; $db = $infra->db(); // check for valid ID with the database - this throws an exception if the group cannot be found $db->lookup(["id" => $group_id, "abook_id" => $this->id], ["id"], "groups"); @@ -994,9 +999,7 @@ public function add_to_group($group_id, $ids): int $davAbook = $this->getCardDavObj(); if (is_string($ids)) { - $ids_string = $ids; - /** @psalm-var list $ids */ - $ids = explode(self::SEPARATOR, $ids_string); + $ids = explode(self::SEPARATOR, $ids); } $db->startTransaction(); diff --git a/src/Config.php b/src/Config.php index 4e6c394d..36d9d807 100644 --- a/src/Config.php +++ b/src/Config.php @@ -84,7 +84,7 @@ public function __construct() $this->admPrefs = new AdminSettings(__DIR__ . '/../config.inc.php', $this->logger, $this->httpLogger); $rcube = rcube::get_instance(); - $this->db = new Database($this->logger, $rcube->db); + $this->db = new Database($this->logger, $rcube->get_dbh()); } public function db(): AbstractDatabase diff --git a/tests/DBInteroperability/DatabaseTest.php b/tests/DBInteroperability/DatabaseTest.php index d86dc1e1..f35c8423 100644 --- a/tests/DBInteroperability/DatabaseTest.php +++ b/tests/DBInteroperability/DatabaseTest.php @@ -497,13 +497,13 @@ public function connectToDbErrFuncProvider(): array public function testExceptionOnFailureToConnectToDb($errFunc): void { if ($GLOBALS["TEST_DBTYPE"] == "sqlite3") { - $dbh = \rcube_db::factory("sqlite:///" . __DIR__ . "/../../testreports/does/not/doesNotExist.db"); + $dbh = \rcube_db::factory("sqlite:////does/not/doesNotExist.db"); $expErrMsg = 'doesNotExist.db'; } elseif ($GLOBALS["TEST_DBTYPE"] == "postgres") { - $dbh = \rcube_db::factory("pgsql://a@unix(" . __DIR__ . "/../../testreports/does/not/doesNotExist)/db"); + $dbh = \rcube_db::factory("pgsql://a@unix(/does/not/doesNotExist)/db"); $expErrMsg = 'doesNotExist'; } elseif ($GLOBALS["TEST_DBTYPE"] == "mysql") { - $dbh = \rcube_db::factory("mysql://a@unix(" . __DIR__ . "/../../testreports/does/not/doesNotExist)/db"); + $dbh = \rcube_db::factory("mysql://a@unix(/does/not/doesNotExist)/db"); $expErrMsg = 'No such file or directory'; } else { $this->fail("unsupported DB");