Owen B. Mehegan wrote:
I've taken this example and tried to adapt it to
my code. But when I
call the function I've created that uses it, I get:
Fatal error: Call to a member function ucfirst() on a non-object in
/usr/share/mediawiki/includes/User.php on line 653
My attempts at debugging seem to indicate that this happens when I
call:
$username = "TestUser";
$u = User::newFromName($username);
I looked at User.php, this is the section in question:
650 static function getCanonicalName( $name, $validate = 'valid'
) {
651 # Force usernames to capital
652 global $wgContLang;
653 $name = $wgContLang->ucfirst( $name );
I don't really know where to go from here...
You haven't initialised $wgContLang
Before calling User::newFromName you can do:
$wgContLang = Language::factory( 'en' );
(assuming the wiki language is English...)