MediaWiki r110580 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r110579‎ | r110580 (on ViewVC)‎ | r110581 >
Date:16:05, 2 February 2012
Author:jeroendedauw
Status:deferred
Tags:miscextensions, nodeploy 
Comment:
some method renaming
Modified paths:

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -378,7 +378,7 @@
379379 $this->handleUnknownField( $item, $name, $value );
380380 }
381381
382 - $success = $item->writeToDB();
 382+ $success = $item->save();
383383
384384 if ( $success ) {
385385 return true;
Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -241,7 +241,7 @@
242242
243243 $student->setFields( $fields );
244244
245 - $success = $student->writeToDB();
 245+ $success = $student->save();
246246
247247 if ( $success ) {
248248 $success = $student->associateWithCourses( array( $course ) ) && $success;
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php
@@ -11,9 +11,9 @@
1212 *
1313 * These methods are likely candidates for overriding:
1414 * * getDefaults
15 - * * removeFromDB
16 - * * insertIntoDB
17 - * * updateInDB
 15+ * * remove
 16+ * * insert
 17+ * * saveExisting
1818 * * loadSummaryFields
1919 * * getSummaryFields
2020 *
@@ -24,9 +24,8 @@
2525 * Main instance methods:
2626 * * getField(s)
2727 * * setField(s)
28 - * * writeToDB
29 - * * removeFromDB
30 - * * updateInDB
 28+ * * save
 29+ * * remove
3130 *
3231 * Main static methods:
3332 * * select
@@ -418,11 +417,11 @@
419418 *
420419 * @return boolean Success indicator
421420 */
422 - public function writeToDB() {
 421+ public function save() {
423422 if ( $this->hasIdField() ) {
424 - return $this->updateInDB();
 423+ return $this->saveExisting();
425424 } else {
426 - return $this->insertIntoDB();
 425+ return $this->insert();
427426 }
428427 }
429428
@@ -433,7 +432,7 @@
434433 *
435434 * @return boolean Success indicator
436435 */
437 - protected function updateInDB() {
 436+ protected function saveExisting() {
438437 $dbw = wfGetDB( DB_MASTER );
439438
440439 $success = $dbw->update(
@@ -453,7 +452,7 @@
454453 *
455454 * @return boolean Success indicator
456455 */
457 - protected function insertIntoDB() {
 456+ protected function insert() {
458457 $dbw = wfGetDB( DB_MASTER );
459458
460459 $result = $dbw->insert(
@@ -477,7 +476,7 @@
478477 *
479478 * @return boolean Success indicator
480479 */
481 - public function removeFromDB() {
 480+ public function remove() {
482481 $success = $this->delete( array( 'id' => $this->getId() ) );
483482
484483 if ( $success ) {
@@ -1190,7 +1189,7 @@
11911190 foreach ( self::select( 'id', $conditions ) as /* EPDBObject */ $item ) {
11921191 $item->loadSummaryFields( $summaryFields );
11931192 $item->setSummaryMode( true );
1194 - $item->updateInDB();
 1193+ $item->saveExisting();
11951194 }
11961195
11971196 self::setReadDb( DB_SLAVE );
@@ -1207,7 +1206,7 @@
12081207 $this->updateSummaries = $update;
12091208 }
12101209
1211 - /**
 1210+ /**
12121211 * Sets the value for the @see $updateSummaries field.
12131212 *
12141213 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -165,19 +165,19 @@
166166
167167 /**
168168 * (non-PHPdoc)
169 - * @see EPDBObject::removeFromDB()
 169+ * @see EPDBObject::remove()
170170 */
171 - public function removeFromDB() {
 171+ public function remove() {
172172 $id = $this->getId();
173173 $this->loadFields( array( 'name' ) );
174174
175 - $success = parent::removeFromDB();
 175+ $success = parent::remove();
176176
177177 if ( $success ) {
178178 $success = wfGetDB( DB_MASTER )->delete( 'ep_cas_per_org', array( 'cpo_org_id' => $id ) ) && $success;
179179
180180 foreach ( EPCourse::select( 'id', array( 'org_id' => $id ) ) as /* EPCourse */ $course ) {
181 - $success = $course->removeFromDB() && $success;
 181+ $success = $course->remove() && $success;
182182 }
183183 }
184184
@@ -186,14 +186,14 @@
187187
188188 /**
189189 * (non-PHPdoc)
190 - * @see EPDBObject::writeToDB()
 190+ * @see EPDBObject::save()
191191 */
192 - public function writeToDB() {
 192+ public function save() {
193193 if ( $this->hasField( 'name' ) ) {
194194 $this->setField( 'name', $GLOBALS['wgLang']->ucfirst( $this->getField( 'name' ) ) );
195195 }
196196
197 - return parent::writeToDB();
 197+ return parent::save();
198198 }
199199
200200 /**
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -85,7 +85,7 @@
8686 protected function storeRevision( EPRevisionedObject $revision, $isDelete = false ) {
8787 if ( $this->storeRevisions ) {
8888 $revison->setStoreRevisions( false );
89 - return $revison->writeToDB();
 89+ return $revison->save();
9090 }
9191
9292 return true;
@@ -148,10 +148,10 @@
149149
150150 /**
151151 * (non-PHPdoc)
152 - * @see EPDBObject::updateInDB()
 152+ * @see EPDBObject::saveExisting()
153153 */
154 - protected function updateInDB() {
155 - $success = parent::updateInDB();
 154+ protected function saveExisting() {
 155+ $success = parent::saveExisting();
156156
157157 if ( $success && !$this->inSummaryMode ) {
158158 $revision = $this->getCurrentRevision();
@@ -167,10 +167,10 @@
168168
169169 /**
170170 * (non-PHPdoc)
171 - * @see EPDBObject::insertIntoDB()
 171+ * @see EPDBObject::insert()
172172 */
173 - protected function insertIntoDB() {
174 - $result = parent::insertIntoDB();
 173+ protected function insert() {
 174+ $result = parent::insert();
175175
176176 if ( $result ) {
177177 $this->storeRevision( $this );
@@ -182,10 +182,10 @@
183183
184184 /**
185185 * (non-PHPdoc)
186 - * @see EPDBObject::removeFromDB()
 186+ * @see EPDBObject::remove()
187187 */
188 - public function removeFromDB() {
189 - $success = parent::removeFromDB();
 188+ public function remove() {
 189+ $success = parent::remove();
190190
191191 if ( $success ) {
192192 $this->log( 'remove' );
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -239,10 +239,10 @@
240240
241241 /**
242242 * (non-PHPdoc)
243 - * @see EPDBObject::insertIntoDB()
 243+ * @see EPDBObject::insert()
244244 */
245 - protected function insertIntoDB() {
246 - $success = parent::insertIntoDB();
 245+ protected function insert() {
 246+ $success = parent::insert();
247247
248248 if ( $success && $this->updateSummaries ) {
249249 EPOrg::updateSummaryFields( array( 'courses', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
@@ -253,9 +253,9 @@
254254
255255 /**
256256 * (non-PHPdoc)
257 - * @see EPDBObject::removeFromDB()
 257+ * @see EPDBObject::remove()
258258 */
259 - public function removeFromDB() {
 259+ public function remove() {
260260 $id = $this->getId();
261261
262262 if ( $this->updateSummaries ) {
@@ -263,7 +263,7 @@
264264 $orgId = $this->getField( 'org_id' );
265265 }
266266
267 - $success = parent::removeFromDB();
 267+ $success = parent::remove();
268268
269269 if ( $success && $this->updateSummaries ) {
270270 EPOrg::updateSummaryFields( array( 'courses', 'students', 'active', 'instructors', 'oas', 'cas' ), array( 'id' => $orgId ) );
@@ -280,9 +280,9 @@
281281
282282 /**
283283 * (non-PHPdoc)
284 - * @see EPDBObject::updateInDB()
 284+ * @see EPDBObject::saveExisting()
285285 */
286 - protected function updateInDB() {
 286+ protected function saveExisting() {
287287 if ( $this->updateSummaries ) {
288288 $currentFields = array();
289289
@@ -297,7 +297,7 @@
298298 }
299299 }
300300
301 - $success = parent::updateInDB();
 301+ $success = parent::saveExisting();
302302
303303 if ( $this->updateSummaries && $success ) {
304304 if ( array_key_exists( 'org_id', $currentFields ) && $currentFields['org_id'] !== $this->getField( 'org_id' ) ) {
@@ -319,14 +319,14 @@
320320
321321 /**
322322 * (non-PHPdoc)
323 - * @see EPDBObject::writeToDB()
 323+ * @see EPDBObject::save()
324324 */
325 - public function writeToDB() {
 325+ public function save() {
326326 if ( $this->hasField( 'name' ) ) {
327327 $this->setField( 'name', $GLOBALS['wgLang']->ucfirst( $this->getField( 'name' ) ) );
328328 }
329329
330 - return parent::writeToDB();
 330+ return parent::save();
331331 }
332332
333333 /**
@@ -646,7 +646,7 @@
647647
648648 if ( $save ) {
649649 $this->disableLogging();
650 - $success = $this->writeToDB();
 650+ $success = $this->save();
651651 $this->enableLogging();
652652 }
653653
@@ -699,7 +699,7 @@
700700
701701 if ( $save ) {
702702 $this->disableLogging();
703 - $success = $this->writeToDB();
 703+ $success = $this->save();
704704 $this->enableLogging();
705705 }
706706
Index: trunk/extensions/EducationProgram/api/ApiDeleteEducation.php
@@ -55,11 +55,11 @@
5656 $everythingOk = true;
5757
5858 foreach ( $params['ids'] as $id ) {
59 - // $instance->removeFromDB is used instead of Class::delete,
 59+ // $instance->remove is used instead of Class::delete,
6060 // so that linked data also gets deleted.
6161 $c = self::$typeMap[$params['type']];
6262 $object = new $c( array( 'id' => $id ) );
63 - $everythingOk = $object->removeFromDB() && $everythingOk;
 63+ $everythingOk = $object->remove() && $everythingOk;
6464 }
6565
6666 $this->getResult()->addValue(

Status & tagging log

  • 21:10, 2 February 2012 ^demon (Talk | contribs) changed the status of r110580 [removed: new added: deferred]
  • 17:49, 2 February 2012 MarkAHershberger (Talk | contribs) changed the tags for r110580 [added: miscextensions,nodeploy]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox