From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/changelog.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 8c14f21b0..e2826e4b3 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -725,8 +725,10 @@ abstract class ChangeLog { * If file larger than $chuncksize, only chunck is read that could contain $rev. * * @param int $rev revision timestamp - * @return array(fp, array(changeloglines), $head, $tail, $eof)|bool - * returns false when not succeed. fp only defined for chuck reading, needs closing. + * @return array|false + * if success returns array(fp, array(changeloglines), $head, $tail, $eof) + * where fp only defined for chuck reading, needs closing. + * otherwise false */ protected function readloglines($rev) { $file = $this->getChangelogFilename(); -- cgit v1.2.3 From fed2ee900d012e5ebccad2796d0850034ac7729b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 6 Nov 2014 21:12:10 +0100 Subject: Make addLogEntry independent of global var INFO In stead use the type as provided to the function. Fixes #920 --- inc/changelog.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 6af336fc2..9642cf9cd 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -83,17 +83,19 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr 'extra' => str_replace($strip, '', $extra) ); + $wasCreated = ($type===DOKU_CHANGE_TYPE_CREATE); + $wasReverted = ($type===DOKU_CHANGE_TYPE_REVERT); // update metadata if (!$wasRemoved) { $oldmeta = p_read_metadata($id); $meta = array(); - if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])){ // newly created + if ($wasCreated && empty($oldmeta['persistent']['date']['created'])){ // newly created $meta['date']['created'] = $created; if ($user){ $meta['creator'] = $INFO['userinfo']['name']; $meta['user'] = $user; } - } elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored + } elseif (($wasCreated || $wasReverted) && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored $meta['date']['created'] = $oldmeta['persistent']['date']['created']; $meta['date']['modified'] = $created; // use the files ctime here $meta['creator'] = $oldmeta['persistent']['creator']; -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/changelog.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index c2d3cb489..d1ef7973e 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -351,7 +351,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ // check existance if($flags & RECENTS_SKIP_DELETED){ $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); - if(!@file_exists($fn)) return false; + if(!file_exists($fn)) return false; } return $recent; @@ -498,14 +498,14 @@ abstract class ChangeLog { if($first < 0) { $first = 0; - } else if(@file_exists($this->getFilename())) { + } else if(file_exists($this->getFilename())) { // skip current revision if the page exists $first = max($first + 1, 0); } $file = $this->getChangelogFilename(); - if(!@file_exists($file)) { + if(!file_exists($file)) { return $revs; } if(filesize($file) < $this->chunk_size || $this->chunk_size == 0) { @@ -735,7 +735,7 @@ abstract class ChangeLog { protected function readloglines($rev) { $file = $this->getChangelogFilename(); - if(!@file_exists($file)) { + if(!file_exists($file)) { return false; } -- cgit v1.2.3 From 7de86af9758e71d251fad91063035a459d83d2eb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 30 Jun 2015 23:07:10 +0200 Subject: phpdocs, reformatting --- inc/changelog.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index d1ef7973e..f4731021c 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -849,18 +849,17 @@ abstract class ChangeLog { public function isCurrentRevision($rev) { return $rev == @filemtime($this->getFilename()); } - + /** - * Return an existing revision for a specific date which is + * Return an existing revision for a specific date which is * the current one or younger or equal then the date * - * @param string $id * @param number $date_at timestamp * @return string revision ('' for current) */ function getLastRevisionAt($date_at){ //requested date_at(timestamp) younger or equal then modified_time($this->id) => load current - if($date_at >= @filemtime($this->getFilename())) { + if($date_at >= @filemtime($this->getFilename())) { return ''; } else if ($rev = $this->getRelativeRevision($date_at+1, -1)) { //+1 to get also the requested date revision return $rev; @@ -1049,6 +1048,12 @@ class MediaChangelog extends ChangeLog { * * @author Ben Coburn * @author Kate Arzamastseva + * + * @param string $id + * @param int $rev + * @param int $chunk_size + * @param bool $media + * @return array|bool */ function getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false) { dbg_deprecated('class PageChangeLog or class MediaChangelog'); -- cgit v1.2.3