r113165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113164‎ | r113165 | r113166 >
Date:18:25, 6 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on reverting stuff
Modified paths:
  • /trunk/extensions/EducationProgram/includes/DBDataObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourses.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/DBDataObject.php
@@ -610,13 +610,21 @@
611611 * @since 1.20
612612 *
613613 * @param DBDataObject $object
614 - * @param boolean $excludeSummaryFields When set to true, summary field changes are ignored.
 614+ * @param boolean|array $excludeSummaryFields
 615+ * When set to true, summary field changes are ignored.
 616+ * Can also be an array of fields to ignore.
615617 *
616618 * @return boolean
617619 */
618620 protected function fieldsChanged( DBDataObject $object, $excludeSummaryFields = false ) {
 621+ $exclusionFields = array();
 622+
 623+ if ( $excludeSummaryFields !== false ) {
 624+ $exclusionFields = is_array( $excludeSummaryFields ) ? $excludeSummaryFields : $this->table->getSummaryFields();
 625+ }
 626+
619627 foreach ( $this->fields as $name => $value ) {
620 - $excluded = $excludeSummaryFields && in_array( $name, $this->table->getSummaryFields() );
 628+ $excluded = $excludeSummaryFields && in_array( $name, $exclusionFields );
621629
622630 if ( !$excluded && $object->getField( $name ) !== $value ) {
623631 return true;
Index: trunk/extensions/EducationProgram/includes/EPRevisionPager.php
@@ -118,14 +118,16 @@
119119 array( 'revid' => $revision->getId() )
120120 );
121121 }
122 -
123 - $actionLinks[] = $object->getLink(
124 - 'eprestore',
125 - wfMsgHtml( 'ep-revision-restore' ),
126 - array(),
127 - array( 'revid' => $revision->getId() )
128 - );
129 -
 122+
 123+ if ( $this->mOffset !== '' || $this->rowNr != 0 ) {
 124+ $actionLinks[] = $object->getLink(
 125+ 'eprestore',
 126+ wfMsgHtml( 'ep-revision-restore' ),
 127+ array(),
 128+ array( 'revid' => $revision->getId() )
 129+ );
 130+ }
 131+
130132 $html .= ' . . ';
131133 $html .= '(' . $this->getLanguage()->pipeList( $actionLinks ) . ')';
132134 }
Index: trunk/extensions/EducationProgram/includes/EPCourses.php
@@ -132,11 +132,16 @@
133133 */
134134 public function getRevertableFields() {
135135 return array(
 136+ 'org_id',
136137 'name',
 138+ 'mc',
137139 'start',
138140 'end',
139141 'description',
140142 'token',
 143+ 'field',
 144+ 'level',
 145+ 'term'
141146 );
142147 }
143148
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -320,15 +320,19 @@
321321 * @return boolean Success indicator
322322 */
323323 public function restoreToRevision( EPRevision $revison, array $fields = null ) {
324 - $obejct = $revison->getObject();
325 - $fields = is_null( $fields ) ? $obejct->getFieldNames() : $fields;
 324+ $object = $revison->getObject();
 325+ $fields = is_null( $fields ) ? $object->getFieldNames() : $fields;
326326
327327 foreach ( $fields as $fieldName ) {
328 - $this->setField( $fieldName, $obejct->getField( $fieldName ) );
 328+ $this->restoreField( $fieldName, $object );
329329 }
330330
331331 return true;
332332 }
 333+
 334+ protected function restoreField( $fieldName, EPRevisionedObject $object ) {
 335+ $this->setField( $fieldName, $object->getField( $fieldName ) );
 336+ }
333337
334338 /**
335339 * Retore the object to a revision with the provided id.
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -705,5 +705,12 @@
706706
707707 EPUtils::log( $info );
708708 }
709 -
 709+
 710+ protected function restoreField( $fieldName, EPRevisionedObject $object ) {
 711+ if ( $fieldName !== 'org_id'
 712+ || EPOrgs::singleton()->has( array( 'id' => $object->getField( 'org_id' ) ) ) ) {
 713+ parent::restoreField( $fieldName, $object );
 714+ }
 715+ }
 716+
710717 }

Status & tagging log