r110594 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110593‎ | r110594 | r110595 >
Date:16:47, 2 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix to revision object and finished up secondary storage for ambassadors
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -82,9 +82,8 @@
8383 *
8484 * @return boolean Success indicator
8585 */
86 - protected function storeRevision( EPRevisionedObject $revision, $isDelete = false ) {
 86+ protected function storeRevision( EPRevision $revision, $isDelete = false ) {
8787 if ( $this->storeRevisions ) {
88 - $revison->setStoreRevisions( false );
8988 return $revison->save();
9089 }
9190
@@ -121,7 +120,7 @@
122121 $revison = static::selectRow( null, array( 'id' => $this->getId() ) );
123122 static::setReadDb( DB_SLAVE );
124123
125 - return EPRevision::newFromObject( $revison, $isDelete );;
 124+ return EPRevision::newFromObject( $revison );
126125 }
127126
128127 /**
@@ -156,7 +155,7 @@
157156 if ( $success && !$this->inSummaryMode ) {
158157 $revision = $this->getCurrentRevision();
159158
160 - if ( $this->fieldsChanged( $revision, true ) ) {
 159+ if ( $this->fieldsChanged( $revision->getObject(), true ) ) {
161160 $this->storeRevision( $revision );
162161 $this->log( 'update' );
163162 }
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -293,7 +293,7 @@
294294 }
295295
296296 if ( count( $currentFields ) > 0 ) {
297 - $currentFields = self::selectFieldsRow( $currentFields, array( 'id' => $this->getId() ) );
 297+ $currentFields = self::selectFieldsRow( $currentFields, array( 'id' => $this->getId() ), array(), array(), false );
298298 }
299299 }
300300
@@ -309,7 +309,24 @@
310310 $field = $ambs === 'oas' ? 'online_ambs' : 'campus_ambs';
311311
312312 if ( array_key_exists( $field, $currentFields ) && $currentFields[$field] !== $this->getField( $field ) ) {
313 - // TODO
 313+ $courseField = $ambs === 'oas' ? 'opc_course_id' : 'cpc_course_id';
 314+ $userField = $ambs === 'oas' ? 'opc_oa_id' : 'cpc_ca_id';
 315+ $table = 'ep_' . $ambs . '_per_course';
 316+
 317+ $dbw = wfGetDB( DB_MASTER );
 318+
 319+ $dbw->delete( $table, array( $courseField => $id ) );
 320+
 321+ $dbw->begin();
 322+
 323+ foreach ( $this->getField( $field ) as $userId ) {
 324+ $dbw->insert( $table, array(
 325+ $courseField => $this->getId(),
 326+ $userField => $userId
 327+ ) );
 328+ }
 329+
 330+ $dbw->commit();
314331 }
315332 }
316333 }

Status & tagging log