Skip to content

Commit

Permalink
Merge branch 'release/3.3.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Nov 9, 2023
2 parents 8927e42 + 0485e1a commit 5c7db61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 3.3.5 - 2023-11-09
### Fixed
- Temporary fix for incomplete pagination on redirects ([#85](https://github.com/studioespresso/craft-seo-fields/pull/85))


## 3.3.4 - 2023-10-14
### Fixed
- Fixed an an error where deleted sections were still shown in the sitemap settings ([#82](https://github.com/studioespresso/craft-seo-fields/issues/82))
- Fixed an error where deleted sections were still shown in the sitemap settings ([#82](https://github.com/studioespresso/craft-seo-fields/issues/82))


## 3.3.3 - 2023-09-18
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "studioespresso/craft-seo-fields",
"description": "Fields for your SEO & OG meta data",
"type": "craft-plugin",
"version": "3.3.4",
"version": "3.3.5",
"keywords": [
"craft",
"cms",
Expand Down
16 changes: 8 additions & 8 deletions src/controllers/CpApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public function actionRedirects()
$page = $this->request->getQueryParam('page', 1);
list($key, $direction) = explode("|", $sort);

$total = RedirectRecord::find()->count();
$limit = 20;

$query = RedirectRecord::find();
Expand All @@ -120,10 +119,6 @@ public function actionRedirects()
"redirect LIKE '%{$search}%'",
]);
}
if ($total > $limit) {
$query->offset($page * 10);
$query->limit($limit);
}
$query->orderBy($key . " " . $direction);
$rows = [];

Expand Down Expand Up @@ -154,8 +149,13 @@ public function actionRedirects()
}
$nextPageUrl = self::REDIRECT_BASE;
$prevPageUrl = self::REDIRECT_BASE;
$lastPage = (int)ceil($total / $limit);
$to = $page === $lastPage ? $total : ($total < $limit ? $total : ($page * $limit));

$from = ($page - 1) * $limit + 1;
$total = count($rows);
$lastPage = (int) ceil($total / $limit);
$to = $page === $lastPage ? $total : ($page * $limit);

$rows = array_slice($rows, $from - 1, $limit);

return $this->asJson([
'pagination' => [
Expand All @@ -165,7 +165,7 @@ public function actionRedirects()
'last_page' => (int)$lastPage,
'next_page_url' => $nextPageUrl,
'prev_page_url' => $prevPageUrl,
'from' => (int)(($page * $limit) - $limit) + 1,
'from' => (int)$from,
'to' => (int)$to,
],
'data' => $rows,
Expand Down

0 comments on commit 5c7db61

Please sign in to comment.