r113705 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113704‎ | r113705 | r113706 >
Date:01:51, 13 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added functionName arg to db functions
Modified paths:
  • /trunk/extensions/EducationProgram/includes/DBDataObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/DBTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/DBTable.php
@@ -103,11 +103,12 @@
104104 * @param array|string|null $fields
105105 * @param array $conditions
106106 * @param array $options
 107+ * @param string|null $functionName
107108 *
108109 * @return array of self
109110 */
110 - public function select( $fields = null, array $conditions = array(), array $options = array() ) {
111 - $result = $this->selectFields( $fields, $conditions, $options, false );
 111+ public function select( $fields = null, array $conditions = array(), array $options = array(), $functionName = null ) {
 112+ $result = $this->selectFields( $fields, $conditions, $options, false, $functionName );
112113
113114 $objects = array();
114115
@@ -136,10 +137,11 @@
137138 * @param array $conditions
138139 * @param array $options
139140 * @param boolean $collapse Set to false to always return each result row as associative array.
 141+ * @param string|null $functionName
140142 *
141143 * @return array of array
142144 */
143 - public function selectFields( $fields = null, array $conditions = array(), array $options = array(), $collapse = true ) {
 145+ public function selectFields( $fields = null, array $conditions = array(), array $options = array(), $collapse = true, $functionName = null ) {
144146 if ( is_null( $fields ) ) {
145147 $fields = array_keys( $this->getFieldTypes() );
146148 }
@@ -152,7 +154,7 @@
153155 $this->getDBTable(),
154156 $this->getPrefixedFields( $fields ),
155157 $this->getPrefixedValues( $conditions ),
156 - __METHOD__,
 158+ is_null( $functionName ) ? __METHOD__ : $functionName,
157159 $options
158160 );
159161
@@ -189,13 +191,14 @@
190192 * @param array|string|null $fields
191193 * @param array $conditions
192194 * @param array $options
 195+ * @param string|null $functionName
193196 *
194197 * @return DBObject|bool False on failure
195198 */
196 - public function selectRow( $fields = null, array $conditions = array(), array $options = array() ) {
 199+ public function selectRow( $fields = null, array $conditions = array(), array $options = array(), $functionName = null ) {
197200 $options['LIMIT'] = 1;
198201
199 - $objects = $this->select( $fields, $conditions, $options );
 202+ $objects = $this->select( $fields, $conditions, $options, $functionName );
200203
201204 return empty( $objects ) ? false : $objects[0];
202205 }
@@ -209,17 +212,18 @@
210213 * @param array $fields
211214 * @param array $conditions
212215 * @param array $options
 216+ * @param string|null $functionName
213217 *
214218 * @return ResultWrapper
215219 */
216 - public function rawSelectRow( array $fields, array $conditions = array(), array $options = array() ) {
 220+ public function rawSelectRow( array $fields, array $conditions = array(), array $options = array(), $functionName = null ) {
217221 $dbr = wfGetDB( $this->getReadDb() );
218222
219223 return $dbr->selectRow(
220224 $this->getDBTable(),
221225 $fields,
222226 $conditions,
223 - __METHOD__,
 227+ is_null( $functionName ) ? __METHOD__ : $functionName,
224228 $options
225229 );
226230 }
@@ -237,13 +241,14 @@
238242 * @param array $conditions
239243 * @param array $options
240244 * @param boolean $collapse Set to false to always return each result row as associative array.
 245+ * @param string|null $functionName
241246 *
242247 * @return mixed|array|bool False on failure
243248 */
244 - public function selectFieldsRow( $fields = null, array $conditions = array(), array $options = array(), $collapse = true ) {
 249+ public function selectFieldsRow( $fields = null, array $conditions = array(), array $options = array(), $collapse = true, $functionName = null ) {
245250 $options['LIMIT'] = 1;
246251
247 - $objects = $this->selectFields( $fields, $conditions, $options, $collapse );
 252+ $objects = $this->selectFields( $fields, $conditions, $options, $collapse, $functionName );
248253
249254 return empty( $objects ) ? false : $objects[0];
250255 }
@@ -292,13 +297,15 @@
293298 * @since 1.20
294299 *
295300 * @param array $conditions
 301+ * @param string|null $functionName
296302 *
297303 * @return boolean Success indicator
298304 */
299 - public function delete( array $conditions ) {
 305+ public function delete( array $conditions, $functionName = null ) {
300306 return wfGetDB( DB_MASTER )->delete(
301307 $this->getDBTable(),
302 - $this->getPrefixedValues( $conditions )
 308+ $this->getPrefixedValues( $conditions ),
 309+ $functionName
303310 );
304311 }
305312
Index: trunk/extensions/EducationProgram/includes/DBDataObject.php
@@ -336,13 +336,15 @@
337337 *
338338 * @since 1.20
339339 *
 340+ * @param string|null $functionName
 341+ *
340342 * @return boolean Success indicator
341343 */
342 - public function save() {
 344+ public function save( $functionName = null ) {
343345 if ( $this->hasIdField() ) {
344 - return $this->saveExisting();
 346+ return $this->saveExisting( $functionName );
345347 } else {
346 - return $this->insert();
 348+ return $this->insert( $functionName );
347349 }
348350 }
349351
@@ -351,16 +353,18 @@
352354 *
353355 * @since 1.20
354356 *
 357+ * @param string|null $functionName
 358+ *
355359 * @return boolean Success indicator
356360 */
357 - protected function saveExisting() {
 361+ protected function saveExisting( $functionName = null ) {
358362 $dbw = wfGetDB( DB_MASTER );
359363
360364 $success = $dbw->update(
361365 $this->table->getDBTable(),
362366 $this->getWriteValues(),
363367 array( $this->table->getPrefixedField( 'id' ) => $this->getId() ),
364 - __METHOD__
 368+ is_null( $functionName ) ? __METHOD__ : $functionName
365369 );
366370
367371 return $success;
@@ -371,16 +375,19 @@
372376 *
373377 * @since 1.20
374378 *
 379+ * @param string|null $functionName
 380+ * @param array|null $options
 381+ *
375382 * @return boolean Success indicator
376383 */
377 - protected function insert() {
 384+ protected function insert( $functionName = null, array $options = null ) {
378385 $dbw = wfGetDB( DB_MASTER );
379386
380387 $result = $dbw->insert(
381388 $this->table->getDBTable(),
382389 $this->getWriteValues(),
383 - __METHOD__,
384 - array( 'IGNORE' )
 390+ is_null( $functionName ) ? __METHOD__ : $functionName,
 391+ is_null( $options ) ? array( 'IGNORE' ) : $options
385392 );
386393
387394 if ( $result ) {
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php
@@ -58,13 +58,13 @@
5959 * (non-PHPdoc)
6060 * @see DBDataObject::save()
6161 */
62 - public function save() {
 62+ public function save( $functionName = null ) {
6363 if ( $this->hasField( $this->table->getIdentifierField() ) && is_null( $this->getTitle() ) ) {
6464 throw new MWException( 'The title for a EPPageObject needs to be valid when saving.' );
6565 return false;
6666 }
6767
68 - return parent::save();
 68+ return parent::save( $functionName );
6969 }
7070
7171 /**
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -98,12 +98,12 @@
9999 * (non-PHPdoc)
100100 * @see DBDataObject::save()
101101 */
102 - public function save() {
 102+ public function save( $functionName = null ) {
103103 if ( $this->hasField( 'name' ) ) {
104104 $this->setField( 'name', $GLOBALS['wgLang']->ucfirst( $this->getField( 'name' ) ) );
105105 }
106106
107 - return parent::save();
 107+ return parent::save( $functionName );
108108 }
109109
110110 /**
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -134,7 +134,7 @@
135135 * (non-PHPdoc)
136136 * @see DBDataObject::saveExisting()
137137 */
138 - protected function saveExisting() {
 138+ protected function saveExisting( $functionName = null ) {
139139 if ( !$this->inSummaryMode ) {
140140 $this->table->setReadDb( DB_MASTER );
141141 $originalObject = $this->table->selectRow( null, array( 'id' => $this->getId() ) );
@@ -148,7 +148,7 @@
149149 $success = true;
150150
151151 if ( $this->inSummaryMode || $this->fieldsChanged( $originalObject, true ) ) {
152 - $success = parent::saveExisting();
 152+ $success = parent::saveExisting( $functionName );
153153
154154 if ( $success && !$this->inSummaryMode ) {
155155 $this->onUpdated( $originalObject );
@@ -175,8 +175,8 @@
176176 * (non-PHPdoc)
177177 * @see DBDataObject::insert()
178178 */
179 - protected function insert() {
180 - $result = parent::insert();
 179+ protected function insert( $functionName = null, array $options = null ) {
 180+ $result = parent::insert( $functionName, $options );
181181
182182 if ( $result ) {
183183 $this->storeRevision( $this );
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -120,8 +120,8 @@
121121 * (non-PHPdoc)
122122 * @see DBDataObject::insert()
123123 */
124 - protected function insert() {
125 - $success = parent::insert();
 124+ protected function insert( $functionName = null, array $options = null ) {
 125+ $success = parent::insert( $functionName, $options );
126126
127127 if ( $success && $this->updateSummaries ) {
128128 EPOrgs::singleton()->updateSummaryFields( array( 'course_count', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
@@ -217,7 +217,7 @@
218218 * (non-PHPdoc)
219219 * @see DBDataObject::save()
220220 */
221 - public function save() {
 221+ public function save( $functionName = null ) {
222222 if ( $this->hasField( 'name' ) ) {
223223 $this->setField( 'name', $GLOBALS['wgLang']->ucfirst( $this->getField( 'name' ) ) );
224224 }
@@ -229,7 +229,7 @@
230230 }
231231 }
232232
233 - return parent::save();
 233+ return parent::save( $functionName );
234234 }
235235
236236 /**

Status & tagging log