diff options
author | Thomas Citharel <tcit@tcit.fr> | 2015-02-16 15:18:24 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2015-02-16 15:18:24 +0100 |
commit | cdee5e65701330e0b740640f471228d8b9b02a91 (patch) | |
tree | 90d0c1a6099738a3bd063b2cdd3eaa9c4315a4e6 /inc | |
parent | 467503fb2ad5904d9c4ef54bf20218937081f3a2 (diff) | |
download | wallabag-cdee5e65701330e0b740640f471228d8b9b02a91.tar.gz wallabag-cdee5e65701330e0b740640f471228d8b9b02a91.tar.zst wallabag-cdee5e65701330e0b740640f471228d8b9b02a91.zip |
much better fix for #10821.9RC1
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/poche/Database.class.php | 12 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 11 |
2 files changed, 12 insertions, 11 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 210ebb74..65675afe 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -411,12 +411,14 @@ class Database { | |||
411 | 411 | ||
412 | return $count; | 412 | return $count; |
413 | } | 413 | } |
414 | public function getRandomId($row, $user_id) { | 414 | public function getRandomId($user_id) { |
415 | $sql = "SELECT id FROM entries WHERE user_id=? LIMIT 1 OFFSET ? "; | 415 | $random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()'; |
416 | $params = array($user_id, $row); | 416 | $sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1"; |
417 | $query = $this->executeQuery($sql, $params); | 417 | $params = array($user_id); |
418 | $query = $this->executeQuery($sql, $params); | ||
419 | $id = $query->fetchAll(); | ||
418 | 420 | ||
419 | return $query->fetchAll(); | 421 | return $id; |
420 | } | 422 | } |
421 | 423 | ||
422 | 424 | ||
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 4b85d52f..481382ec 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -393,13 +393,12 @@ class Poche | |||
393 | 393 | ||
394 | /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */ | 394 | /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */ |
395 | case 'random': | 395 | case 'random': |
396 | $count = $this->store->getEntriesByViewCount($view, $this->user->getId()); | ||
397 | $id_query = $this->store->getRandomId(rand(1,$count)-1, $this->user->getId()); | ||
398 | $id = $id_query[0]; | ||
399 | Tools::logm('get a random article'); | 396 | Tools::logm('get a random article'); |
400 | Tools::redirect('?view=view&id=' . $id[0]); | 397 | if ($this->store->getRandomId($this->user->getId())) { |
401 | 398 | $id = $this->store->getRandomId($this->user->getId())[0]; | |
402 | //$this->displayView('view', $id); | 399 | Tools::redirect('?view=view&id=' . $id[0]); |
400 | Tools::logm('got the article with id ' . $id[0]); | ||
401 | } | ||
403 | break; | 402 | break; |
404 | default: | 403 | default: |
405 | break; | 404 | break; |