Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4963
mediawiki.parserfunction.lastedit.4.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:13 PM
2014-11-21 22:13:34 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
mediawiki.parserfunction.lastedit.4.diff
View Options
Index: includes/MagicWord.php
===================================================================
--- includes/MagicWord.php (revision 35825)
+++ includes/MagicWord.php (working copy)
@@ -105,6 +105,7 @@
'numberofadmins',
'defaultsort',
'pagesincategory',
+ 'lastedit',
);
/* Array of caching hints for ParserCache */
Index: includes/CoreParserFunctions.php
===================================================================
--- includes/CoreParserFunctions.php (revision 35825)
+++ includes/CoreParserFunctions.php (working copy)
@@ -44,6 +44,7 @@
$parser->setFunctionHook( 'pagesincategory', array( __CLASS__, 'pagesincategory' ), SFH_NO_HASH );
$parser->setFunctionHook( 'pagesize', array( __CLASS__, 'pagesize' ), SFH_NO_HASH );
$parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
+ $parser->setFunctionHook( 'lastedit', array( __CLASS__, 'lastedit' ), SFH_NO_HASH );
if ( $wgAllowDisplayTitle ) {
$parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
@@ -382,4 +383,31 @@
);
return $parser->extensionSubstitution( $params, $frame );
}
+
+ static function lastedit( $parser, $s = '' ) {
+ static $cache = array();
+
+ $user = User::newFromName( trim( $s ) );
+ if ($user == null) return '';
+ $s = $user->getName();
+
+ if( isset( $cache[$s] ) ) {
+ $ts = $cache[$s];
+ } elseif ( $parser->incrementExpensiveFunctionCount() ) {
+ $db = wfGetDB( DB_SLAVE );
+ $ts = $db->selectField(
+ 'revision',
+ 'rev_timestamp',
+ array( 'rev_user_text' => $s ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_timestamp DESC' )
+ );
+
+ $cache[$s] = $ts;
+ }
+
+ if ($ts === false) return '';
+
+ return wfTimestamp(TS_ISO_8601, $ts);
+ }
}
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 35825)
+++ languages/messages/MessagesEn.php (working copy)
@@ -340,6 +340,7 @@
'hiddencat' => array( 1, '__HIDDENCAT__' ),
'pagesincategory' => array( 1, 'PAGESINCATEGORY', 'PAGESINCAT' ),
'pagesize' => array( 1, 'PAGESIZE' ),
+ 'lastedit' => array( 0, '#LASTEDIT:' ),
);
/**
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4527
Default Alt Text
mediawiki.parserfunction.lastedit.4.diff (2 KB)
Attached To
Mode
T16384: New #lastedit parserfunction
Attached
Detach File
Event Timeline
Log In to Comment