https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113705
Revision: 113705
Author: jeroendedauw
Date: 2012-03-13 01:51:46 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
added functionName arg to db functions
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/DBDataObject.php
trunk/extensions/EducationProgram/includes/DBTable.php
trunk/extensions/EducationProgram/includes/EPCourse.php
trunk/extensions/EducationProgram/includes/EPOrg.php
trunk/extensions/EducationProgram/includes/EPPageObject.php
trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
Modified: trunk/extensions/EducationProgram/includes/DBDataObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/DBDataObject.php 2012-03-13
01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/DBDataObject.php 2012-03-13
01:51:46 UTC (rev 113705)
@@ -336,13 +336,15 @@
*
* @since 1.20
*
+ * @param string|null $functionName
+ *
* @return boolean Success indicator
*/
- public function save() {
+ public function save( $functionName = null ) {
if ( $this->hasIdField() ) {
- return $this->saveExisting();
+ return $this->saveExisting( $functionName );
} else {
- return $this->insert();
+ return $this->insert( $functionName );
}
}
@@ -351,16 +353,18 @@
*
* @since 1.20
*
+ * @param string|null $functionName
+ *
* @return boolean Success indicator
*/
- protected function saveExisting() {
+ protected function saveExisting( $functionName = null ) {
$dbw = wfGetDB( DB_MASTER );
$success = $dbw->update(
$this->table->getDBTable(),
$this->getWriteValues(),
array( $this->table->getPrefixedField( 'id' ) =>
$this->getId() ),
- __METHOD__
+ is_null( $functionName ) ? __METHOD__ : $functionName
);
return $success;
@@ -371,16 +375,19 @@
*
* @since 1.20
*
+ * @param string|null $functionName
+ * @param array|null $options
+ *
* @return boolean Success indicator
*/
- protected function insert() {
+ protected function insert( $functionName = null, array $options = null
) {
$dbw = wfGetDB( DB_MASTER );
$result = $dbw->insert(
$this->table->getDBTable(),
$this->getWriteValues(),
- __METHOD__,
- array( 'IGNORE' )
+ is_null( $functionName ) ? __METHOD__ : $functionName,
+ is_null( $options ) ? array( 'IGNORE' ) : $options
);
if ( $result ) {
Modified: trunk/extensions/EducationProgram/includes/DBTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/DBTable.php 2012-03-13
01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/DBTable.php 2012-03-13
01:51:46 UTC (rev 113705)
@@ -103,11 +103,12 @@
* @param array|string|null $fields
* @param array $conditions
* @param array $options
+ * @param string|null $functionName
*
* @return array of self
*/
- public function select( $fields = null, array $conditions = array(),
array $options = array() ) {
- $result = $this->selectFields( $fields, $conditions, $options,
false );
+ public function select( $fields = null, array $conditions = array(),
array $options = array(), $functionName = null ) {
+ $result = $this->selectFields( $fields, $conditions, $options,
false, $functionName );
$objects = array();
@@ -136,10 +137,11 @@
* @param array $conditions
* @param array $options
* @param boolean $collapse Set to false to always return each result
row as associative array.
+ * @param string|null $functionName
*
* @return array of array
*/
- public function selectFields( $fields = null, array $conditions =
array(), array $options = array(), $collapse = true ) {
+ public function selectFields( $fields = null, array $conditions =
array(), array $options = array(), $collapse = true, $functionName = null ) {
if ( is_null( $fields ) ) {
$fields = array_keys( $this->getFieldTypes() );
}
@@ -152,7 +154,7 @@
$this->getDBTable(),
$this->getPrefixedFields( $fields ),
$this->getPrefixedValues( $conditions ),
- __METHOD__,
+ is_null( $functionName ) ? __METHOD__ : $functionName,
$options
);
@@ -189,13 +191,14 @@
* @param array|string|null $fields
* @param array $conditions
* @param array $options
+ * @param string|null $functionName
*
* @return DBObject|bool False on failure
*/
- public function selectRow( $fields = null, array $conditions = array(),
array $options = array() ) {
+ public function selectRow( $fields = null, array $conditions = array(),
array $options = array(), $functionName = null ) {
$options['LIMIT'] = 1;
- $objects = $this->select( $fields, $conditions, $options );
+ $objects = $this->select( $fields, $conditions, $options,
$functionName );
return empty( $objects ) ? false : $objects[0];
}
@@ -209,17 +212,18 @@
* @param array $fields
* @param array $conditions
* @param array $options
+ * @param string|null $functionName
*
* @return ResultWrapper
*/
- public function rawSelectRow( array $fields, array $conditions =
array(), array $options = array() ) {
+ public function rawSelectRow( array $fields, array $conditions =
array(), array $options = array(), $functionName = null ) {
$dbr = wfGetDB( $this->getReadDb() );
return $dbr->selectRow(
$this->getDBTable(),
$fields,
$conditions,
- __METHOD__,
+ is_null( $functionName ) ? __METHOD__ : $functionName,
$options
);
}
@@ -237,13 +241,14 @@
* @param array $conditions
* @param array $options
* @param boolean $collapse Set to false to always return each result
row as associative array.
+ * @param string|null $functionName
*
* @return mixed|array|bool False on failure
*/
- public function selectFieldsRow( $fields = null, array $conditions =
array(), array $options = array(), $collapse = true ) {
+ public function selectFieldsRow( $fields = null, array $conditions =
array(), array $options = array(), $collapse = true, $functionName = null ) {
$options['LIMIT'] = 1;
- $objects = $this->selectFields( $fields, $conditions, $options,
$collapse );
+ $objects = $this->selectFields( $fields, $conditions, $options,
$collapse, $functionName );
return empty( $objects ) ? false : $objects[0];
}
@@ -292,13 +297,15 @@
* @since 1.20
*
* @param array $conditions
+ * @param string|null $functionName
*
* @return boolean Success indicator
*/
- public function delete( array $conditions ) {
+ public function delete( array $conditions, $functionName = null ) {
return wfGetDB( DB_MASTER )->delete(
$this->getDBTable(),
- $this->getPrefixedValues( $conditions )
+ $this->getPrefixedValues( $conditions ),
+ $functionName
);
}
Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php 2012-03-13
01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php 2012-03-13
01:51:46 UTC (rev 113705)
@@ -120,8 +120,8 @@
* (non-PHPdoc)
* @see DBDataObject::insert()
*/
- protected function insert() {
- $success = parent::insert();
+ protected function insert( $functionName = null, array $options = null
) {
+ $success = parent::insert( $functionName, $options );
if ( $success && $this->updateSummaries ) {
EPOrgs::singleton()->updateSummaryFields( array(
'course_count', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
@@ -217,7 +217,7 @@
* (non-PHPdoc)
* @see DBDataObject::save()
*/
- public function save() {
+ public function save( $functionName = null ) {
if ( $this->hasField( 'name' ) ) {
$this->setField( 'name', $GLOBALS['wgLang']->ucfirst(
$this->getField( 'name' ) ) );
}
@@ -229,7 +229,7 @@
}
}
- return parent::save();
+ return parent::save( $functionName );
}
/**
Modified: trunk/extensions/EducationProgram/includes/EPOrg.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrg.php 2012-03-13
01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/EPOrg.php 2012-03-13
01:51:46 UTC (rev 113705)
@@ -98,12 +98,12 @@
* (non-PHPdoc)
* @see DBDataObject::save()
*/
- public function save() {
+ public function save( $functionName = null ) {
if ( $this->hasField( 'name' ) ) {
$this->setField( 'name', $GLOBALS['wgLang']->ucfirst(
$this->getField( 'name' ) ) );
}
- return parent::save();
+ return parent::save( $functionName );
}
/**
Modified: trunk/extensions/EducationProgram/includes/EPPageObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-03-13
01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/EPPageObject.php 2012-03-13
01:51:46 UTC (rev 113705)
@@ -58,13 +58,13 @@
* (non-PHPdoc)
* @see DBDataObject::save()
*/
- public function save() {
+ public function save( $functionName = null ) {
if ( $this->hasField( $this->table->getIdentifierField() ) &&
is_null( $this->getTitle() ) ) {
throw new MWException( 'The title for a EPPageObject
needs to be valid when saving.' );
return false;
}
- return parent::save();
+ return parent::save( $functionName );
}
/**
Modified: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
2012-03-13 01:46:33 UTC (rev 113704)
+++ trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
2012-03-13 01:51:46 UTC (rev 113705)
@@ -134,7 +134,7 @@
* (non-PHPdoc)
* @see DBDataObject::saveExisting()
*/
- protected function saveExisting() {
+ protected function saveExisting( $functionName = null ) {
if ( !$this->inSummaryMode ) {
$this->table->setReadDb( DB_MASTER );
$originalObject = $this->table->selectRow( null, array(
'id' => $this->getId() ) );
@@ -148,7 +148,7 @@
$success = true;
if ( $this->inSummaryMode || $this->fieldsChanged(
$originalObject, true ) ) {
- $success = parent::saveExisting();
+ $success = parent::saveExisting( $functionName );
if ( $success && !$this->inSummaryMode ) {
$this->onUpdated( $originalObject );
@@ -175,8 +175,8 @@
* (non-PHPdoc)
* @see DBDataObject::insert()
*/
- protected function insert() {
- $result = parent::insert();
+ protected function insert( $functionName = null, array $options = null
) {
+ $result = parent::insert( $functionName, $options );
if ( $result ) {
$this->storeRevision( $this );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs