Difference between revisions of "Talk:MediaWiki code snippets"

From Organic Design wiki
(Logging to file failing)
 
Line 14: Line 14:
  
 
It is failing on this line <code>$ts = $GLOBALS['wgLang']->timeanddate(wfTimestampNow(),true);</code>. Where is the timeanddate set within the MediaWiki classes? --[[User:Sven|Sven]] 13:33, 10 December 2007 (NZDT)
 
It is failing on this line <code>$ts = $GLOBALS['wgLang']->timeanddate(wfTimestampNow(),true);</code>. Where is the timeanddate set within the MediaWiki classes? --[[User:Sven|Sven]] 13:33, 10 December 2007 (NZDT)
 +
: Looks like $GLOBALS['wgLang'] doesn't exist anymore in <code>print_r($GLOBALS); </code> either --[[User:Sven|Sven]] 13:36, 10 December 2007 (NZDT)

Revision as of 00:36, 10 December 2007

This function failed for me when put at the beginning of an extension;

<php> logFile("FOO","FODDA");

  1. Logging to a file

function logFile($file, $msg) { $fh = fopen($file,'a'); $ts = $GLOBALS['wgLang']->timeanddate(wfTimestampNow(),true); if(is_array($msg)) $msg = print_r($msg, true); fwrite($fh, "\n$ts: $msg"); } </php>

It is failing on this line $ts = $GLOBALS['wgLang']->timeanddate(wfTimestampNow(),true);. Where is the timeanddate set within the MediaWiki classes? --Sven 13:33, 10 December 2007 (NZDT)

Looks like $GLOBALS['wgLang'] doesn't exist anymore in print_r($GLOBALS); either --Sven 13:36, 10 December 2007 (NZDT)