mstilkerich / rcmcarddav
Showing 1 of 1 files from the diff.

@@ -61,7 +61,7 @@
Loading
61 61
    /** @var string $id database ID of the addressbook */
62 62
    private $id;
63 63
64 -
    /** @var DbAndCondition[] An additional filter to limit contact searches */
64 +
    /** @var list<DbAndCondition> An additional filter to limit contact searches */
65 65
    private $filter = [];
66 66
67 67
    /** @var string[] $requiredProps A list of addressobject fields that must not be empty, otherwise the addressobject
@@ -1195,16 +1195,23 @@
Loading
1195 1195
        }
1196 1196
1197 1197
        $this->logger->debug("listRecordsReadDB $dbattr [$firstrow, $numrows] ORD($sort_column)");
1198 -
        /** @var list<array{id: numeric-string, name: string, vcard?: string} & array<string,?string>> $contacts */
1199 -
        $contacts = $this->db->get(
1200 -
            $this->currentFilterConditions(),
1201 -
            "id,name,$dbattr",
1202 -
            'contacts',
1203 -
            [
1204 -
                'limit' => [ $firstrow, $numrows ],
1205 -
                'order' => [ $sort_column ]
1206 -
            ]
1207 -
        );
1198 +
1199 +
        $conditions = $this->currentFilterConditions();
1200 +
1201 +
        if (isset($conditions)) {
1202 +
            /** @var list<array{id: numeric-string, name: string, vcard?: string} & array<string,?string>> $contacts */
1203 +
            $contacts = $this->db->get(
1204 +
                $conditions,
1205 +
                "id,name,$dbattr",
1206 +
                'contacts',
1207 +
                [
1208 +
                    'limit' => [ $firstrow, $numrows ],
1209 +
                    'order' => [ $sort_column ]
1210 +
                ]
1211 +
            );
1212 +
        } else {
1213 +
            $contacts = [];
1214 +
        }
1208 1215
1209 1216
        // FIXME ORDER BY (CASE WHEN showas='COMPANY' THEN organization ELSE " . $sort_column . " END)
1210 1217
@@ -1355,14 +1362,14 @@
Loading
1355 1362
    private function doCount(): int
1356 1363
    {
1357 1364
        if ($this->total_cards < 0) {
1358 -
            [$result] = $this->db->get(
1359 -
                $this->currentFilterConditions(),
1360 -
                '*',
1361 -
                'contacts',
1362 -
                [ 'count' => true ]
1363 -
            );
1365 +
            $conditions = $this->currentFilterConditions();
1364 1366
1365 -
            $this->total_cards = intval($result['*']);
1367 +
            if (isset($conditions)) {
1368 +
                [$result] = $this->db->get($conditions, '*', 'contacts', [ 'count' => true ]);
1369 +
                $this->total_cards = intval($result['*']);
1370 +
            } else {
1371 +
                $this->total_cards = 0;
1372 +
            }
1366 1373
        }
1367 1374
1368 1375
        return $this->total_cards;
@@ -1504,9 +1511,9 @@
Loading
1504 1511
     *   - A search filter set by roundcube ($this->filter)
1505 1512
     *   - A currenty selected group ($this->group_id)
1506 1513
     *
1507 -
     * @return DbAndCondition[]
1514 +
     * @return ?list<DbAndCondition> Null if the current filter conditions result in an empty contact result.
1508 1515
     */
1509 -
    private function currentFilterConditions(): array
1516 +
    private function currentFilterConditions(): ?array
1510 1517
    {
1511 1518
        $conditions = $this->filter;
1512 1519
        $conditions[] = new DbAndCondition(new DbOrCondition("abook_id", $this->id));
@@ -1522,7 +1529,12 @@
Loading
1522 1529
                $this->db->get(['group_id' => (string) $this->group_id], 'contact_id', 'group_user'),
1523 1530
                'contact_id'
1524 1531
            );
1525 -
            $conditions[] = new DbAndCondition(new DbOrCondition("id", $contactsInGroup));
1532 +
1533 +
            if (empty($contactsInGroup)) {
1534 +
                $conditions = null;
1535 +
            } else {
1536 +
                $conditions[] = new DbAndCondition(new DbOrCondition("id", $contactsInGroup));
1537 +
            }
1526 1538
        }
1527 1539
1528 1540
        return $conditions;
Files Complexity Coverage
src 485 45.70%
carddav.php 181 5.72%
Project Totals (10 files) 666 35.26%
RCMCardDAV database interoperability test coverage
Build #472932421 -
dbinterop
RCMCardDAV unit test coverage
Build #472932421 -
unittests

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading