Lines Matching +full:- +full:- +full:date

31         $this->cache =& $cache_revinfo;
32 if (!isset($this->cache[$id])) {
33 $this->cache[$id] = [];
36 $this->id = $id;
37 $this->setChunkSize($chunk_size);
56 * Returns path to the global changelog file (the cross-page recent-changes feed)
70 return $rev == $this->currentRevision();
81 return $rev === $this->lastRevision();
97 if (!isset($this->currentRevision)) {
99 $this->getCurrentRevisionInfo();
101 return $this->currentRevision;
105 * Return the last revision identifier, date value of the last entry of the changelog
111 $revs = $this->getRevisions(-1, 1);
125 $info['mode'] = $this->getMode();
126 $this->cache[$this->id][$info['date']] ??= $info;
143 * - date: unix timestamp
144 * - ip: IPv4 address (127.0.0.1)
145 * - type: log line type
146 * - id: page id
147 * - user: user name
148 * - sum: edit summary (or action reason)
149 * - extra: extra data (varies by line type)
150 * - sizechange: change of filesize
152 * - mode: page or media
163 if (!isset($this->currentRevision) && $retrieveCurrentRevInfo) {
164 $this->getCurrentRevisionInfo();
168 if (isset($this->cache[$this->id][$rev])) {
169 return $this->cache[$this->id][$rev];
173 $result = $this->readloglines($rev);
183 $this->parseAndCacheLogLine($line);
186 return $this->cache[$this->id][$rev] ?? false;
193 * only that a line with the date exists in the changelog.
218 $logfile = $this->getChangelogFilename();
229 $fileLastMod = $this->getFilename();
230 if (file_exists($fileLastMod) && $this->isLastRevision(filemtime($fileLastMod))) {
236 if (filesize($logfile) < $this->chunk_size || $this->chunk_size == 0) {
252 $finger = max($tail - $this->chunk_size, 0);
254 $nl = $this->getNewlinepointer($fp, $finger);
258 $finger = max($finger - $this->chunk_size, 0);
266 $read_size = max($tail - $finger, 0); // found chunk size
269 $tmp = @fread($fp, max(min($this->chunk_size, $read_size - $got), 0));
288 $finger = max($tail - $this->chunk_size, 0);
295 $num = max(min(count($lines) - $first, $num), 0);
297 $lines = array_slice($lines, max(count($lines) - $first - $num, 0), $num);
299 $lines = array_slice($lines, 0, max(count($lines) - $first, 0));
301 $lines = array_slice($lines, max(count($lines) - $num, 0));
305 for ($i = count($lines) - 1; $i >= 0; $i--) {
306 $info = $this->parseAndCacheLogLine($lines[$i]);
308 $revs[] = $info['date'];
316 * Get the nth revision left or right-hand side for a specific page id and revision (timestamp)
324 * @param int $rev revision timestamp used as start date
337 //no direction given or last rev, so no follow-up
338 if (!$direction || ($direction > 0 && $this->isCurrentRevision($rev))) {
343 $result = $this->readloglines($rev);
361 $start = $count - 1;
362 $step = -1;
365 $info = $this->parseAndCacheLogLine($lines[$i]);
367 //look for revs older/earlier then reference $rev and select $direction-th one
368 … if (($direction > 0 && $info['date'] > $rev) || ($direction < 0 && $info['date'] < $rev)) {
371 $relativeRev = $info['date'];
377 //true when $rev is found, but not the wanted follow-up.
379 && ($info['date'] == $rev || ($revCounter > 0 && !$relativeRev))
383 [$lines, $head, $tail] = $this->readAdjacentChunk($fp, $head, $tail, $direction);
418 $rev2 = $this->currentRevision();
421 $result2 = $this->retrieveRevisionsAround($rev2, $max);
431 $result1 = $this->retrieveRevisionsAround($rev1, $max);
443 for ($i = count($lines) - 1; $i >= 0; $i--) {
444 $info = $this->parseAndCacheLogLine($lines[$i]);
446 $revs1[] = $info['date'];
455 [$lines, $head, $tail] = $this->readAdjacentChunk($fp, $head, $tail, -1);
461 $revs1 = array_slice($revs1, max($index - (int) ($max / 2), 0), $max);
468 * Return an existing revision for a specific date which is
469 * the current one or younger or equal then the date
476 $fileLastMod = $this->getFilename();
477 … //requested date_at(timestamp) younger or equal then modified_time($this->id) => load current
480 } elseif ($rev = $this->getRelativeRevision($date_at + 1, -1)) {
481 //+1 to get also the requested date revision
499 * - $requestedRevs: array of with $max revision timestamps
500 * - $revs: all parsed revision timestamps
501 * - $fp: file pointer only defined for chuck reading, needs closing.
502 * - $lines: non-parsed changelog lines before the parsed revisions
503 * - $head: position of first read changelog line
504 * - $lastTail: position of end of last read changelog line
514 $result = $this->readloglines($rev);
524 $info = $this->parseAndCacheLogLine($line);
526 $revs[] = $info['date'];
527 if ($info['date'] >= $rev) {
541 [$lines, $head, $tail] = $this->readAdjacentChunk($fp, $head, $tail, 1);
548 count($revs) && !$this->isCurrentRevision($revs[count($revs) - 1])
550 $revs[] = $this->currentRevision;
565 [$lines, $head, $tail] = $this->readAdjacentChunk($fp, $head, $tail, -1);
567 for ($i = count($lines) - 1; $i >= 0; $i--) {
568 $info = $this->parseAndCacheLogLine($lines[$i]);
570 $revs[] = $info['date'];
573 if ($beforeCount > max((int) ($max / 2), $max - $afterCount)) {
579 //keep only non-parsed lines
585 $requestedRevs = array_slice($revs, -$max, $max);
601 * data dir is not writable in the current process context), the in-memory synthesized entry
605 * - date: revision identifier (timestamp or last revision +1)
606 * - ip: IPv4 address (127.0.0.1)
607 * - type: log line type
608 * - id: id of page or media
609 * - user: user name
610 * - sum: edit summary (or action reason)
611 * - extra: extra data (varies by line type)
612 * - sizechange: change of filesize
613 * - timestamp: unix timestamp or false (key set only for external edit occurred)
615 * - mode: page or media
621 if (isset($this->currentRevision)) {
622 return $this->getRevisionInfo($this->currentRevision);
626 $filename = $this->getFilename();
628 $recordedRev = $this->lastRevision(); // false when there is no changelog
632 $this->currentRevision = $recordedRev;
633 return $recordedRev === false ? false : $this->getRevisionInfo($recordedRev);
639 $revInfo = $this->synthesizeExternalDeletion($recordedRev);
642 $this->getRevisionInfo($recordedRev, false)['type'] == DOKU_CHANGE_TYPE_DELETE
645 $revInfo = $this->synthesizeExternalCreate($filename, $fileRev, $recordedRev);
648 $revInfo = $this->synthesizeExternalEdit($filename, $fileRev, $recordedRev);
651 …// null means the external change was a no-op (content unchanged), so keep the recorded revision a…
652 $this->currentRevision = $recordedRev;
653 return $this->getRevisionInfo($recordedRev);
657 $this->persistCurrentRevisionInfo($revInfo);
658 $this->currentRevision = $revInfo['date'];
659 $this->cache[$this->id][$this->currentRevision] = $revInfo;
660 return $this->getRevisionInfo($this->currentRevision);
667 * @param int $recordedRev date of the newest recorded changelog revision
675 if ($this->getRevisionInfo($recordedRev, false)['type'] == DOKU_CHANGE_TYPE_DELETE) {
679 // date the deletion as late as possible: 1 sec before now, or newest revision +1
681 'date' => max($recordedRev + 1, time() - 1),
684 'id' => $this->id,
686 … 'sum' => $lang['deleted'] . ' - ' . $lang['external_edit'] . ' (' . $lang['unknowndate'] . ')',
688 'sizechange' => -$this->lastRevisionSize($recordedRev),
690 'mode' => $this->getMode()
696 * differs from the newest recorded revision, which is a live (non-deleted) page.
700 * @param int $recordedRev date of the newest recorded changelog revision
710 // recorded date and keep that revision.
711 if ($this->currentContentMatchesRevision($recordedRev)) {
722 $msg = "Warning: current file modification time is older than last revision date";
723 … $details = 'File revision: ' . $fileRev . ' ' . dformat($fileRev, "%Y-%m-%d %H:%M:%S") . "\n"
724 … . 'Last revision: ' . $recordedRev . ' ' . dformat($recordedRev, "%Y-%m-%d %H:%M:%S");
731 'date' => $timestamp ?: $recordedRev + 1,
734 'id' => $this->id,
738 'sizechange' => filesize($filename) - $this->lastRevisionSize($recordedRev),
740 'mode' => $this->getMode()
751 …* @param int|false $recordedRev date of the newest recorded changelog revision, or false when none
758 // trust the file mtime as the creation date only when it postdates any prior delete; a
759 // backup restored with an older mtime (cp -p) can't date the creation before the deletion,
760 // so record it just after, with an unknown date.
763 $sum = $lang['created'] . ' - ' . $lang['external_edit']
767 'date' => $timestamp ?: $recordedRev + 1,
770 'id' => $this->id,
776 'mode' => $this->getMode()
786 * the lock without re-entering it.
788 * Best-effort: if writeLogEntry() throws, surfaces the error via msg() and still
792 * @param int $timestamp log line date (optional)
797 $logfile = $this->getChangelogFilename();
800 return $this->writeLogEntry($info, $timestamp);
802 msg($e->getMessage(), -1);
803 $info['mode'] = $this->getMode();
811 * Append a log entry to the local and global changelog and update the in-memory cache.
824 * @param int $timestamp log line date (optional)
833 if (isset($timestamp)) unset($this->cache[$this->id][$info['date']]);
837 // append to local changelog without re-locking (caller holds the lock)
838 $localFile = $this->getChangelogFilename();
849 $this->writeGlobalLogEntry($logline, $info['date'], $external);
851 $this->currentRevision = $info['date'];
852 $info['mode'] = $this->getMode();
853 $this->cache[$this->id][$this->currentRevision] = $info;
858 * Append a log line to the global changelog (the cross-page recent-changes feed).
864 * A detected external edit ($external) is skipped here when its date is older than the
866 * with an old date (issue #4634). Skipping does not lose the entry — writeLogEntry() has
867 * already recorded it in the page's own changelog; it is only kept out of the cross-page
871 * @param int $date revision date of the entry, compared against the feed's last change
874 protected function writeGlobalLogEntry($logline, $date, $external) argument
876 $globalFile = $this->getGlobalChangelogFilename();
878 // skip an out-of-order external edit
882 if ($globalMtime !== false && $date < $globalMtime) return;
889 * Persist a synthesized external-revision entry to the changelog
891 * Holds the local changelog lock around the entire detect-and-write critical section
894 * to avoid re-entering the lock we already hold.
897 * already persisted the entry. The caller falls back to the in-memory synthesized
908 $logfile = $this->getChangelogFilename();
911 // re-read lastRev under the lock — another request may have just persisted
912 $lastRev = $this->lastRevision();
913 if ($lastRev !== false && $lastRev >= $revInfo['date']) {
918 if (!$this->repairExternalMtime($revInfo)) return false;
919 if (!$this->saveExternalAttic($revInfo)) return false;
922 $this->writeLogEntry($revInfo, null, true);
925 // silent fallback to in-memory synthesis
933 * Move the current file's modification time forward to the synthesized revision date when
934 * the detected external change had an unreliable date (its file mtime was older than the
937 * change would be re-detected on every request.
939 * Only relevant for non-delete changes (a deletion has no file); the persist flow calls it
942 * @param array $revInfo synthesized revision info with 'date' and 'timestamp' set
947 // a set timestamp means the date is the real file mtime — nothing to repair
950 $file = $this->getFilename();
953 if (!@touch($file, $revInfo['date'])) return false;
959 * Snapshot the externally-modified content to the attic before the synthesized log entry
960 * is persisted, so the revision stays retrievable. Called only for non-delete changes.
965 * @param array $revInfo synthesized revision info with 'date' set
966 * @return bool true on success or no-op, false to abort persistence
980 return io_getSizeFile($this->getFilename($recordedRev));
984 * Whether the current item file's content is byte-identical to the stored content
997 * Mechanism to trace no-actual external current revision
1002 if ($rev > $this->lastRevision()) {
1003 $rev = $this->currentRevision();