mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-27 07:56:20 +00:00
much better fix for #1082
This commit is contained in:
parent
467503fb2a
commit
cdee5e6570
2 changed files with 12 additions and 11 deletions
|
@ -411,12 +411,14 @@ class Database {
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
public function getRandomId($row, $user_id) {
|
public function getRandomId($user_id) {
|
||||||
$sql = "SELECT id FROM entries WHERE user_id=? LIMIT 1 OFFSET ? ";
|
$random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
|
||||||
$params = array($user_id, $row);
|
$sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1";
|
||||||
$query = $this->executeQuery($sql, $params);
|
$params = array($user_id);
|
||||||
|
$query = $this->executeQuery($sql, $params);
|
||||||
|
$id = $query->fetchAll();
|
||||||
|
|
||||||
return $query->fetchAll();
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -393,13 +393,12 @@ class Poche
|
||||||
|
|
||||||
/* 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 */
|
/* 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 */
|
||||||
case 'random':
|
case 'random':
|
||||||
$count = $this->store->getEntriesByViewCount($view, $this->user->getId());
|
|
||||||
$id_query = $this->store->getRandomId(rand(1,$count)-1, $this->user->getId());
|
|
||||||
$id = $id_query[0];
|
|
||||||
Tools::logm('get a random article');
|
Tools::logm('get a random article');
|
||||||
Tools::redirect('?view=view&id=' . $id[0]);
|
if ($this->store->getRandomId($this->user->getId())) {
|
||||||
|
$id = $this->store->getRandomId($this->user->getId())[0];
|
||||||
//$this->displayView('view', $id);
|
Tools::redirect('?view=view&id=' . $id[0]);
|
||||||
|
Tools::logm('got the article with id ' . $id[0]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue