| [ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
ChangeLog Prototype; methods for handling changelog
| File Size: | 847 lines (32 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
| __construct($id, $chunk_size = 8192) X-Ref |
| Constructor param: string $id page id param: int $chunk_size maximum block size read from file |
| isCurrentRevision($rev) X-Ref |
| Check whether given revision is the current page param: int $rev timestamp of current page return: bool true if $rev is current revision, otherwise false |
| isLastRevision($rev = null) X-Ref |
| Checks if the revision is last revision param: int $rev revision timestamp return: bool true if $rev is last revision, otherwise false |
| currentRevision() X-Ref |
| Return the current revision identifier The "current" revision means current version of the page or media file. It is either identical with or newer than the "last" revision, that depends on whether the file has modified, created or deleted outside of DokuWiki. The value of identifier can be determined by timestamp as far as the file exists, otherwise it must be assigned larger than any other revisions to keep them sortable. return: int|false revision timestamp |
| lastRevision() X-Ref |
| Return the last revision identifier, date value of the last entry of the changelog return: int|false revision timestamp |
| parseAndCacheLogLine($value) X-Ref |
| Parses a changelog line into its components and save revision info to the cache pool param: string $value changelog line return: array|bool parsed line or false |
| getRevisionInfo($rev, $retrieveCurrentRevInfo = true) X-Ref |
| Get the changelog information for a specific revision (timestamp) Adjacent changelog lines are optimistically parsed and cached to speed up consecutive calls to getRevisionInfo. For large changelog files, only the chunk containing the requested changelog line is read. param: int $rev revision timestamp param: bool $retrieveCurrentRevInfo allows to skip for getting other revision info in the return: bool|array false or array with entries: author: Ben Coburn <btcoburn@silicodon.net> author: Kate Arzamastseva <pshns@ukr.net> |
| getRevisions($first, $num) X-Ref |
| Return a list of page revisions numbers Does not guarantee that the revision exists in the attic, only that a line with the date exists in the changelog. By default the current revision is skipped. The current revision is automatically skipped when the page exists. See $INFO['meta']['last_change'] for the current revision. A negative $first let read the current revision too. For efficiency, the log lines are parsed and cached for later calls to getRevisionInfo. Large changelog files are read backwards in chunks until the requested number of changelog lines are received. param: int $first skip the first n changelog lines param: int $num number of revisions to return return: array with the revision timestamps author: Ben Coburn <btcoburn@silicodon.net> author: Kate Arzamastseva <pshns@ukr.net> |
| getRelativeRevision($rev, $direction) X-Ref |
| Get the nth revision left or right-hand side for a specific page id and revision (timestamp) For large changelog files, only the chunk containing the reference revision $rev is read and sometimes a next chunk. Adjacent changelog lines are optimistically parsed and cached to speed up consecutive calls to getRevisionInfo. param: int $rev revision timestamp used as start date param: int $direction give position of returned revision with respect to $rev; return: bool|int |
| getRevisionsAround($rev1, $rev2, $max = 50) X-Ref |
| Returns revisions around rev1 and rev2 When available it returns $max entries for each revision param: int $rev1 oldest revision timestamp param: int $rev2 newest revision timestamp (0 looks up last revision) param: int $max maximum number of revisions returned return: array with two arrays with revisions surrounding rev1 respectively rev2 |
| getLastRevisionAt($date_at) X-Ref |
| Return an existing revision for a specific date which is the current one or younger or equal then the date param: number $date_at timestamp return: string revision ('' for current) |
| retrieveRevisionsAround($rev, $max) X-Ref |
| Collect the $max revisions near to the timestamp $rev Ideally, half of retrieved timestamps are older than $rev, another half are newer. The returned array $requestedRevs may not contain the reference timestamp $rev when it does not match any revision value recorded in changelog. param: int $rev revision timestamp param: int $max maximum number of revisions to be returned return: bool|array |
| getCurrentRevisionInfo() X-Ref |
| Get the current revision information, considering external edit, create or deletion When the file has not modified since its last revision, the information of the last change that had already recorded in the changelog is returned as current change info. Otherwise, the change information since the last revision caused outside DokuWiki should be returned, which is referred as "external revision". External revisions are persisted to the changelog (and, for non-delete cases, copied to the attic) on first detection so subsequent reads see one canonical entry instead of recomputing a synthesized one. If persistence fails (e.g. the data dir is not writable in the current process context), the in-memory synthesized entry is still returned so the read path keeps working. return: bool|array false when page had never existed or array with entries: author: Satoshi Sahara <sahara.satoshi@gmail.com> |
| addLogEntry(array $info, $timestamp = null) X-Ref |
| Adds an entry to the changelog Locks the local changelog file for the duration of the write so concurrent writers serialize through the same key. Subclasses provide the actual append logic via writeLogEntry() so persistCurrentRevisionInfo() can append while already holding the lock without re-entering it. Best-effort: if writeLogEntry() throws, surfaces the error via msg() and still returns the info dict so existing callers (saveWikiText etc.) keep working. param: array $info Revision info structure of a page or media file param: int $timestamp log line date (optional) return: array revision info of added log line |
| writeLogEntry(array $info, $timestamp = null) X-Ref |
| Append a log entry to the changelog files and update the in-memory cache. The caller MUST hold io_lock() on the local changelog file. The global changelog is a different file with its own lock (acquired briefly here). This is what addLogEntry() runs under its lock, and what persistCurrentRevisionInfo() calls directly while it's holding the same lock for the detect-and-write critical section. param: array $info Revision info structure param: int $timestamp log line date (optional) return: array revision info of added log line |
| persistCurrentRevisionInfo(array $revInfo) X-Ref |
| Persist a synthesized external-revision entry to the changelog Holds the local changelog lock around the entire detect-and-write critical section (idempotency check, attic copy, log append) so it serializes against any other writer that goes through addLogEntry(). The append uses writeLogEntry() to avoid re-entering the lock we already hold. Returns false (without raising) when the attic write fails or another request already persisted the entry. The caller falls back to the in-memory synthesized entry. param: array $revInfo synthesized revision info return: bool true if newly persisted, false otherwise |
| traceCurrentRevision($rev) X-Ref |
| Mechanism to trace no-actual external current revision param: int $rev |