https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113608
Revision: 113608
Author: jeroendedauw
Date: 2012-03-12 03:06:31 +0000 (Mon, 12 Mar 2012)
Log Message:
-----------
minor optimization
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/EPIRole.php
trunk/extensions/EducationProgram/includes/EPRoleObject.php
Modified: trunk/extensions/EducationProgram/includes/EPIRole.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPIRole.php 2012-03-12
00:50:12 UTC (rev 113607)
+++ trunk/extensions/EducationProgram/includes/EPIRole.php 2012-03-12
03:06:31 UTC (rev 113608)
@@ -19,11 +19,12 @@
* @since 0.1
*
* @param integer $userId
- * @param null|array|string $fields
+ * @param boolean $load If the object should be loaded from the db if
it already exists
+ * @param null|array|string $fields Fields to load
*
* @return EPIRole
*/
- public static function newFromUserId( $userId, $fields = null );
+ public static function newFromUserId( $userId, $load = false, $fields =
null );
/**
* Create a new role object from a user object.
@@ -31,11 +32,12 @@
* @since 0.1
*
* @param User $user
- * @param null|array|string $fields
+ * @param boolean $load If the object should be loaded from the db if
it already exists
+ * @param null|array|string $fields Fields to load
*
* @return EPIRole
*/
- public static function newFromUser( User $user, $fields = null );
+ public static function newFromUser( User $user, $load = false, $fields
= null );
/**
Modified: trunk/extensions/EducationProgram/includes/EPRoleObject.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRoleObject.php 2012-03-12
00:50:12 UTC (rev 113607)
+++ trunk/extensions/EducationProgram/includes/EPRoleObject.php 2012-03-12
03:06:31 UTC (rev 113608)
@@ -35,11 +35,12 @@
* @since 0.1
*
* @param integer $userId
- * @param null|array|string $fields
- *
+ * @param boolean $load If the object should be loaded from the db if
it already exists
+ * @param null|array|string $fields Fields to load
+ *
* @return EPRoleObject
*/
- public static function newFromUserId( $userId, $fields = null ) {
+ public static function newFromUserId( $userId, $load = false, $fields =
null ) {
$data = array( 'user_id' => $userId );
$map = array(
@@ -52,7 +53,7 @@
$class = $map[get_called_class()];
$table = $class::singleton();
- $userRole = $table->selectRow( $fields, $data );
+ $userRole = $load ? $table->selectRow( $fields, $data ) : false;
if ( $userRole === false ) {
return new static( $table, $data, true );
@@ -69,12 +70,13 @@
* @since 0.1
*
* @param User $user
- * @param null|array|string $fields
- *
+ * @param boolean $load If the object should be loaded from the db if
it already exists
+ * @param null|array|string $fields Fields to load
+ *
* @return EPRoleObject
*/
- public static function newFromUser( User $user, $fields = null ) {
- return static::newFromUserId( $user->getId(), $fields );
+ public static function newFromUser( User $user, $load = false, $fields
= null ) {
+ return static::newFromUserId( $user->getId(), $load, $fields );
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs