From cf00041c08ee3d330a871c2b4558000bb94f2694 Mon Sep 17 00:00:00 2001 From: Anton Andersen Date: Mon, 18 Mar 2013 18:48:37 +0400 Subject: [PATCH 1/4] Fix: multiple using of getPage overwites cache The getPage's cache becomes overwritten while using [!getPage&cache=`1` ... ] two or more times on a same page. Thus we can't use two or more calls to getPage to show different content (eg. from getResources with different params). Signed-off-by: Anton Andersen --- core/components/getpage/snippet.getpage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/components/getpage/snippet.getpage.php b/core/components/getpage/snippet.getpage.php index 6e7c7cc..53dd167 100644 --- a/core/components/getpage/snippet.getpage.php +++ b/core/components/getpage/snippet.getpage.php @@ -40,7 +40,7 @@ } if ($properties['cache']) { - $properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters())); + $properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters() . http_build_query($scriptProperties))); $properties['cacheOptions'] = array( xPDO::OPT_CACHE_KEY => $properties[xPDO::OPT_CACHE_KEY], xPDO::OPT_CACHE_HANDLER => $properties[xPDO::OPT_CACHE_HANDLER], @@ -91,7 +91,7 @@ $qs[$properties['pageVarKey']] = $properties['page']; } } - + $properties['firstItem'] = $properties['offset'] + 1; $properties['lastItem'] = ($properties['offset'] + $properties['limit']) < $totalSet ? ($properties['offset'] + $properties['limit']) : $totalSet; From 8c14cc2534b3653a6f65df01baff884796539471 Mon Sep 17 00:00:00 2001 From: Anton Andersen Date: Mon, 18 Mar 2013 18:56:55 +0400 Subject: [PATCH 2/4] Fix for previous commit. (: Signed-off-by: Anton Andersen --- core/components/getpage/snippet.getpage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/getpage/snippet.getpage.php b/core/components/getpage/snippet.getpage.php index 53dd167..5d2f949 100644 --- a/core/components/getpage/snippet.getpage.php +++ b/core/components/getpage/snippet.getpage.php @@ -40,7 +40,7 @@ } if ($properties['cache']) { - $properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters() . http_build_query($scriptProperties))); + $properties['cachePageKey'] = $modx->resource->getCacheKey() . '/' . $properties['page'] . '/' . md5(http_build_query($modx->request->getParameters()) . http_build_query($scriptProperties)); $properties['cacheOptions'] = array( xPDO::OPT_CACHE_KEY => $properties[xPDO::OPT_CACHE_KEY], xPDO::OPT_CACHE_HANDLER => $properties[xPDO::OPT_CACHE_HANDLER], From d754ecc33f4e0bca4d125aac9ef2a25d5f9a21e9 Mon Sep 17 00:00:00 2001 From: Jan Peca Date: Wed, 12 Mar 2014 20:59:27 +0100 Subject: [PATCH 3/4] Cache total results number into correct variable name --- core/components/getpage/snippet.getpage.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/components/getpage/snippet.getpage.php b/core/components/getpage/snippet.getpage.php index 6e7c7cc..6311711 100644 --- a/core/components/getpage/snippet.getpage.php +++ b/core/components/getpage/snippet.getpage.php @@ -15,7 +15,7 @@ } $properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) : 0; $properties['totalVar'] = empty($totalVar) ? "total" : $totalVar; -$properties['total'] = !empty($properties['total']) && $total = intval($properties['total']) ? $total : 0; +$properties[$properties['totalVar']] = !empty($properties[$properties['totalVar']]) && $total = intval($properties[$properties['totalVar']]) ? $total : 0; $properties['pageOneLimit'] = (!empty($pageOneLimit) && $pageOneLimit = intval($pageOneLimit)) ? $pageOneLimit : $properties['limit']; $properties['actualLimit'] = $properties['limit']; $properties['pageLimit'] = isset($pageLimit) && is_numeric($pageLimit) ? intval($pageLimit) : 5; @@ -71,18 +71,18 @@ $properties['qs'] =& $qs; $totalSet = $modx->getPlaceholder($properties['totalVar']); - $properties['total'] = (($totalSet = intval($totalSet)) ? $totalSet : $properties['total']); - if (!empty($properties['total']) && !empty($properties['actualLimit'])) { + $properties[$properties['totalVar']] = (($totalSet = intval($totalSet)) ? $totalSet : $properties[$properties['totalVar']]); + if (!empty($properties[$properties['totalVar']]) && !empty($properties['actualLimit'])) { if ($properties['pageOneLimit'] !== $properties['actualLimit']) { - $adjustedTotal = $properties['total'] - $properties['pageOneLimit']; + $adjustedTotal = $properties[$properties['totalVar']] - $properties['pageOneLimit']; $properties['pageCount'] = $adjustedTotal > 0 ? ceil($adjustedTotal / $properties['actualLimit']) + 1 : 1; } else { - $properties['pageCount'] = ceil($properties['total'] / $properties['actualLimit']); + $properties['pageCount'] = ceil($properties[$properties['totalVar']] / $properties['actualLimit']); } } else { $properties['pageCount'] = 1; } - if (empty($properties['total']) || empty($properties['actualLimit']) || $properties['total'] <= $properties['actualLimit'] || ($properties['page'] == 1 && $properties['total'] <= $properties['pageOneLimit'])) { + if (empty($properties[$properties['totalVar']]) || empty($properties['actualLimit']) || $properties[$properties['totalVar']] <= $properties['actualLimit'] || ($properties['page'] == 1 && $properties[$properties['totalVar']] <= $properties['pageOneLimit'])) { $properties['page'] = 1; } else { $pageNav = getpage_buildControls($modx, $properties); @@ -110,4 +110,4 @@ $output = ''; } -return $output; +return $output; \ No newline at end of file From ab2d0c93d8693a32cfc970944b3464126b8789cf Mon Sep 17 00:00:00 2001 From: Jason Coward Date: Mon, 24 Mar 2014 22:31:52 -0600 Subject: [PATCH 4/4] Bump version for 1.2.4-pl release --- _build/build.transport.php | 4 ++-- core/components/getpage/docs/changelog.txt | 2 ++ core/components/getpage/docs/readme.txt | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/_build/build.transport.php b/_build/build.transport.php index 12e97aa..2832843 100644 --- a/_build/build.transport.php +++ b/_build/build.transport.php @@ -4,7 +4,7 @@ * * @package getpage * @subpackage build - * @version 1.2.3-pl + * @version 1.2.4-pl * @author Jason Coward */ $mtime = microtime(); @@ -25,7 +25,7 @@ /* package defines */ define('PKG_NAME','getPage'); -define('PKG_VERSION','1.2.3'); +define('PKG_VERSION','1.2.4'); define('PKG_RELEASE','pl'); define('PKG_LNAME',strtolower(PKG_NAME)); diff --git a/core/components/getpage/docs/changelog.txt b/core/components/getpage/docs/changelog.txt index 7ded901..4e034c2 100644 --- a/core/components/getpage/docs/changelog.txt +++ b/core/components/getpage/docs/changelog.txt @@ -1,5 +1,7 @@ Changelog for getPage. +getPage 1.2.4-pl (March 24, 2014) +==================================== - [#19] Add scriptProperties to cachePageKey signature - [#24] Cache total results number into correct variable name diff --git a/core/components/getpage/docs/readme.txt b/core/components/getpage/docs/readme.txt index 3967df0..3f1b7b9 100644 --- a/core/components/getpage/docs/readme.txt +++ b/core/components/getpage/docs/readme.txt @@ -1,12 +1,12 @@ -------------------- Snippet: getPage -------------------- -Version: 1.2.3-pl -Released: June 20, 2012 +Version: 1.2.4-pl +Released: March 24, 2014 Since: March 19, 2010 Author: Jason Coward A generic wrapper snippet for returning paged results and navigation from snippets that return limitable collections. This release requires MODX Revolution 2.1+. Official Documentation: -http://rtfm.modx.com/display/ADDON/getPage \ No newline at end of file +http://rtfm.modx.com/display/ADDON/getPage