X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FHistory.php;h=5e3b1b72d475ce97fd05692bec751e661b13e182;hb=66e74d50d38a6fea8fc904a1746157633de7cc65;hp=f93b03568235c1f71ecc7d9d86b21e0a56fab34b;hpb=b8fcb7d4403a344158ab5d2c8979bdd002e6001d;p=github%2Fshaarli%2FShaarli.git diff --git a/application/History.php b/application/History.php index f93b0356..5e3b1b72 100644 --- a/application/History.php +++ b/application/History.php @@ -16,6 +16,7 @@ * - UPDATED: link updated * - DELETED: link deleted * - SETTINGS: the settings have been updated through the UI. + * - IMPORT: bulk links import * * Note: new events are put at the beginning of the file and history array. */ @@ -41,6 +42,11 @@ class History */ const SETTINGS = 'SETTINGS'; + /** + * @var string Action key: a bulk import has been processed. + */ + const IMPORT = 'IMPORT'; + /** * @var string History file path. */ @@ -121,6 +127,16 @@ class History $this->addEvent(self::SETTINGS); } + /** + * Add Event: bulk import. + * + * Note: we don't store links add/update one by one since it can have a huge impact on performances. + */ + public function importLinks() + { + $this->addEvent(self::IMPORT); + } + /** * Save a new event and write it in the history file. * @@ -135,7 +151,7 @@ class History $item = [ 'event' => $status, - 'datetime' => (new DateTime())->format(DateTime::ATOM), + 'datetime' => new DateTime(), 'id' => $id !== null ? $id : '', ]; $this->history = array_merge([$item], $this->history); @@ -177,7 +193,7 @@ class History { $comparaison = new DateTime('-'. $this->retentionTime . ' seconds'); foreach ($this->history as $key => $value) { - if (DateTime::createFromFormat(DateTime::ATOM, $value['datetime']) < $comparaison) { + if ($value['datetime'] < $comparaison) { unset($this->history[$key]); } }