r111112 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111111‎ | r111112 | r111113 >
Date:22:21, 9 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
minor fixes and tweaks
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EPEditAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPDBObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -403,11 +403,11 @@
404404 foreach ( $unknownValues as $name => $value ) {
405405 $this->handleUnknownField( $item, $name, $value );
406406 }
407 -
 407+
408408 $revAction = new EPRevisionAction();
409409 $revAction->setUser( $this->getUser() );
410 - $revAction->setComment( '' ); // TODO
411 - $revAction->setMinor( false ); // TODO
 410+ $revAction->setComment( $this->getRequest()->getText( 'wpSummary' ) );
 411+ $revAction->setMinor( $this->getRequest()->getCheck( 'wpMinoredit' ) );
412412
413413 $success = $item->revisionedSave( $revAction );
414414
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php
@@ -198,6 +198,7 @@
199199 *
200200 * @param array|null $fields
201201 * @param boolean $override
 202+ * @param boolean $skipLoaded
202203 *
203204 * @return Success indicator
204205 */
@@ -213,7 +214,7 @@
214215 if ( $skipLoaded ) {
215216 $loadedFields = array_keys( $this->fields );
216217 $fields = array_filter( $fields, function( $field ) use ( $loadedFields ) {
217 - return !in_array( $loadedFields );
 218+ return !in_array( $field, $loadedFields );
218219 } );
219220 }
220221
@@ -1262,4 +1263,27 @@
12631264 $this->inSummaryMode = $summaryMode;
12641265 }
12651266
 1267+ /**
 1268+ * Return if any fields got changed.
 1269+ *
 1270+ * @since 0.1
 1271+ *
 1272+ * @param EPDBObject $object
 1273+ * @param boolean $excludeSummaryFields When set to true, summary field changes are ignored.
 1274+ *
 1275+ * @return boolean
 1276+ */
 1277+ protected function fieldsChanged( EPDBObject $object, $excludeSummaryFields = false ) {
 1278+ foreach ( $this->fields as $name => $value ) {
 1279+ $excluded = $excludeSummaryFields && in_array( $name, $this->getSummaryFields() );
 1280+
 1281+ if ( !$excluded && $object->getField( $name ) !== $value ) {
 1282+ //q($name, $value, $object->getField( $name ));
 1283+ return true;
 1284+ }
 1285+ }
 1286+
 1287+ return false;
 1288+ }
 1289+
12661290 }
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -131,28 +131,6 @@
132132 }
133133
134134 /**
135 - * Return if any fields got changed.
136 - *
137 - * @since 0.1
138 - *
139 - * @param EPRevisionedObject $revision
140 - * @param boolean $excludeSummaryFields When set to true, summaty field changes are ignored.
141 - *
142 - * @return boolean
143 - */
144 - protected function fieldsChanged( EPRevisionedObject $revision, $excludeSummaryFields = false ) {
145 - foreach ( $this->fields as $name => $value ) {
146 - $excluded = $excludeSummaryFields && in_array( $name, $this->getSummaryFields() );
147 -
148 - if ( !$excluded && $revision->getField( $name ) !== $value ) {
149 - return true;
150 - }
151 - }
152 -
153 - return false;
154 - }
155 -
156 - /**
157135 * (non-PHPdoc)
158136 * @see EPDBObject::saveExisting()
159137 */
@@ -162,11 +140,14 @@
163141 $currentObject = static::selectRow( null, array( 'id' => $this->getId() ) );
164142 static::setReadDb( DB_SLAVE );
165143 }
166 -
167 - $success = parent::saveExisting();
168144
169 - if ( $success && !$this->inSummaryMode ) {
170 - if ( $this->fieldsChanged( $currentObject, true ) ) {
 145+ $success = true;
 146+
 147+ if ( $this->inSummaryMode || $currentObject === false || $this->fieldsChanged( $currentObject, true ) ) {
 148+
 149+ $success = parent::saveExisting();
 150+
 151+ if ( $success && !$this->inSummaryMode ) {
171152 $this->storeRevision( $currentObject );
172153 $this->log( 'update' );
173154 }
@@ -199,7 +180,7 @@
200181 protected function onRemoved() {
201182 $this->storeRevision( $this );
202183 $this->log( 'remove' );
203 - parent::onRemoved( $object );
 184+ parent::onRemoved();
204185 }
205186
206187 public function getIdentifier() {

Status & tagging log