Extension talk:Realnames

Jump to navigation Jump to search

About this board

Speed Issues

There is (I have) some concern over speed issues. While I wasn't able to observe it on my wiki, with large RecentChanges or History pages with a lot of username->realname conversions/lookups (by as many different users as possible) it could start to slow down. We have potentially 500 unique realname lookups for a single page hit. If you experience this on your wiki, please let me know, I have a few strategies to combat this. The first will be to change from using the User:newFromName() core lookup and first compiling a list of usernames to look up, and doing them all at once in a single direct db hit on the users table. This would speed up name lookups on all pages but tie us more closely into base core components (I may do this anyways in a future version). The next strategy would be to hook into these two specific high use pages (perhaps All Users as well), and add to their queries so as they get data they also get the real name for display. I've already coded this for History, OldRecentChanges, EnhancedRecentChanges and AllUsers, but haven't included it in yet, it would increase the size/complexity a fair amount. The good news that all of these improvements can act as layers. We can do hook-based lookups for high-use places, than fallback on the more general article content search for any straglers (like Revisions, Comparison, user-created links). Please let me know what your experience is! --Ofbeaton 17:59, 19 September 2011 (UTC)

If you use the default style 'replace', users (especially non-tech) users won't be able to find someone's username very easily. Infact the only place you can find it is in the URL, under the form 'User:username' because all displays will be of their real names. This makes manual linking to a user cumbersome. I can see two avenues of attack to this problem, the first may be to change the default style to something like 'append' or 'reverse'. Please let me know if you prefer a different default style (although this will affect people already using the extension). The 2nd avenue, and one I will probably pursue anyways is looking at $linker to see if I could allow users to do [User:realname] links in articles. Even if it involves doing another search and replace of realname->username or hooking's the lookup to be username OR realname. This could produce some weird collisions since realnames are not unique, and usernames+realnames definitely aren't, however as a togglable option it may make a 'replace' style wiki more usable in the long. Please let me know your thoughts! --Ofbeaton 18:07, 19 September 2011 (UTC)

User Issues

Please use the "Start a new topic" box on the left about your issue or suggestion.

Not working on body if username is not a link

Loic.tessier (talkcontribs)


My topic is not relevant as a problem but as a tip :

In RealNames.body.php, it seems that a function is never call : "lookForBare"

I just add the line underlined below:

if ( $GLOBALS['wgRealnamesReplacements']['body'] === true ) {
                       // article html text
                       self::debug( __METHOD__, 'searching article body...' );
                       $out->mBodytext = self::lookForLinks( $out->getHTML() );
+                       $out->mBodytext = self::lookForBare ( $out->getHTML() );

and then, username will be translate in RealName even if there is no link.

Reply to "Not working on body if username is not a link"

Realnames 0.3.1 page titel and body problem

5 (talkcontribs)

First I got to say I am working in Austria.

I am running MW 1.18.0 with Realnames 0.3.1 and my problem is that every page titel in the header/body that starts with "Benutzer" is replaced to nothing. E.g "Benutzeroberflächen" is displayed as "oberflächen".

I also expected a problem with Realnames at the recent changes page: The usernames are not displayed with their realnames.

Ofbeaton (talkcontribs)

Thanks for letting me know, I'll definitely look at this. Can you tell me what language you've set your wiki to? I'm not talking about the user language but the sitewide one set in LocalSettings.php so I can test. Thanks!

This post was posted by Ofbeaton, but signed as Olivier Beaton. (talkcontribs)

Hey! I have set $wgLanguageCode = "de"; in my LocalSettings.php

Thanks for your very quick reply! (talkcontribs)

It's the same with English language code ( $wgLanguageCode = "en"; ) and User* pages.
As User:Robinson_Weijman already mentioned, with [[user*]] and [[ User*]] (or for German: [[benutzer*]] and [[ Benutzer*]]) at least the links will work. The page title will still be cut off.

Ofbeaton (talkcontribs)

7 years late, but should now be fixed for 1.31 LTS! I hope, I haven't tested non-en languages but the fix I checked it should address this.

Reply to "Realnames 0.3.1 page titel and body problem"

Problem in Japanese Environment

Koty~mediawikiwiki (talkcontribs)

MediaWiki 1.19.2 Realnames 0.3.1

Replacement of name does not work in Japanese Environment. I think there is a lack of i18n. I modified source, then it runs correctly. thank you.

<     $namespaces[] = urlencode($lang->getNsText ( NS_USER )) . ':';
<     $namespaces[] = urlencode($lang->getNsText ( NS_USER_TALK )) . ':';
>     $namespaces[] = $lang->getNsText ( NS_USER );
>     $namespaces[] = $lang->getNsText ( NS_USER_TALK );
<         $namespaces[] = urlencode($name) . ':';
>         $namespaces[] = $name;

This post was posted by Koty~mediawikiwiki, but signed as Koty.

Ofbeaton (talkcontribs)

4 years late, but should now be fixed for 1.31 LTS!

Reply to "Problem in Japanese Environment"

Not works on 'RecentChanges', 'ListUser' and 'History of page' pages

7 (talkcontribs)

I install the extension with these parameters, but it doesn't work on 'RecentChanges', 'ListUser' and 'History of page' pages. I see my full name and user name in the top right menu after I log in.

require_once("$IP/extensions/Realnames/Realnames.php"); $wgRealnamesLinkStyle = "reverse"; $wgRealnamesBareStyle = "reverse"; $wgRealnamesBlank = true;

System parameters MediaWiki: 1.18.1 PHP: 5.3.10 (cgi-fcgi) MySQL: 5.5.21

What will be the problem?

Thx for the answers


Syserr0r (talkcontribs)

On line 353 of Realnames.body.php replace:

 $pattern = '/(<a\b[^">]+href="[^">]+'.static::getNamespacePrefixes().'([^"\\?\\&>]+)[^>]+>)'.static::getNamespacePrefixes().'?([^>]+)(<\\/a>)/';


 $pattern = '/(<a\b(?:(?!href=")[^">]+[^>]+)?[^">]+href="[^">]+'.static::getNamespacePrefixes().'([^"\?\&>]+)[^>]+>)'.static::getNamespacePrefixes().'?(?:\<bdi\>)?([^>]+)(?:\<\/bdi\>)?(<\/a>)/';
Ofbeaton (talkcontribs)

2 years late, but should now be fixed for 1.31 LTS! Thanks! This is what was causing problems on the RecentChanges pages! (talkcontribs)

I have my wiki set up in Dutch language, but for some reason the function static::getNamespacePrefixes() returns (?:User:|User talk:|Gebruiker|Overleg_gebruiker). Notice the absence of : after Gebruiker and Overleg_gebruiker.. I had to replace the pattern with:

$pattern = '/(<a\b(?:(?!href=")[^">]+[^>]+)?[^">]+href="[^">]+'.static::getNamespacePrefixes().':?([^"\?\&>]+)[^>]+>)'.static::getNamespacePrefixes().'?:?(?:\<bdi\>)?([^>]+)(?:\<\/bdi\>)?(<\/a>)/';

But I'm not a regex wizard, so I hope this won't break anything..

Ofbeaton (talkcontribs)

2 years late, but should now be fixed for 1.31 LTS!

Reply to "Not works on 'RecentChanges', 'ListUser' and 'History of page' pages"
Harry0725 (talkcontribs)

For those guys who may have the same problem with me.....

I just tried to install this extension to make realname append to user ID on top of page.

But I didn't notice that all my page titles (<h1>) are gone since I didn't give arguments for $wgRealnamesReplacements

One day, I found this problem and spend couple hours to solve this strange problem.

Finally, I realized I should set $wgRealnamesReplacements['title'] = false to prevent from title missing.

It's my misunderstanding....Just hope no one will do stupid thing like me.

Morgan greywolf (talkcontribs)

This is a great extension, but it doesn't seem to work with the MobileFrontend extension. All I see are the login names, not the real names. I'm using 0.3.1 of Realnames and the latest snapshot for both MediaWiki 1.23.13 (production) and the latest snapshot of MediaWiki 1.27 (test) . The extension works great in the desktop view, just not the mobile view. Any ideas?

Addendum: It does work with Special:ListUsers in mobile view, but not on normal article pages.

Reply to "Problem with MobileFrontend"
Ofbeaton (talkcontribs)

I had to fix the namespace to get users recognized:

-     static::$namespacePrefixes = '(?:'.implode('|',$namespaces).':)';
+     static::$namespacePrefixes = '(?:'.implode('|',$namespaces).'):';

Cweiske 13:18, 15 December 2011 (UTC)

This post was posted by Ofbeaton, but signed as Olivier Beaton.

Ofbeaton (talkcontribs)

Could you please try 0.3.1 and let me know if you have the same issue? The fix in the end was not as easy as you mentioned.

This post was posted by Ofbeaton, but signed as Olivier Beaton.

Cweiske (talkcontribs)

> Could you please try 0.3.1 and let me know if you have the same issue Yes, I still have the same problem with 0.3.1. 0.3.0 with my patch makes it work for me.

I'm specifically having the problem that [[User:christian.weiske]] in the text does not get replaced with my name.

Reply to "Problem in 0.3"

Realnames_0.3_2011-11-05 fails on MW 1.18

Vgold~mediawikiwiki (talkcontribs)

I'm getting Parse error: syntax error, unexpected T_STATIC in C:\wiki\htdocs\wiki\extensions\Realnames\Realnames.body.php on line 85

This post was posted by Vgold~mediawikiwiki, but signed as Vgold.

Ofbeaton (talkcontribs)

I'm not exactly sure if I fixed your problem, but could you please try 0.3.1 and let me know? I finally got my environment back up, and I've got it working on all wiki version back to 1.15.x

If it doesn't fix it, could you please give me the new error message/line num, as well as what version of PHP you are running?

Thanks for reporting the problem! I'll get it fixed ASAP either way.

This post was posted by Ofbeaton, but signed as Olivier Beaton. (talkcontribs)

Hi, I'm also getting this error with 0.3.1. Here is my enviroment:

Product Version
MediaWiki 1.17.0
PHP 5.1.6 (apache2handler)
MySQL 5.0.77

|- ! Header text !! Header text !! Header text |- | Example || Example || Example |- | Example || Example || Example |- | Example || Example || Example

And the error message: PHP Parse error: syntax error, unexpected T_STATIC in /var/www/html/mw/extensions/Realnames/Realnames.body.php on line 80 (talkcontribs)

Same error as others
Parse error: syntax error, unexpected T_STATIC in /homepages/obfuscation/htdocs/mediawiki/extensions/Realnames/Realnames.body.php on line 80


  • MediaWiki 1.18
  • PHP 5.2.17
  • Realnames 0.3.1 (2011-12-25)

$wgRealnamesLinkStyle = "append";

Users are clamoring for Real Names to be visible. (talkcontribs)

i've got the same error. MediaWiki 1.18.0 PHP 5.2.17 (ucgi5) MySQL 5.5.21-log Parse error: syntax error, unexpected T_STATIC in /polish/extensions/Realnames/Realnames.body.php on line 80 (talkcontribs)

I resolved the issue by replacing all reference to static:: with self:: This will roughly have the same effect, but fix your errors.

Reply to "Realnames_0.3_2011-11-05 fails on MW 1.18"

Block Page Title Conversion

Salquint (talkcontribs)

Great extension, I wish I knew about it about 132 internal users ago, but still, it's very useful. However, I have some oldtimers who have their first name matching their login name (like "John"). So home page titles went from "John Smith" to "John Smith Smith" or from "John Jones" to "John Smith Jones".

Salquint (talkcontribs)

Here's the patch in case you have an IT department that forces you to be interested:

Index: Realnames.body.php
--- Realnames.body.php	(revision 223)
+++ Realnames.body.php	(revision 226)
@@ -278,7 +278,7 @@
    * @note requires MediaWiki 1.7.0      
   public static function hookBeforePageDisplay(&$out, &$sk = false) {
-    global $wgTitle;
+    global $wgTitle, $wgRealnamesPageTitle;
     // pre 1.16 no getTitle()
     $title = method_exists($out,'getTitle') ? $out->getTitle() : $wgTitle;
@@ -294,8 +294,10 @@
     if (self::debug()) {
       echo "hookBeforePageDisplay: searching article title...<br>\n";          
-    // this should also affect the html head title
-    $out->setPageTitle(self::lookForBare($out->getPageTitle()));
+    if ( $wgRealnamesPageTitle ) {
+      // this should also affect the html head title
+      $out->setPageTitle(self::lookForBare($out->getPageTitle()));
+    }
     // subtitle (say, on revision pages)
     if (self::debug()) {

Index: Realnames.php
--- Realnames.php	(revision 223)
+++ Realnames.php	(revision 226)
@@ -107,6 +107,12 @@
 $wgRealnamesNamespaces = array();
+ * Used to block the conversion of Page titles (when set to false)
+ * @since 2011-09-350 0.1
+ */ 
+$wgRealnamesPageTitle = true;
 if (isset($wgConfigureAdditionalExtensions) && is_array($wgConfigureAdditionalExtensions)) {
   /* (not our var to doc)
@@ -121,6 +127,7 @@
           'wgRealnamesBlank' => 'bool',
           'wgRealnamesStyles' => 'array',   
           'wgRealnamesNamespaces' => 'array',     
+          'wgRealnamesPageTitle' => 'bool',
       'array' => array(
           'wgRealnamesStyles' => 'assoc',

To block page title conversions, set $wgRealnamesPageTitle to false in LocalSetttings.php. Otherwise, it works as intended.

Ofbeaton (talkcontribs)

Hi Salquint, I'm happy to hear you're liking the extension, and thanks for the patch! While it's obvious it lets you opt-out of replacing the page title, I was wondering if you could send me a few other details about why this is happening for you. If a user sets their real name to 'John' and their username is 'John Smith', with a 'replace' style you will only see 'John'. With an append style you will see 'John Smith - John'. Is that what you meant? I remember writting a patch for Extension:ShowRealUsernames a long way back to make it so that if their username == realname, then don't use the append style. I had completely forgotten it until now! So I'll definitely be adding something in for that in the next version. Back to your problem though, could you please elaborate? Thanks a bunch!

This post was posted by Ofbeaton, but signed as Quadir.

Salquint (talkcontribs)

Sorry for the late reply, silly work gets in the way. I encountered it the other way. In my situation:

  • Username - John
  • "Real name" in preferences - John Smith
  • Profile Page Name - "John Smith", not User:John, a John Smith page

After installing Realnames, viewing the profile page showed the title "John Smith Smith", presumably because the "John" in the title was replaced with Real name "John Smith"

Ofbeaton (talkcontribs)

Hi salquint, sorry for the delay. I've released version 0.3 which includes a new setting for which you can do $wgRealnamesReplacements['title'] = FALSE; in your LocalSettings to do the behaviour you describe above. Please let me know if it works for you. I still want to look more into the exact problem you were encountering though. I fixed a bug in title handling that may be related, can you give it a try (with titles enabled) and let me know if you see the same behaviour? If so, just disable title handling and I'll keep working on this.

This post was posted by Ofbeaton, but signed as Olivier Beaton.

Salquint (talkcontribs)
Ofbeaton (talkcontribs)

Oh bother. Yes, that's the file. I forgot to change the version in Realnames.php (again!) I'm glad to hear your issue is resolved!

This post was posted by Ofbeaton, but signed as Olivier Beaton.

MSun (talkcontribs)

I tried to use the extension for MW 1.16.0. It didn't work. MW pages do not show up.

Salquint (talkcontribs)

For what it's worth, I'm using the extension with 1.16.0. Are there any other descriptions / clues you can provide on what you're seeing?

MSun (talkcontribs)

Thanks Salquint.

The message is "The website cannot display the page". It seems that MW reads line "$wgHooks['BeforePageDisplay'][] = 'ExtRealnames::hookBeforePageDisplay';" and "$wgHooks['PersonalUrls'][] = 'ExtRealnames::hookPersonalUrls';" as program error. When I removed these two lines, the webpages show up.

Ofbeaton (talkcontribs)

If you comment out those lines, then the extension does nothing at all. Could you please try 0.3.1 and let me know if this solves your problem? If not, please add a error_log line to your php.ini and tell me what errors you are seeing for Realnames and paste them here. Please let me know what version of PHP, MW and Realnames you are trying to use together.

I just got my environment back online, so I'll get whatever your issue is fixed ASAP! And Thanks Salquint, you're always helpful.

This post was posted by Ofbeaton, but signed as Olivier Beaton.

MSun (talkcontribs)

I reinstalled MW (1.17.0). The extension didn't work. With the extension installed, MW pages do not show up. The error message is "The website cannot display the page".

Reply to "Block Page Title Conversion"

Extension not working after moving from Linux to Windows

Ironswalt (talkcontribs)

Hi all,

I recently moved my wiki from a LAMP setup to a WAMP setup. There have been a few small issues to resolve, one of them being that user's real names weren't displaying. I noticed that this is because this extension searches for the text "User:" and "User Talk:" in the content then replaces it.

However on Windows, the colon is URL Encoded so no match was made and no substitution performed.

To fix this, I changed Realnames.body.php around line 212 and replaced the colon with %3A:

    // always catch this one
#    $namespaces = array('User:', 'User talk:');
    $namespaces = array('User%3A', 'User talk%3A');

Hope this helps someone in future :)


Reply to "Extension not working after moving from Linux to Windows"