r94468 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94467‎ | r94468 | r94469 >
Date:19:16, 14 August 2011
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
Craptastic extension

Solves (bug 30305) Special:UserAgent


and then some!
Modified paths:
  • /trunk/extensions/UserDebugInfo (added) (history)
  • /trunk/extensions/UserDebugInfo/SpecialUserDebugInfo.php (added) (history)
  • /trunk/extensions/UserDebugInfo/UserDebugInfo.alias.php (added) (history)
  • /trunk/extensions/UserDebugInfo/UserDebugInfo.i18n.php (added) (history)
  • /trunk/extensions/UserDebugInfo/UserDebugInfo.php (added) (history)

Diff [purge]

Index: trunk/extensions/UserDebugInfo/UserDebugInfo.alias.php
@@ -0,0 +1,8 @@
 2+<?php
 3+
 4+$specialPageAliases = array();
 5+
 6+/** English (English) */
 7+$specialPageAliases['en'] = array(
 8+ 'UserDebugInfo' => array( 'UserDebugInfo', ),
 9+);
\ No newline at end of file
Property changes on: trunk/extensions/UserDebugInfo/UserDebugInfo.alias.php
___________________________________________________________________
Added: svn:eol-style
110 + native
Index: trunk/extensions/UserDebugInfo/UserDebugInfo.i18n.php
@@ -0,0 +1,24 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+/**
 7+ * @author Reedy
 8+ */
 9+$messages['en'] = array(
 10+ 'userdebuginfo' => 'User Debugging Information',
 11+ 'userdebuginfo-desc' => 'Displays some potentially useful debugging information about the current user',
 12+ 'userdebuginfo-useragent' => 'HTTP user agent',
 13+ 'userdebuginfo-remotehost' => 'HTTP remote host',
 14+ 'userdebuginfo-remoteaddr' => 'HTTP remote address',
 15+ 'userdebuginfo-key' => 'Key',
 16+ 'userdebuginfo-value' => 'Value',
 17+);
 18+
 19+/**
 20+ * Message documentation (Message documentation)
 21+ * @author Reedy
 22+ */
 23+$messages['qqq'] = array(
 24+ 'userdebuginfo-desc' => '{{desc}}',
 25+);
\ No newline at end of file
Property changes on: trunk/extensions/UserDebugInfo/UserDebugInfo.i18n.php
___________________________________________________________________
Added: svn:eol-style
126 + native
Index: trunk/extensions/UserDebugInfo/UserDebugInfo.php
@@ -0,0 +1,18 @@
 2+<?php
 3+
 4+$wgExtensionCredits['specialpage'][] = array(
 5+ 'path' => __FILE__,
 6+ 'name' => 'UserDebugInfo',
 7+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UserDebugInfo',
 8+ 'author' => 'Sam Reed',
 9+ 'descriptionmsg' => 'userdebuginfo-desc',
 10+);
 11+
 12+$dir = dirname( __FILE__ ) . '/';
 13+
 14+$wgAutoloadClasses['SpecialUserDebugInfo'] = $dir . 'SpecialUserDebugInfo.php';
 15+$wgSpecialPages['UserDebugInfo'] = 'SpecialUserDebugInfo';
 16+$wgSpecialPageGroups['UserDebugInfo'] = 'other';
 17+
 18+$wgExtensionMessagesFiles['UserDebugInfo'] = $dir . 'UserDebugInfo.i18n.php';
 19+$wgExtensionAliasesFiles['UserDebugInfo'] = $dir . 'UserDebugInfo.alias.php';
\ No newline at end of file
Property changes on: trunk/extensions/UserDebugInfo/UserDebugInfo.php
___________________________________________________________________
Added: svn:eol-style
120 + native
Index: trunk/extensions/UserDebugInfo/SpecialUserDebugInfo.php
@@ -0,0 +1,69 @@
 2+<?php
 3+
 4+/**
 5+ *
 6+ */
 7+class SpecialUserDebugInfo extends SpecialPage {
 8+
 9+ public function __construct() {
 10+ parent::__construct( 'UserDebugInfo' );
 11+ }
 12+
 13+ public function execute( $subpage ) {
 14+ $this->setHeaders();
 15+ global $wgOut;
 16+ $wgOut->addHTML( Xml::openElement( 'table', array( 'class' => 'TablePager' ) ) );
 17+
 18+ $wgOut->addHTML( '<thead>' );
 19+ $wgOut->addHTML( '<tr>' );
 20+ $wgOut->addHTML( '<th>' );
 21+ $wgOut->addWikiMsg( 'userdebuginfo-key' );
 22+ $wgOut->addHTML( '</th>' );
 23+ $wgOut->addHTML( '<th>' );
 24+ $wgOut->addWikiMsg( 'userdebuginfo-value' );
 25+ $wgOut->addHTML( '</th>' );
 26+ $wgOut->addHTML( '</tr>' );
 27+ $wgOut->addHTML( '</thead>' );
 28+
 29+ $wgOut->addHTML( '<tbody>' );
 30+
 31+ $wgOut->addHTML( '<tr>' );
 32+ $wgOut->addHTML( '<td>' );
 33+ $wgOut->addWikiMsg( 'userdebuginfo-useragent' );
 34+ $wgOut->addHTML( '</td>' );
 35+
 36+ $wgOut->addHTML( '<td>' );
 37+ $wgOut->addHTML( $_SERVER['HTTP_USER_AGENT'] );
 38+ $wgOut->addHTML( '</td>' );
 39+
 40+ $wgOut->addHTML( '</tr>' );
 41+
 42+ if ( isset( $_SERVER['REMOTE_HOST'] ) ) {
 43+ $wgOut->addHTML( '<tr>' );
 44+ $wgOut->addHTML( '<td>' );
 45+ $wgOut->addWikiMsg( 'userdebuginfo-remotehost' );
 46+ $wgOut->addHTML( '</td>' );
 47+
 48+ $wgOut->addHTML( '<td>' );
 49+ $wgOut->addHTML( $_SERVER['REMOTE_HOST'] );
 50+ $wgOut->addHTML( '</td>' );
 51+
 52+ $wgOut->addHTML( '</tr>' );
 53+ }
 54+
 55+ $wgOut->addHTML( '<tr>' );
 56+ $wgOut->addHTML( '<td>' );
 57+ $wgOut->addWikiMsg( 'userdebuginfo-remoteaddr' );
 58+ $wgOut->addHTML( '</td>' );
 59+
 60+ $wgOut->addHTML( '<td>' );
 61+ $wgOut->addHTML( $_SERVER['REMOTE_ADDR'] );
 62+ $wgOut->addHTML( '</td>' );
 63+
 64+ $wgOut->addHTML( '</tr>' );
 65+
 66+ $wgOut->addHTML( '</tbody>' );
 67+ $wgOut->addHTML( '</table>' );
 68+ }
 69+}
 70+
Property changes on: trunk/extensions/UserDebugInfo/SpecialUserDebugInfo.php
___________________________________________________________________
Added: svn:eol-style
171 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r94477Followup r94468...reedy19:54, 14 August 2011
r94756Add new extension (r94468) to translatewiki.netraymond13:51, 17 August 2011

Comments

#Comment by Jack Phoenix (talk | contribs)   19:29, 14 August 2011

This reminds me a bit of ShoutWiki's MyInfo extension, which is somewhat similar: it displays the user's current skin, browser, operating system and full User-Agent string on a special page, Special:MyInfo.

In my opinion, the special page looks like it should be using QuickTemplate (unlike the current users of QuickTemplate, i.e. Special:UserLogin and the skin system).

#Comment by Krinkle (talk | contribs)   19:32, 14 August 2011
+		$wgOut->addHTML( Xml::openElement( 'table', array( 'class' => 'TablePager' ) ) );

Seems like class="wikitable" is more appropiate (perhaps add class sortable as well), but TablePager is wrong imho.

#Comment by Reedy (talk | contribs)   19:54, 14 August 2011

CR uses it even for tables that aren't sorted

#Comment by Krinkle (talk | contribs)   20:05, 14 August 2011

It's not just about being sorted, it's for being paged. Since this is not a pager by the Pager class (or any other pager), it'd make sense not to use the TablePager class.

#Comment by 😂 (talk | contribs)   19:38, 14 August 2011

Don't use $_SERVER['REMOTE_ADDR'] directly, it might not work. That's what wfGetIP() is for.

#Comment by MaxSem (talk | contribs)   20:45, 14 August 2011

Will not work in Wikimedia or other cached environments - you need to disable caching for this page.

#Comment by Reedy (talk | contribs)   20:55, 14 August 2011

As in by setting by setting the http headers not to cache?

#Comment by Catrope (talk | contribs)   20:56, 14 August 2011

No, you don't need to do that. Disabling caching is only required when the parser cache is involved, which it isn't for special pages, only for parser functions/tags.

Status & tagging log