r99533 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99532‎ | r99533 | r99534 >
Date:18:50, 11 October 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Don't abuse globals
Modified paths:
  • /trunk/extensions/LastModified/LastModified.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LastModified/LastModified.php
@@ -69,14 +69,22 @@
7070
7171 $wgLastModifiedRange = isset( $wgLastModifiedRange ) ? (integer) $wgLastModifiedRange : 0;
7272
73 -function fnLastModified() {
74 - global $wgOut, $wgArticle, $wgLastModifiedRange;
 73+/**
 74+ * @param $out OutputPage
 75+ * @param $sk Skin
 76+ * @return bool
 77+ */
 78+function fnLastModified( &$out, &$sk ) {
 79+ global $wgLastModifiedRange;
7580
76 - if ( isset( $wgArticle ) && !empty( $wgArticle ) ){
77 - $timestamp = $wgArticle->getTimestamp();
78 - $wgOut->addMeta( 'last-edited', wfTimestamp ( TS_UNIX, $timestamp ) );
79 - $wgOut->addMeta( 'last-modified-range', $wgLastModifiedRange );
80 - $wgOut->addModules( 'last.modified' );
 81+ $context = $out->getContext();
 82+ $title = $context->getTitle();
 83+ $article = Article::newFromTitle( $title, $context );
 84+ if ( $article ){
 85+ $timestamp = $article->getTimestamp();
 86+ $out->addMeta( 'last-edited', wfTimestamp ( TS_UNIX, $timestamp ) );
 87+ $out->addMeta( 'last-modified-range', $wgLastModifiedRange );
 88+ $out->addModules( 'last.modified' );
8189 }
8290
8391 return true;

Sign-offs

UserFlagDate
Jpostlethwaiteinspected18:59, 11 October 2011
Jpostlethwaitetested18:59, 11 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99522Adding new extension LastModified.jpostlethwaite18:30, 11 October 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   18:59, 11 October 2011

Thanks for removing the evil globals. Tested and working.

Status & tagging log