Page MenuHomePhabricator

Empty reversed diffs
Open, LowPublic

Description

Author: refkeat

Description:
When I try use $diffs->reverse(). I'm getting the empty $editors.

function reverse() {
	$rev = $this;
	$rev->edits = array();
	foreach ( $this->edits as $edit ) {
		$rev->edits[] = $edit->reverse();
	}
	return $rev;
}

I suppose that the problem in rewriting $rev->edits by empty array.

$rev = $this;
$rev->edits = array();

My solution:

function reverse() {
	$edits = array();
	foreach ( $this->edits as $edit ) {
		$edits[] = $edit->reverse();
	}
	$this->edits = $edits;
	
	return $this->edits;
}

Version: 1.22.0
Severity: normal

Details

Reference
bz61306

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:07 AM
bzimport set Reference to bz61306.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Feb 13 2014, 9:31 AM

refkeat wrote:

includes/diff/DairikiDiff.php:683

refkeat wrote:

Also, when we use $diffs->reverse(), TableDiffFormatter doesn't change markers.

Aklapper lowered the priority of this task from Normal to Low.Sun, Aug 11, 10:01 PM
Aklapper updated the task description. (Show Details)
Aklapper removed a subscriber: wikibugs-l-list.

This seems to be about public function reverse() in ./includes/diff/Diff.php. The code nowadays is:

	public function reverse() {
		$rev = $this;
		$rev->edits = [];
		/** @var DiffOp $edit */
		foreach ( $this->edits as $edit ) {
			$rev->edits[] = $edit->reverse();
		}

		return $rev;
	}