This patch fixes a bug where the nextID and prevID variables are not set correctly and point to the incorrect locations. It also avoids two extra queries which improves execution time.
Without this patch the navigation was useless (for instance, comic 5 might have "nextID" as 2).
Version 1.0.6, file ./includes/classes/comicDO.class.php
172c172
< if ($result===false)
---
> if (!$result)
190,204c190,192
< $live = (empty($showNonLive)) ? "AND live='1'" : '';
<
< $result = $this->_db->Execute("SELECT id FROM {$this->DB_PREFIX}comic
< WHERE date <= '$date' $live
< ORDER BY date DESC");
< if ($result===false)
< die("Could not get previous comic ID - ".$this->_db->ErrorMsg());
< else {
< while(!$result->EOF) {
< if ($result->fields[0] == $id) {
< $result->MoveNext();
< } else
< return $result->fields[0];
< }
< }
---
> $ret = $id - 1;
> if($ret == 0) return $id;
> return $ret;
208,222c196,199
< $live = (empty($showNonLive)) ? "AND live='1'" : '';
<
< $result = $this->_db->Execute("SELECT id FROM {$this->DB_PREFIX}comic
< WHERE date >= '$date' $live
< ORDER BY date ASC");
< if ($result===false)
< die("Could not get next comic ID - ".$this->_db->ErrorMsg());
< else {
< while(!$result->EOF) {
< if ((int) $result->fields[0] == (int) $id)
< $result->MoveNext();
< else
< return $result->fields[0];
< }
< }
---
> $ret = $id + 1;
> $latest = $this->getLatestComicId($showNonLive);
> if($ret >= $latest) return $latest;
> return $ret;