I'm trying to pass $old from getOldText to reEdit with globals, but its not working. I can't call getOldText from inside reEdit, because by the time that occurs the old text would have been overwritten by the edit.
$old = "INITIAL";
function reEdit() {
global $old;
//removed code creating article object to simplify
$new = $article->getRawText();
$article->doEdit( "$new <-new old -> $old"); //PROBLEM HERE, returns as INITIAL
return true;
}
function getOldText() {
global $old;
//removed code creating article object to simplify
$old = $article->getRawText();
return true;
}
$wgHooks['EditFormInitialText'][] = array('getOldText');
$wgHooks['ArticleSaveComplete'][] = array('reEdit');
The problem is in the line indicated - $old is not passed to it despite being global.
The $wgHooks are MediaWiki code that call my functions when an article is starting to be edited and saved, respectively. For those who are familiar with mediawiki code, I'm just trying to get the text from before an edit was performed.