On 11/4/05, Magnus Manske magnus_manske@users.sourceforge.net wrote:
Update of /cvsroot/wikipedia/phase3/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21820/includes
Modified Files: EditPage.php Log Message: Additional hook
Index: EditPage.php
RCS file: /cvsroot/wikipedia/phase3/includes/EditPage.php,v retrieving revision 1.231 retrieving revision 1.232 diff -C2 -d -r1.231 -r1.232 *** EditPage.php 3 Nov 2005 22:40:02 -0000 1.231 --- EditPage.php 4 Nov 2005 15:32:26 -0000 1.232
*** 155,158 **** --- 155,161 ---- function edit() { global $wgOut, $wgUser, $wgRequest, $wgTitle;
$l = strlen ( $wgOut->mBodytext ) ;
wfRunHooks( 'AlternateEdit', array( &$this ) ) ;
if ( $l != strlen ( $wgOut->mBodytext ) ) return ; # Something's changed the text, my work here is done $fname = 'EditPage::edit';
This is the wrong way to do something like this, it should look like:
if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) ) return;
That way you avoid two calls to strlen() and allow the extension using the hook to override the function even if it doesn't change $wgOut->mBodyText (and you should really use the ->getHTML() accessor if you wanted it)
wikitech-l@lists.wikimedia.org