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

From Organic Design wiki
(1.13's HTML: only need li's)
(remove regex info from last debugging notes)
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
  
 
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.
 
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.
 
=== Current state ===
 
The current version (1.1.0) is successfully implementing the hack to ensure that the ''SpecialPageExecuteAfterPage'' gets called properly and gives the extension access to modify the output, but unfortunately some other HTML changes have also occurred since 1.12 and so the patterns aren't matching properly. This shouldn't be too difficult to fix however, so it should be ready soon.
 
 
=== 1.11's HTML ===
 
{{code|<pre>
 
<li>(<a href="/wiki/index.php?title=Config:Template/LocalSettings.php&amp;curid=9977&amp;diff=89609&amp;oldid=89510" title="Config:Template/LocalSettings.php"  tabindex="2">diff</a>) (<a href="/wiki/index.php?title=Config:Template/LocalSettings.php&amp;curid=9977&amp;action=history" title="Config:Template/LocalSettings.php">hist</a>) . .    <a href="/Config:Template/LocalSettings.php" title="Config:Template/LocalSettings.php">Config:Template/LocalSettings.php</a>‎; 08:56 . . <span class='mw-plusminus-pos'>(+47)</span> . . <a href="/User:Nad" title="User:Nad">Nad</a> (<a href="/User_talk:Nad" title="User talk:Nad">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a> | <a href="/Special:Blockip/Nad" title="Special:Blockip/Nad">block</a>) <span class="comment">(check gchart4mw)</span></li>
 
<li>(<a href="/wiki/index.php?title=User_talk:Nad&amp;curid=1399&amp;diff=89608&amp;oldid=89607" title="User talk:Nad"  tabindex="3">diff</a>) (<a href="/wiki/index.php?title=User_talk:Nad&amp;curid=1399&amp;action=history" title="User talk:Nad">hist</a>) . .  <strong class="mw-watched"> <a href="/User_talk:Nad" title="User talk:Nad">User talk:Nad</a></strong>‎; 08:44 . . <span class='mw-plusminus-pos'>(+67)</span> . . <a href="/User:Nad" title="User:Nad">Nad</a> (<a href="/User_talk:Nad" title="User talk:Nad">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a> | <a href="/Special:Blockip/Nad" title="Special:Blockip/Nad">block</a>) <span class="comment">(<span class="autocomment"><a href="/User_talk:Nad#Wiki.pl_Stability" title="User talk:Nad">→</a>Wiki.pl Stability -</span> ;-))</span></li>
 
<li>(<a href="/wiki/index.php?title=User_talk:Nad&amp;curid=1399&amp;diff=89607&amp;oldid=84960" title="User talk:Nad"  tabindex="4">diff</a>) (<a href="/wiki/index.php?title=User_talk:Nad&amp;curid=1399&amp;action=history" title="User talk:Nad">hist</a>) . .  <strong class="mw-watched"> <a href="/User_talk:Nad" title="User talk:Nad">User talk:Nad</a></strong>‎; 08:43 . . <span class='mw-plusminus-pos'>(+797)</span> . . <a href="/User:Sven" title="User:Sven">Sven</a> (<a href="/User_talk:Sven" title="User talk:Sven">Talk</a> | <a href="/Special:Contributions/Sven" title="Special:Contributions/Sven">contribs</a> | <a href="/Special:Blockip/Sven" title="Special:Blockip/Sven">block</a>) <span class="comment">(New section: <a href="/User_talk:Nad#Wiki.pl_Stability" title="User talk:Nad">Wiki.pl Stability</a>)</span></li>
 
<li>(<a href="/Special:Log/upload" title="Special:Log/upload">Upload log</a>); 03:56 . . <a href="/wiki/index.php?title=User:Le_dunff&amp;action=edit" class="new" title="User:Le dunff">Le dunff</a> (<a href="/wiki/index.php?title=User_talk:Le_dunff&amp;action=edit" class="new" title="User talk:Le dunff">Talk</a> | <a href="/Special:Contributions/Le_dunff" title="Special:Contributions/Le dunff">contribs</a> | <a href="/Special:Blockip/Le_dunff" title="Special:Blockip/Le dunff">block</a>) <span class="comment">(uploaded &quot;<a href="/Image:Le_dunff.png" title="Image:Le dunff.png">Image:Le dunff.png</a>&quot;)</span></li>
 
<li>(<a href="/wiki/index.php?title=Server_log&amp;curid=9501&amp;diff=89605&amp;oldid=89562&amp;rcid=88506" title="Server log"  tabindex="6">diff</a>) (<a href="/wiki/index.php?title=Server_log&amp;curid=9501&amp;action=history" title="Server log">hist</a>) . .  <span class="unpatrolled">!</span> <strong class="mw-watched"> <a href="/Server_log" title="Server log">Server log</a></strong>‎; 03:20 . . <span class='mw-plusminus-pos'>(+51)</span> . . <a href="/User:Server" title="User:Server">Server</a> (<a href="/wiki/index.php?title=User_talk:Server&amp;action=edit" class="new" title="User talk:Server">Talk</a> | <a href="/Special:Contributions/Server" title="Special:Contributions/Server">contribs</a> | <a href="/Special:Blockip/Server" title="Special:Blockip/Server">block</a>) <span class="comment">(DB backup: all-2008-12-19.sql.7z (842.3MB/46.4MB))</span></li>
 
</pre>}}
 
 
=== 1.13's HTML ===
 
{{code|<pre>
 
<li>(<a href="/Special:Log/protect" title="Special:Log/protect">Protection log</a>); 08:32 . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) protected "<a href="/Sandbox" title="Sandbox">Sandbox</a>" <span class="comment">(see if this shows in changes for anon [edit=sysop:move=sysop:read=sysop])</span></li>
 
<li>(<a href="/Special:Log/rights" title="Special:Log/rights">User rights log</a>); 08:19 . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) changed group membership for <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">User:Nad</a> from bot, bureaucrat, sysop to bureaucrat, sysop</li>
 
<li>(<a href="/wiki/index.php?title=Help:Contents&amp;curid=11&amp;diff=63&amp;oldid=62" title="Help:Contents"  tabindex="3">diff</a>) (<a href="/wiki/index.php?title=Help:Contents&amp;curid=11&amp;action=history" title="Help:Contents">hist</a>) . . <span class="bot">b</span>  <a href="/Help:Contents" title="Help:Contents">Help:Contents</a>‎; 08:17 . . <span class='mw-plusminus-pos'>(+5)</span> . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) <span class="comment">(dsgsd)</span></li>
 
<li>(diff) (<a href="/wiki/index.php?title=Help:Contents&amp;curid=11&amp;action=history" title="Help:Contents">hist</a>) . . <span class="newpage">N</span><span class="bot">b</span>  <a href="/Help:Contents" title="Help:Contents">Help:Contents</a>‎; 08:17 . . <span class='mw-plusminus-pos'>(+9)</span> . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) <span class="comment">(New page: sdfgsdgsd)</span></li>
 
<li>(diff) (<span class="unreadable">) . . <span class="newpage">N</span><span class="minor">m</span><span class="bot">b</span>  <a href="/Sandbox" title="Sandbox">Sandbox</span>‎; 06:36 . . <span class='mw-plusminus-pos'>(+6)</span> . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) <span class="comment">(New page: dsgsdg)</span></li>
 
<li>(<a href="/Special:Log/delete" title="Special:Log/delete">Deletion log</a>); 06:35 . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) deleted "<span class="unreadable">" <span class="comment">(content was: '__TOC__ == Foo ==...' (and the only contributor was '<a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">Nad</span>'))</span></li>
 
<li>(<a href="/Special:Log/rights" title="Special:Log/rights">User rights log</a>); 06:35 . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) changed group membership for <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">User:Nad</a> from bureaucrat, sysop to bureaucrat, sysop, bot</li>
 
<li>(diff) (<a href="/wiki/index.php?title=MediaWiki:Common.css&amp;curid=9&amp;action=history" title="MediaWiki:Common.css">hist</a>) . . <span class="newpage">N</span>  <a href="/MediaWiki:Common.css" title="MediaWiki:Common.css">MediaWiki:Common.css</a>‎; 06:02 . . <span class='mw-plusminus-pos'>(+590)</span> . . <a href="/wiki/index.php?title=User:Nad&amp;action=edit&amp;redlink=1" class="new" title="User:Nad (not yet written)">Nad</a> (<a href="/wiki/index.php?title=User_talk:Nad&amp;action=edit&amp;redlink=1" class="new" title="User talk:Nad (not yet written)">Talk</a> | <a href="/Special:Contributions/Nad" title="Special:Contributions/Nad">contribs</a>) <span class="comment">(New page: table.changes ...)</span></li>
 
</pre>}}
 

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.