Skip to content

Commit

Permalink
Bump app to Nextcloud 30
Browse files Browse the repository at this point in the history
Closes #1333

I decided to not cross-check the availability of all all deprecated
things with older majors, so both min and max version are v30 for now.

A list of all things that I've fixed:

* Deprecated SCSS variables updated as documented in the upgrade notes[1].
* Fixed a bunch of query builder deprecations:
  * $qb->resetQueryParts() is deprecated, one should just create a new
    query-builder object. Done that.
  * Calling `$qb->expr()->andX()` (and `orX()`) with no arguments is
    deprecated. Instead, one should list all arguments in an array and
    pass that to the method. Reworked queries where necessary to do so.
* The PHPUnit version I got by running `make test` downloaded a version
  that prohibits non-static data providers. Made all affected data
  providers static.

With that, everything from `make test` passes in a local dev
installation of Nextcloud 30 except for two tests:

    1) OCA\Maps\Controller\PhotosControllerTest::testAddGetPhotos
    Failed asserting that actual size 0 matches expected size 1.

    /home/ma27/Projects/nextcloud/apps/maps/tests/Unit/Controller/PhotosControllerTest.php:206

    2) OCA\Maps\Controller\TracksControllerTest::testAddGetTracks
    Failed asserting that false matches expected true.

    /home/ma27/Projects/nextcloud/apps/maps/tests/Unit/Controller/TracksControllerTest.php:205

Both tests failed on the previous commit already, so I decided to leave
those for now.

[1] https://docs.nextcloud.com/server/latest/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_30.html#front-end-changes

Signed-off-by: Maximilian Bosch <[email protected]>
  • Loading branch information
Ma27 committed Oct 7, 2024
1 parent de4acfa commit 03cc1db
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 63 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependencies>
<php min-version="8.1" max-version="8.3"/>
<lib>exif</lib>
<nextcloud min-version="28" max-version="29"/>
<nextcloud min-version="30" max-version="30"/>
</dependencies>
<repair-steps>
<post-migration>
Expand Down
14 changes: 7 additions & 7 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
margin-left: 56px !important;
padding-top: 5px;
border: 2px solid var(--color-border-dark) !important;
border-bottom-left-radius: var(--border-radius-large) !important;
border-bottom-right-radius: var(--border-radius-large) !important;
border-bottom-left-radius: var(--border-radius-element) !important;
border-bottom-right-radius: var(--border-radius-element) !important;
border-top: 0 !important;
background-color: var(--color-main-background);
}
Expand Down Expand Up @@ -90,7 +90,7 @@
}

td:nth-child(3) {
color: var(--color-text-light);
color: var(--color-main-text);
}

tr:nth-child(odd) {
Expand Down Expand Up @@ -132,7 +132,7 @@
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: none;
border-radius: var(--border-radius);
border-radius: var(--border-radius-small);
}

/* Fix attribution overlapping map on mobile */
Expand Down Expand Up @@ -461,7 +461,7 @@ tr.selected td {
.leaflet-marker-photo-suggestion,
.leaflet-marker-photo,
.leaflet-marker-photo-suggestion-selected {
border-radius: var(--border-radius);
border-radius: var(--border-radius-small);
}

.leaflet-marker-track.track-marker,
Expand All @@ -479,7 +479,7 @@ tr.selected td {
.photo-tooltip {
max-width: 325px;
max-height: 325px;
border-radius: var(--border-radius);
border-radius: var(--border-radius-small);
}

.easy-button-button {
Expand Down Expand Up @@ -575,7 +575,7 @@ tr.selected td {
text-align: center;
}
.tooltip-photo-name {
color: var(--color-text-light);
color: var(--color-main-text);
}
.tooltip-photo-date {
font-weight: bold;
Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private function setAddressCoordinates(float $lat, float $lng, string $adr, stri
$req = $qb->execute();
$result = $req->fetchAll();
$req->closeCursor();
$qb = $qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
if ($result and count($result) > 0) {
$id = $result[0]['id'];
$qb->update('maps_address_geo')
Expand All @@ -702,7 +702,8 @@ private function setAddressCoordinates(float $lat, float $lng, string $adr, stri
]);
$req = $qb->execute();
$id = $qb->getLastInsertId();
}$qb = $qb->resetQueryParts();
}
$qb = $this->dbconnection->getQueryBuilder();
}


Expand Down
14 changes: 7 additions & 7 deletions lib/Service/AddressService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function lookupAddress($adr, $uri): array {
break;
}
$req->closeCursor();
$qb = $this->qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
// if it's still not in the DB, it means the lookup did not happen yet
// so we can schedule it for later
if (!$inDb) {
Expand All @@ -129,7 +129,7 @@ public function lookupAddress($adr, $uri): array {
->set('looked_up', $qb->createNamedParameter($lookedUp, IQueryBuilder::PARAM_BOOL))
->where($this->qb->expr()->eq('id', $this->qb->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
$req = $this->qb->execute();
$qb = $this->qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ private function lookupAddressInternal($adr): array {
$res[2] = true;
}
$req->closeCursor();
$qb = $this->qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();

return $res;
}
Expand Down Expand Up @@ -257,15 +257,15 @@ private function cleanUpDBContactAddresses($vCard, $uri) {
}
}
$req->closeCursor();
$qb = $this->qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();

foreach ($adrIdToDelete as $id) {
$qb->delete('maps_address_geo')
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
}
}

Expand All @@ -276,7 +276,7 @@ public function deleteDBContactAddresses($uri) {
$qb->expr()->eq('object_uri', $qb->createNamedParameter($uri, IQueryBuilder::PARAM_STR))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
}

// schedules the address for an external lookup
Expand All @@ -298,7 +298,7 @@ private function scheduleForLookup($adr, $uri): array {
]);
$req = $this->qb->execute();
$id = $this->qb->getLastInsertId();
$qb = $this->qb->resetQueryParts();
$qb = $this->dbconnection->getQueryBuilder();
if (!$geo[2]) {
$this->jobList->add(LookupMissingGeoJob::class, []);
}
Expand Down
42 changes: 21 additions & 21 deletions lib/Service/DevicesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getDevicesFromDB($userId) {
];
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $devices;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public function getDevicesByTokens(array $tokens) {
}
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $devices;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public function getDevicePointsFromDB($userId, $deviceId, ?int $pruneBefore = 0,
];
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

return array_reverse($points);
}
Expand All @@ -179,18 +179,18 @@ public function getDevicePointsFromDB($userId, $deviceId, ?int $pruneBefore = 0,
public function getDevicePointsByTokens(array $tokens, ?int $pruneBefore = 0, ?int $limit = 10000, ?int $offset = 0) {
$qb = $this->qb;
// get coordinates
$or = $qb->expr()->orX();
$or = [];
foreach ($tokens as $token) {
$and = $qb->expr()->andX();
$and->add($qb->expr()->eq('s.token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$and->add($qb->expr()->lte('p.timestamp', 's.timestamp_to'));
$and->add($qb->expr()->gte('p.timestamp', 's.timestamp_from'));
$or->add($and);
$or[] = $qb->expr()->andX(
$qb->expr()->eq('s.token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR)),
$qb->expr()->lte('p.timestamp', 's.timestamp_to'),
$qb->expr()->gte('p.timestamp', 's.timestamp_from')
);
}
$qb->select('p.id', 'lat', 'lng', 'timestamp', 'altitude', 'accuracy', 'battery')
->from('maps_device_points', 'p')
->innerJoin('p', 'maps_device_shares', 's', $qb->expr()->eq('p.device_id', 's.device_id'))
->where($or);
->where($qb->expr()->orX(...$or));

if (intval($pruneBefore) > 0) {
$qb->andWhere(
Expand Down Expand Up @@ -219,7 +219,7 @@ public function getDevicePointsByTokens(array $tokens, ?int $pruneBefore = 0, ?i
];
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

return array_reverse($points);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public function getDeviceTimePointsFromDb($userId, $deviceId) {
$points[intval($row['timestamp'])] = [floatval($row['lat']), floatval($row['lng'])];
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $points;
}

Expand All @@ -272,7 +272,7 @@ public function getOrCreateDeviceFromDB($userId, $userAgent) {
break;
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

if ($deviceId === null) {
$qb->insert('maps_devices')
Expand All @@ -282,7 +282,7 @@ public function getOrCreateDeviceFromDB($userId, $userAgent) {
]);
$req = $qb->execute();
$deviceId = $qb->getLastInsertId();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}
return $deviceId;
}
Expand All @@ -301,7 +301,7 @@ public function addPointToDB($deviceId, $lat, $lng, $ts, $altitude, $battery, $a
]);
$req = $qb->execute();
$pointId = $qb->getLastInsertId();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $pointId;
}

Expand Down Expand Up @@ -353,7 +353,7 @@ public function getDeviceFromDB($id, $userId) {
break;
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $device;
}

Expand All @@ -370,7 +370,7 @@ public function editDeviceInDB($id, $color, $name) {
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function deleteDeviceFromDB($id) {
Expand All @@ -380,14 +380,14 @@ public function deleteDeviceFromDB($id) {
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

$qb->delete('maps_device_points')
->where(
$qb->expr()->eq('device_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function countPoints($userId, $deviceIdList, $begin, $end) {
Expand Down Expand Up @@ -423,7 +423,7 @@ public function countPoints($userId, $deviceIdList, $begin, $end) {
$count = intval($row['co']);
break;
}
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

return $count;
}
Expand Down Expand Up @@ -538,7 +538,7 @@ private function getAndWriteDevicePoints($devid, $begin, $end, $fd, $nbPoints, $
$gpxText .= ' </trkpt>' . "\n";
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

// write the chunk
fwrite($fd, $gpxText);
Expand Down
18 changes: 9 additions & 9 deletions lib/Service/FavoritesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getFavoritesFromDB($userId, $pruneBefore = 0, $filterCategory =
];
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $favorites;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public function getFavoriteFromDB($id, $userId = null, $category = null, $isDele
break;
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $favorite;
}

Expand All @@ -181,7 +181,7 @@ public function addFavoriteToDB($userId, $name, $lat, $lng, $category, $comment,
]);
$req = $qb->execute();
$favoriteId = $qb->getLastInsertId();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
return $favoriteId;
}

Expand Down Expand Up @@ -232,7 +232,7 @@ public function renameCategoryInDB($userId, $cat, $newName) {
$qb->expr()->eq('category', $qb->createNamedParameter($cat, IQueryBuilder::PARAM_STR))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function editFavoriteInDB($id, $name, $lat, $lng, $category, $comment, $extensions) {
Expand Down Expand Up @@ -262,7 +262,7 @@ public function editFavoriteInDB($id, $name, $lat, $lng, $category, $comment, $e
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function deleteFavoriteFromDB($id) {
Expand All @@ -272,7 +272,7 @@ public function deleteFavoriteFromDB($id) {
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function deleteFavoritesFromDB($ids, $userId) {
Expand All @@ -291,7 +291,7 @@ public function deleteFavoritesFromDB($ids, $userId) {
return;
}
$req = $qb->execute();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
}

public function countFavorites($userId, $categoryList, $begin, $end) {
Expand Down Expand Up @@ -334,7 +334,7 @@ public function countFavorites($userId, $categoryList, $begin, $end) {
break;
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();

return $nbFavorites;
}
Expand Down Expand Up @@ -628,7 +628,7 @@ public function exportFavorites($userId, $fileHandler, $categoryList, $begin, $e
$gpxText .= ' </wpt>' . "\n";
}
$req->closeCursor();
$qb = $qb->resetQueryParts();
$this->qb = $this->dbconnection->getQueryBuilder();
// write the chunk !
fwrite($fileHandler, $gpxText);
$favIndex = $favIndex + $chunkSize;
Expand Down
Loading

0 comments on commit 03cc1db

Please sign in to comment.