Toniher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59073


Change subject: Default user when no detected: maintenance scripts
......................................................................

Default user when no detected: maintenance scripts

Modification to assign a default user (via param) when $wgUser is not 
accessible.

Change-Id: Ib6d6080b4b48a34bb30edcb01ff8fe16397dfb04
---
M UserFunctions.php
M UserFunctions_body.php
2 files changed, 11 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UserFunctions 
refs/changes/73/59073/1

diff --git a/UserFunctions.php b/UserFunctions.php
index 339d3b3..a7f9b8d 100644
--- a/UserFunctions.php
+++ b/UserFunctions.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * UserFunctions extension - Provides a set of dynamic parser functions that 
trigger on the current user.
- * @version 2.4.2 - 2013/04/08 (Based on ParserFunctions)
+ * @version 2.5.0 - 2013/04/14 (Based on ParserFunctions)
  *
  * @link http://www.mediawiki.org/wiki/Extension:UserFunctions Documentation
  *
@@ -21,6 +21,9 @@
 if ( !defined( 'MEDIAWIKI' ) ) {
        die( 'This file is a MediaWiki extension, it is not a valid entry 
point' );
 }
+
+/** User to use when none detected. E.g., for maintenance scripts **/
+$wgUFMaintenanceUser = "WikiSysop";
 
 /**
  * Enable Personal Data Functions
@@ -42,7 +45,7 @@
 $wgExtensionCredits['parserhook'][] = array(
        'path' => __FILE__,
        'name' => 'UserFunctions',
-       'version' => '2.4.2',
+       'version' => '2.5.0',
        'url' => 'https://www.mediawiki.org/wiki/Extension:UserFunctions',
        'author' => array( 'Algorithm ', 'Toniher', 'Kghbln', 'Wikinaut', 
'Reedy', '...' ),
        'descriptionmsg' => 'userfunctions-desc',
diff --git a/UserFunctions_body.php b/UserFunctions_body.php
index 8b485b6..d66faae 100644
--- a/UserFunctions_body.php
+++ b/UserFunctions_body.php
@@ -28,9 +28,14 @@
        /**
         * @return User
         * Using $wgUser Incompatibility with SMW using via $parser
+        * If no user $wgUser available, let's assign one from prefs
         **/
        private static function getUserObj() {
-               global $wgUser;
+               global $wgUser, $wgUFMaintenanceUser;
+               if ( $wgUser->getID() == null && isset( $wgUFMaintenanceUser ) 
) {
+                       $fakeUser = User::newFromName( $wgUFMaintenanceUser );
+                       return $fakeUser;
+               }
                return $wgUser;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/59073
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6d6080b4b48a34bb30edcb01ff8fe16397dfb04
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UserFunctions
Gerrit-Branch: master
Gerrit-Owner: Toniher <toni...@cau.cat>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to