r92505 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92504‎ | r92505 | r92506 >
Date:23:14, 18 July 2011
Author:reedy
Status:ok
Tags:
Comment:
MFT r92477, r92480, r92481, r92482, r92484, r9485, r92486

RELEASE-NOTES already merged...
Modified paths:
  • /branches/REL1_18/phase3/includes/Block.php (modified) (history)
  • /branches/REL1_18/phase3/includes/HttpFunctions.php (modified) (history)
  • /branches/REL1_18/phase3/includes/User.php (modified) (history)
  • /branches/REL1_18/phase3/includes/WikiPage.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /branches/REL1_18/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /branches/REL1_18/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/includes/User.php
@@ -282,7 +282,7 @@
283283 * Load user table data, given mId has already been set.
284284 * @return Bool false if the ID does not exist, true otherwise
285285 */
286 - private function loadFromId() {
 286+ public function loadFromId() {
287287 global $wgMemc;
288288 if ( $this->mId == 0 ) {
289289 $this->loadDefaults();
@@ -859,7 +859,7 @@
860860 *
861861 * @param $name string
862862 */
863 - private function loadDefaults( $name = false ) {
 863+ public function loadDefaults( $name = false ) {
864864 wfProfileIn( __METHOD__ );
865865
866866 $this->mId = 0;
@@ -1016,7 +1016,7 @@
10171017 *
10181018 * @return Bool True if the user exists, false if the user is anonymous
10191019 */
1020 - private function loadFromDatabase() {
 1020+ public function loadFromDatabase() {
10211021 # Paranoia
10221022 $this->mId = intval( $this->mId );
10231023
@@ -2758,7 +2758,7 @@
27592759 * Clear the user's cookies and session, and reset the instance cache.
27602760 * @see logout()
27612761 */
2762 - private function doLogout() {
 2762+ public function doLogout() {
27632763 $this->clearInstanceCache( 'defaults' );
27642764
27652765 $this->getRequest()->setSessionData( 'wsUserID', 0 );
Index: branches/REL1_18/phase3/includes/installer/Installer.php
@@ -1466,10 +1466,14 @@
14671467 $params['language'] = $myLang;
14681468 }
14691469
1470 - $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1471 - array( 'method' => 'POST', 'postData' => $params ) )->execute();
1472 - if( !$res->isOK() ) {
1473 - $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
 1470+ if( MWHttpRequest::canMakeRequests() ) {
 1471+ $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
 1472+ array( 'method' => 'POST', 'postData' => $params ) )->execute();
 1473+ if( !$res->isOK() ) {
 1474+ $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
 1475+ }
 1476+ } else {
 1477+ $s->warning( 'config-install-subscribe-notpossible' );
14741478 }
14751479 }
14761480
Index: branches/REL1_18/phase3/includes/installer/Installer.i18n.php
@@ -520,6 +520,7 @@
521521 'config-insecure-keys' => "'''Warning:''' {{PLURAL:$2|A secure key|Secure keys}} ($1) generated during installation {{PLURAL:$2|is|are}} not completely safe. Consider changing {{PLURAL:$2|it|them}} manually.",
522522 'config-install-sysop' => 'Creating administrator user account',
523523 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce: $1',
 524+ 'config-install-subscribe-notpossible' => 'cURL is not installed and allow_url_fopen is not available.',
524525 'config-install-mainpage' => 'Creating main page with default content',
525526 'config-install-extension-tables' => 'Creating tables for enabled extensions',
526527 'config-install-mainpage-failed' => 'Could not insert main page: $1',
Index: branches/REL1_18/phase3/includes/api/ApiQueryAllUsers.php
@@ -248,7 +248,7 @@
249249
250250 if ( $fld_rights ) {
251251 if ( !isset( $lastUserData['rights'] ) ) {
252 - $lastUserData['rights'] = User::getGroupPermissions( User::getImplicitGroups() );
 252+ $lastUserData['rights'] = User::getGroupPermissions( User::newFromName( $lastUser )->getAutomaticGroups() );
253253 }
254254 if ( !is_null( $row->ug_group2 ) ) {
255255 $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'],
Index: branches/REL1_18/phase3/includes/api/ApiQueryUsers.php
@@ -154,7 +154,7 @@
155155
156156 if ( isset( $this->prop['rights'] ) ) {
157157 if ( !isset( $data[$name]['rights'] ) ) {
158 - $data[$name]['rights'] = User::getGroupPermissions( User::getImplicitGroups() );
 158+ $data[$name]['rights'] = User::getGroupPermissions( $user->getAutomaticGroups() );
159159 }
160160
161161 if ( !is_null( $row->ug_group ) ) {
Index: branches/REL1_18/phase3/includes/WikiPage.php
@@ -82,6 +82,8 @@
8383 * Always override this for all subclasses (until we use PHP with LSB)
8484 *
8585 * @param $id Int article ID to load
 86+ *
 87+ * @return WikiPage
8688 */
8789 public static function newFromID( $id ) {
8890 $t = Title::newFromID( $id );
@@ -278,6 +280,8 @@
279281 /**
280282 * Return the list of revision fields that should be selected to create
281283 * a new page.
 284+ *
 285+ * @return array
282286 */
283287 public static function selectFields() {
284288 return array(
@@ -535,7 +539,7 @@
536540 * Revision::FOR_THIS_USER to be displayed to $wgUser
537541 * Revision::RAW get the text regardless of permissions
538542 * @return String|false The text of the current revision
539 - */
 543+ */
540544 public function getText( $audience = Revision::FOR_PUBLIC ) {
541545 $this->loadLastEdit();
542546 if ( $this->mLastRevision ) {
Index: branches/REL1_18/phase3/includes/HttpFunctions.php
@@ -210,6 +210,15 @@
211211 }
212212
213213 /**
 214+ * Simple function to test if we can make any sort of requests at all, using
 215+ * cURL or fopen()
 216+ * @return bool
 217+ */
 218+ public static function canMakeRequests() {
 219+ return function_exists( 'curl_init' ) || wfIniGetBool( 'allow_url_fopen' );
 220+ }
 221+
 222+ /**
214223 * Generate a new request object
215224 * @param $url String: url to use
216225 * @param $options Array: (optional) extra params to pass (see Http::request())
Index: branches/REL1_18/phase3/includes/Block.php
@@ -77,7 +77,11 @@
7878 $this->mAuto = $auto;
7979 $this->isHardblock( !$anonOnly );
8080 $this->prevents( 'createaccount', $createAccount );
81 - $this->mExpiry = $expiry;
 81+ if ( $expiry == 'infinity' || $expiry == Block::infinity() ) {
 82+ $this->mExpiry = 'infinity';
 83+ } else {
 84+ $this->mExpiry = wfTimestamp( TS_MW, $expiry );
 85+ }
8286 $this->isAutoblocking( $enableAutoblock );
8387 $this->mHideName = $hideName;
8488 $this->prevents( 'sendemail', $blockEmail );
@@ -348,8 +352,15 @@
349353 $this->mAuto = $row->ipb_auto;
350354 $this->mHideName = $row->ipb_deleted;
351355 $this->mId = $row->ipb_id;
352 - $this->mExpiry = $row->ipb_expiry;
353356
 357+ // I wish I didn't have to do this
 358+ $db = wfGetDB( DB_SLAVE );
 359+ if ( $row->ipb_expiry == $db->getInfinity() ) {
 360+ $this->mExpiry = 'infinity';
 361+ } else {
 362+ $this->mExpiry = wfTimestamp( TS_MW, $row->ipb_expiry );
 363+ }
 364+
354365 $this->isHardblock( !$row->ipb_anon_only );
355366 $this->isAutoblocking( $row->ipb_enable_autoblock );
356367
@@ -455,7 +466,7 @@
456467 if( !$db ){
457468 $db = wfGetDB( DB_SLAVE );
458469 }
459 - $this->mExpiry = $db->encodeExpiry( $this->mExpiry );
 470+ $expiry = $db->encodeExpiry( $this->mExpiry );
460471
461472 $a = array(
462473 'ipb_address' => (string)$this->target,
@@ -468,7 +479,7 @@
469480 'ipb_anon_only' => !$this->isHardblock(),
470481 'ipb_create_account' => $this->prevents( 'createaccount' ),
471482 'ipb_enable_autoblock' => $this->isAutoblocking(),
472 - 'ipb_expiry' => $this->mExpiry,
 483+ 'ipb_expiry' => $expiry,
473484 'ipb_range_start' => $this->getRangeStart(),
474485 'ipb_range_end' => $this->getRangeEnd(),
475486 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite
@@ -632,8 +643,7 @@
633644 $autoblock->mHideName = $this->mHideName;
634645 $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) );
635646
636 - $dbr = wfGetDB( DB_SLAVE );
637 - if ( $this->mExpiry == $dbr->getInfinity() ) {
 647+ if ( $this->mExpiry == 'infinity' ) {
638648 # Original block was indefinite, start an autoblock now
639649 $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
640650 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r9485PROCESS permission, for lag detectiontimstarling01:44, 19 June 2005
r92477* (bug 29938) list=users&usprop=rights shows rights the user doesn't havereedy21:26, 18 July 2011
r92480Block.php fixes: Always store mExpiry as a TS_MW or "infinity". Convert as ap...werdna21:48, 18 July 2011
r92481(bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and use...demon21:56, 18 July 2011
r92482Fix autoblocks in r92480werdna21:56, 18 July 2011
r92484It seems people don't either pay attention to code comments, or those comment...reedy22:01, 18 July 2011
r92486Add comment...reedy22:23, 18 July 2011

Status & tagging log