return;
}
+ $this->urls = [];
+ $this->ids = [];
$this->links = FileUtils::readFlatDB($this->datastore, []);
$toremove = array();
foreach ($this->links as $key => &$link) {
if (! $this->loggedIn && $link['private'] != 0) {
// Transition for not upgraded databases.
- $toremove[] = $key;
+ unset($this->links[$key]);
continue;
}
}
$link['shorturl'] = smallHash($link['linkdate']);
}
- }
- // If user is not logged in, filter private links.
- foreach ($toremove as $offset) {
- unset($this->links[$offset]);
+ $this->urls[$link['url']] = $key;
+ $this->ids[$link['id']] = $key;
}
-
- $this->reorder();
}
/**
*/
private function write()
{
+ $this->reorder();
FileUtils::writeFlatDB($this->datastore, $this->links);
}
return $a['created'] < $b['created'] ? 1 * $order : -1 * $order;
});
- $this->urls = array();
- $this->ids = array();
+ $this->urls = [];
+ $this->ids = [];
foreach ($this->links as $key => $link) {
$this->urls[$link['url']] = $key;
$this->ids[$link['id']] = $key;