New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hierarchical class Ui\(Revisions,Diff), new class File\PageFile #3361
Conversation
Create new Ui\MediaRevisions class created by copying from Ui\Revisons and customize its methods to use media only (methods args are changed). Replace deprecated html_revisions() with Ui\MediaRevisions->show() method.
new Ui\PageRevisons is dedicated for page revisions
define Revisions as abstract, which is inherited by PageRevision and MediaRevision classes. this is simillar to ChangeLog class hierachy.
deprecated functions: media_diff() _media_file_diff() media_file_diff() media_image_diff()
- new item property defined - modified getObjRevInfo(), buildDiffHead()
obsolete buildDiffHead()
5.1 create a page 5.2 external edit 5.3 edit and save 5.4 delete 5.5 create a page, second time 5.6 externally delete 5.7 create a page, third time
inc/common.php
Outdated
@@ -1265,43 +1266,11 @@ function con($pre, $text, $suf, $pretty = false) { | |||
* wiki, triggered in @see saveWikiText() | |||
* | |||
* @param string $id the page ID | |||
* @deprecated YYYY-MM-DD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Date is missing, just today’s date is fine.
Thanks for the further improvements. and thanks for adding the extra unit tests. You delivered a big refactor here. Thank you very much! |
add routine for "save on top of external edit" assertions
@Klap-in , I added routine for "save on top of external edit" assertions. |
Now, I could implemented what I wanted to do. I hope the new concept of File\PageFile class is accepted by core team members. |
For me PageFile in current shape is fine. MediaFile looks a bit different, but I think that can wait until later more attention is given to the media part of (external) diff/revs. |
allow 2nd to last revision check for normal save
@ssahara Thanks for the work! |
My intention is to merge this, but because it is a bit big, I announced it first before doing. |
At ?do=recent also a diff button is shown for just created pages. That scenario is an corner case for the ?do=diff, because we have no older page than the just created page. The diff does not handled this well before and now, and an error occurs. (btw, maybe that diff-button should not be shown, but at least (also for a manual visit) to ?do=diff page for a just created pages no error should occur) old $input = $form->addDropdown('rev2[0]', $l_revisions)->val($l_rev)->addClass('quickselect'); In the merged pull request this problem is solved, because now new git diff
diff --git a/inc/ChangeLog/ChangeLog.php b/inc/ChangeLog/ChangeLog.php
index 84a87e5e2..67b6f4b0d 100644
--- a/inc/ChangeLog/ChangeLog.php
+++ b/inc/ChangeLog/ChangeLog.php
@@ -395,7 +395,12 @@ abstract class ChangeLog
list($revs2, $allrevs, $fp, $lines, $head, $tail) = $this->retrieveRevisionsAround($rev2, $max);
if (empty($revs2)) return array(array(), array());
-
+ if ($rev1 === 0) {
+ //rev1 is 0 if just created
+ $revs2[] = 0;
+ sort($revs2);
+ return array(array_reverse($revs2), array_reverse($revs2));
+ }
//collect revisions around rev1
$index = array_search($rev1, $allrevs);
if ($index === false) {
diff --git a/inc/Ui/PageDiff.php b/inc/Ui/PageDiff.php
index f4099579c..0aa390ef6 100644
--- a/inc/Ui/PageDiff.php
+++ b/inc/Ui/PageDiff.php
@@ -134,6 +134,16 @@ class PageDiff extends Diff
$this->newRevInfo = $changelog->getRevisionInfo($this->newRev);
foreach ([&$this->oldRevInfo, &$this->newRevInfo] as &$revInfo) {
+ if($revInfo === false) {
+ //if just created there is no oldRev
+ $revInfo = [
+ 'current' => false,
+ 'navTitle' => '—',
+ 'text' => '',
+ 'timestamp' => false
+ ];
+ continue;
+ }
// use timestamp and '' properly as $rev for the current file
$isCurrent = $changelog->isCurrentRevision($revInfo['date']);
$revInfo += [
@@ -420,7 +430,6 @@ class PageDiff extends Diff
*/
protected function buildRevisionOptions($side, $revs)
{
- global $lang;
$changelog =& $this->changelog;
$revisions = array();
@@ -429,11 +438,18 @@ class PageDiff extends Diff
foreach ($revs as $rev) {
$info = $changelog->getRevisionInfo($rev);
+ if($info === false) {
+ $info = [
+ 'timestamp' => false,
+ 'user' => '',
+ 'sum' => ''
+ ];
+ }
// revision info may have timestamp key when external edits occurred
$info['timestamp'] = $info['timestamp'] ?? true;
$date = dformat($info['date']);
if ($info['timestamp'] === false) {
- // exteranlly deleted or older file restored
+ // externally deleted or older file restored
$date = preg_replace('/[0-9a-zA-Z]/','_', $date);
}
$revisions[$rev] = array(
|
@Klap-in , |
Moving to Action\Diff does not solve the not-existing timestamp at left side for a diff of a just created page? @ssahara the rev2[] parameter, which is used for navigation via dropdowns at do=diff page get lost of an external deletion revision, because the external deletion revision timestamp is not an actual timestamp in the changelog. So it cannot be found, and there is I think now also no mechanism to catch them and link back to external revision (which used, due to time between the page loads, now a different timestamp… I guess this is the challenge of using current as identifying timestamp. Do you have already a proposal for linking the outdated timestamps to the external deletion revision? In earlier stage I have tested this scenario, I now realize not for the later ones. |
@Klap-in , as you pointed out, It is not possible to catch up non-actual timestamp, i.e. external revision. I understand the both timestamp |
@ssahara the rev2[] is used for the dropdowns on the diff page and the checkboxes on the revisions page. Maybe it is for this case a lot simpler to use revision timestamp 9999999999? There exists always max 1 external deletion revision per page, it is always more recent than latest revision. If no external deletion revision exists it can be ignored. Of course it looks as a bit strange number, but if we can simplify the code needed for tracking an external deletion on page reload, I think using 9999999999 is quite practical. |
@Klap-in , sorry for late response during in my stay in labo experiments during this week. |
This PR is follow-up work of #3198, to improve Ui\Revisions and Ui\Diff classes by making them hierarchical subclasses for page and media. This approach is similar to ChangeLog and likely to name resolver in #3272.