Difference between revisions of "Extension talk:TransformChanges.php"

From Organic Design wiki
m (New page: Changes added in OD changes, <php> # We're using these cols and ordering $cols = array('time','diff','title','comment','user','info'); # this is added before the final row-assembling line...)
 
(remove regex info from last debugging notes)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
Changes added in OD changes,
+
== Fix for MediaWiki 1.13 ==
<php>
+
The problem is that the [[MW:Manual:Hooks/SpecialPageExecuteAfterPage|SpecialPageExecuteAfterPage]] hook doesn't get called by sub-classes of ''SpecialPage''. In MediaWiki 1.12, the recentchanges specialpage was changed from the old-style execution method to a sub-class, and therefore prevented TransformChanges from working.
# We're using these cols and ordering
 
$cols = array('time','diff','title','comment','user','info');
 
  
# this is added before the final row-assembling line of wfTransformChangesLI()
+
After analysing the flow of execution during the rendering of a special page I was able to find a means of hooking in to the rendered page. The ''webOutput'' method calls the builds the entire HTML output and then sends it all at once to the ''addHTML'' method of the global ''$wgOut'' object.
$talk = preg_replace('| \\|.+</a>|','',$talk);
+
 
$diff = preg_replace('|curid=[0-9]+&(amp;)?action=history|','action=edit',$diff);
+
This means we can hook in to ''ChangesListInsertArticleLink'' (a hook which was introduced in 1.12 and is called only from a recentchanges page), and the first time it is called we can replace the ''$wgOut'' object with a replacement that runs the ''SpecialPageExecuteAfterPage'' hook if the content being outputted begins with an openening '''h4''' tag.
$diff = preg_replace('|>hist<|','>edit<',$diff);
 
$user .= "&nbsp;<small>$talk</small>";
 
</php>
 

Latest revision as of 08:48, 13 April 2009

Fix for MediaWiki 1.13

The problem is that the SpecialPageExecuteAfterPage hook doesn't get called by sub-classes of SpecialPage. In MediaWiki 1.12, the recentchanges specialpage was changed from the old-style execution method to a sub-class, and therefore prevented TransformChanges from working.

After analysing the flow of execution during the rendering of a special page I was able to find a means of hooking in to the rendered page. The webOutput method calls the builds the entire HTML output and then sends it all at once to the addHTML method of the global $wgOut object.

This means we can hook in to ChangesListInsertArticleLink (a hook which was introduced in 1.12 and is called only from a recentchanges page), and the first time it is called we can replace the $wgOut object with a replacement that runs the SpecialPageExecuteAfterPage hook if the content being outputted begins with an openening h4 tag.