Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -403,11 +403,11 @@ |
404 | 404 | foreach ( $unknownValues as $name => $value ) { |
405 | 405 | $this->handleUnknownField( $item, $name, $value ); |
406 | 406 | } |
407 | | - |
| 407 | + |
408 | 408 | $revAction = new EPRevisionAction(); |
409 | 409 | $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' ) ); |
412 | 412 | |
413 | 413 | $success = $item->revisionedSave( $revAction ); |
414 | 414 | |
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php |
— | — | @@ -198,6 +198,7 @@ |
199 | 199 | * |
200 | 200 | * @param array|null $fields |
201 | 201 | * @param boolean $override |
| 202 | + * @param boolean $skipLoaded |
202 | 203 | * |
203 | 204 | * @return Success indicator |
204 | 205 | */ |
— | — | @@ -213,7 +214,7 @@ |
214 | 215 | if ( $skipLoaded ) { |
215 | 216 | $loadedFields = array_keys( $this->fields ); |
216 | 217 | $fields = array_filter( $fields, function( $field ) use ( $loadedFields ) { |
217 | | - return !in_array( $loadedFields ); |
| 218 | + return !in_array( $field, $loadedFields ); |
218 | 219 | } ); |
219 | 220 | } |
220 | 221 | |
— | — | @@ -1262,4 +1263,27 @@ |
1263 | 1264 | $this->inSummaryMode = $summaryMode; |
1264 | 1265 | } |
1265 | 1266 | |
| 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 | + |
1266 | 1290 | } |
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
— | — | @@ -131,28 +131,6 @@ |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
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 | | - /** |
157 | 135 | * (non-PHPdoc) |
158 | 136 | * @see EPDBObject::saveExisting() |
159 | 137 | */ |
— | — | @@ -162,11 +140,14 @@ |
163 | 141 | $currentObject = static::selectRow( null, array( 'id' => $this->getId() ) ); |
164 | 142 | static::setReadDb( DB_SLAVE ); |
165 | 143 | } |
166 | | - |
167 | | - $success = parent::saveExisting(); |
168 | 144 | |
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 ) { |
171 | 152 | $this->storeRevision( $currentObject ); |
172 | 153 | $this->log( 'update' ); |
173 | 154 | } |
— | — | @@ -199,7 +180,7 @@ |
200 | 181 | protected function onRemoved() { |
201 | 182 | $this->storeRevision( $this ); |
202 | 183 | $this->log( 'remove' ); |
203 | | - parent::onRemoved( $object ); |
| 184 | + parent::onRemoved(); |
204 | 185 | } |
205 | 186 | |
206 | 187 | public function getIdentifier() { |