r113608 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113607‎ | r113608 | r113609 >
Date:03:06, 12 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
minor optimization
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPIRole.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRoleObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php
@@ -35,11 +35,12 @@
3636 * @since 0.1
3737 *
3838 * @param integer $userId
39 - * @param null|array|string $fields
40 - *
 39+ * @param boolean $load If the object should be loaded from the db if it already exists
 40+ * @param null|array|string $fields Fields to load
 41+ *
4142 * @return EPRoleObject
4243 */
43 - public static function newFromUserId( $userId, $fields = null ) {
 44+ public static function newFromUserId( $userId, $load = false, $fields = null ) {
4445 $data = array( 'user_id' => $userId );
4546
4647 $map = array(
@@ -52,7 +53,7 @@
5354 $class = $map[get_called_class()];
5455 $table = $class::singleton();
5556
56 - $userRole = $table->selectRow( $fields, $data );
 57+ $userRole = $load ? $table->selectRow( $fields, $data ) : false;
5758
5859 if ( $userRole === false ) {
5960 return new static( $table, $data, true );
@@ -69,12 +70,13 @@
7071 * @since 0.1
7172 *
7273 * @param User $user
73 - * @param null|array|string $fields
74 - *
 74+ * @param boolean $load If the object should be loaded from the db if it already exists
 75+ * @param null|array|string $fields Fields to load
 76+ *
7577 * @return EPRoleObject
7678 */
77 - public static function newFromUser( User $user, $fields = null ) {
78 - return static::newFromUserId( $user->getId(), $fields );
 79+ public static function newFromUser( User $user, $load = false, $fields = null ) {
 80+ return static::newFromUserId( $user->getId(), $load, $fields );
7981 }
8082
8183 /**
Index: trunk/extensions/EducationProgram/includes/EPIRole.php
@@ -19,11 +19,12 @@
2020 * @since 0.1
2121 *
2222 * @param integer $userId
23 - * @param null|array|string $fields
 23+ * @param boolean $load If the object should be loaded from the db if it already exists
 24+ * @param null|array|string $fields Fields to load
2425 *
2526 * @return EPIRole
2627 */
27 - public static function newFromUserId( $userId, $fields = null );
 28+ public static function newFromUserId( $userId, $load = false, $fields = null );
2829
2930 /**
3031 * Create a new role object from a user object.
@@ -31,11 +32,12 @@
3233 * @since 0.1
3334 *
3435 * @param User $user
35 - * @param null|array|string $fields
 36+ * @param boolean $load If the object should be loaded from the db if it already exists
 37+ * @param null|array|string $fields Fields to load
3638 *
3739 * @return EPIRole
3840 */
39 - public static function newFromUser( User $user, $fields = null );
 41+ public static function newFromUser( User $user, $load = false, $fields = null );
4042
4143
4244 /**

Status & tagging log