Topic on Extension talk:Realnames

Block Page Title Conversion

12
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"