Browse files

Fixed descending sort option. Patch created.

Patch will be removed when a new release is made that
  includes these changes.
  • Loading branch information...
1 parent fbbef15 commit 930ab7396bf486bcb9cbfef808efb02177c458f6 @wizonesolutions committed Oct 20, 2010
Showing with 38 additions and 6 deletions.
  1. +7 −6 MeetupAPIBase.php
  2. +31 −0 meetup_api_sortdesc_fix_20100920.patch
View
13 MeetupAPIBase.php
@@ -237,10 +237,11 @@ protected function initRequest($offset = 0, $request = NULL) {
if (!isset($request)) {
//URL-encode the query
$request_settings = array('key' => $this->apiKey,
- 'page' => $this->pageSize,
- 'offset' => $offset,
- 'desc' => $this->sortDesc,
- );
+ 'page' => $this->pageSize,
+ 'offset' => $offset,
+ 'desc' => $this->sortDesc,
+ );
+ if ($this->sortDesc == NULL) unset($request_settings['desc']); // Don't put desc in the query string at all if it isn't being used; its very presence sorts results descending!
$request = $this->getRequestUrl() . '?' . http_build_query(array_merge($this->query, $request_settings));
}
$this->curl = curl_init($request);
@@ -309,8 +310,8 @@ function getNumPages() {
}
function setSortDesc($sortDesc) {
- if ($sortDesc == TRUE) $this->sortDesc = $sortDesc;
- else return FALSE;
+ if ($sortDesc == TRUE) $this->sortDesc = 'true';
+ else $this->sortDesc = NULL;
}
function getSortDesc() {
View
31 meetup_api_sortdesc_fix_20100920.patch
@@ -0,0 +1,31 @@
+diff --git MeetupAPIBase.php MeetupAPIBase.php
+index 7fed5eb..1915f4f 100644
+--- MeetupAPIBase.php
++++ MeetupAPIBase.php
+@@ -237,10 +237,11 @@ class MeetupAPIBase {
+ if (!isset($request)) {
+ //URL-encode the query
+ $request_settings = array('key' => $this->apiKey,
+- 'page' => $this->pageSize,
+- 'offset' => $offset,
+- 'desc' => $this->sortDesc,
+- );
++ 'page' => $this->pageSize,
++ 'offset' => $offset,
++ 'desc' => $this->sortDesc,
++ );
++ if ($this->sortDesc == NULL) unset($request_settings['desc']); // Don't put desc in the query string at all if it isn't being used; its very presence sorts results descending!
+ $request = $this->getRequestUrl() . '?' . http_build_query(array_merge($this->query, $request_settings));
+ }
+ $this->curl = curl_init($request);
+@@ -309,8 +310,8 @@ class MeetupAPIBase {
+ }
+
+ function setSortDesc($sortDesc) {
+- if ($sortDesc == TRUE) $this->sortDesc = $sortDesc;
+- else return FALSE;
++ if ($sortDesc == TRUE) $this->sortDesc = 'true';
++ else $this->sortDesc = NULL;
+ }
+
+ function getSortDesc() {

0 comments on commit 930ab73

Please sign in to comment.