X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLinkDB.php;h=eace625eed517f840fbd8cdd65516c66b4d7d966;hb=9ec0a61156192484ca90a8dc88b7c23b26129755;hp=22c1f0ab5321b3ccb274931637ba642357ddecb6;hpb=e8cef3ac43d5a50485c72ea2e8267e92b00be609;p=github%2Fshaarli%2FShaarli.git diff --git a/application/LinkDB.php b/application/LinkDB.php index 22c1f0ab..eace625e 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -289,13 +289,15 @@ You use the community supported version of the original Shaarli project, by Seba 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; } @@ -329,14 +331,10 @@ You use the community supported version of the original Shaarli project, by Seba } $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(); } /** @@ -346,6 +344,7 @@ You use the community supported version of the original Shaarli project, by Seba */ private function write() { + $this->reorder(); FileUtils::writeFlatDB($this->datastore, $this->links); } @@ -528,8 +527,8 @@ You use the community supported version of the original Shaarli project, by Seba 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;