r96013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96012‎ | r96013 | r96014 >
Date:17:08, 1 September 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
RL2: Fix bug where the preferences page was messed up when a description was empty, and the titles weren't included. Now using "$title: $description"
Modified paths:
  • /branches/RL2/extensions/Gadgets/GadgetHooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/Gadgets.i18n.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.i18n.php
@@ -26,6 +26,7 @@
2727
2828 Also note that these special gadgets are not part of the MediaWiki software, and are usually developed and maintained by users on your local wiki.
2929 Local administrators can edit the [[MediaWiki:Gadgets-definition|definitions]] and [[Special:Gadgets|descriptions]] of available gadgets.',
 30+ 'gadgets-preference-description' => '$1: $2',
3031
3132 # For Special:Gadgets
3233 'gadgets' => 'Gadgets',
@@ -98,6 +99,7 @@
99100
100101 {{Identical|Gadgets}}',
101102 'gadgets-prefstext' => 'In Gadgets extension. This is the explanation text displayed under the Gadgets tab in [[Special:Preferences]].',
 103+ 'gadgets-preference-description' => 'Used for the description HTML of a Gadget in Special:Preferences. $1 is the title of the Gadget, $2 is the description of the Gadget.',
102104 'gadgets' => '{{Identical|Gadgets}}',
103105 'gadgets-title' => '{{Identical|Gadgets}}',
104106 'gadgets-uses' => "This is used as a verb in third-person singular. It appears in front of a script name. Example: \"''Uses: Gadget-UTCLiveClock.js''\"
Index: branches/RL2/extensions/Gadgets/GadgetHooks.php
@@ -193,8 +193,15 @@
194194 $category = $gadget->getCategory();
195195
196196 // Add the Gadget to the right category
197 - $description = $gadget->getDescriptionMessage();
198 - $categories[$category][$description] = $name;
 197+ $title = htmlspecialchars( $gadget->getTitleMessage() );
 198+ $description = $gadget->getDescriptionMessage(); // Is parsed, doesn't need escaping
 199+ if ( $description === '' ) {
 200+ // Empty description, just use the title
 201+ $text = $title;
 202+ } else {
 203+ $text = wfMessage( 'gadgets-preference-description' )->rawParams( $title, $description )->parse();
 204+ }
 205+ $categories[$category][$text] = $name;
199206 // Add the Gadget to the default list if enabled
200207 if ( $gadget->isEnabledForUser( $user ) ) {
201208 $default[] = $name;

Comments

#Comment by Krinkle (talk | contribs)   15:17, 3 September 2011

Something seems still wrong.

I've got three gadgets on local wiki:

  1. name: A; title: Aaaa title; description: (none);
  2. name: B; title: (none); description: (none);
  3. name: x; title: (none); description: (none); (lower case x)

Gadget manager:

  1. Aaaa title
  2. B
  3. X

Preferences:

  1. B
  2. X
#Comment by Catrope (talk | contribs)   11:52, 5 September 2011

Was this fixed in r96215?

#Comment by Krinkle (talk | contribs)   00:26, 9 September 2011

No, this is happening on SpecialPreferences under the (local) gadgets tab. Not related to the api.

#Comment by Catrope (talk | contribs)   13:57, 9 September 2011

This is not a bug. The preferences page hides gadgets you don't have the necessary rights for. You put "rights": [ "block", "xxx" ] in Gadget definition:A.js and didn't give yourself the xxx right. After giving all users the xxx right (what's that, anyway, the right to have sex? :D) A appears as it should.

#Comment by Krinkle (talk | contribs)   20:45, 10 September 2011

Oh crap, you're right. That's the reason I wasn't showing up. Duh!

I won't comment on the placeholder user right name....

Status & tagging log