Extension talk:FileLink

Guys a bug when running this on MW 1.10 Internal error Detected bug in an extension! Hook filelinkDo failed to return a value; should return true to continue hook processing or false to abort.

Backtrace:


 * 1) 0 /var/www/html/mediawiki/includes/Parser.php(332): wfRunHooks('ParserBeforeTid...', Array)
 * 2) 1 /var/www/html/mediawiki/includes/Article.php(3017): Parser->parse('?Edit [[Hea...', Object(Title), Object(ParserOptions), true, true, 915)
 * 3) 2 /var/www/html/mediawiki/includes/Article.php(841): Article->outputWikiText('?Edit [[Hea...', false)
 * 4) 3 /var/www/html/mediawiki/includes/Wiki.php(383): Article->view
 * 5) 4 /var/www/html/mediawiki/includes/Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
 * 6) 5 /var/www/html/mediawiki/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest))
 * 7) 6 {main}

Bug with MediaWiki 1.11.0
I installed and used the FileLink-Extension with mediawiki version 1.10.0 without problem, but after upgrading to version 1.11.0 I get the following error message whenever I try to edit a page.

Detected bug in an extension! Hook filelinkDo failed to return a value; should return true to continue hook processing or false to abort.

Backtrace:


 * 1) 0 /opt/lampp/htdocs/_fhbwiki/includes/Parser.php(332): wfRunHooks('ParserBeforeTid...', Array)
 * 2) 1 /opt/lampp/htdocs/_fhbwiki/includes/OutputPage.php(474): Parser->parse('Abbrechen', Object(Title), Object(ParserOptions), true, true, NULL)
 * 3) 2 /opt/lampp/htdocs/_fhbwiki/includes/GlobalFunctions.php(593): OutputPage->parse('Abbrechen', true, true)
 * 4) 3 /opt/lampp/htdocs/_fhbwiki/includes/EditPage.php(1065): wfMsgExt('cancel', Array)
 * 5) 4 /opt/lampp/htdocs/_fhbwiki/includes/EditPage.php(433): EditPage->showEditForm
 * 6) 5 /opt/lampp/htdocs/_fhbwiki/includes/EditPage.php(285): EditPage->edit
 * 7) 6 /opt/lampp/htdocs/_fhbwiki/includes/Wiki.php(437): EditPage->submit
 * 8) 7 /opt/lampp/htdocs/_fhbwiki/includes/Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
 * 9) 8 /opt/lampp/htdocs/_fhbwiki/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest))
 * 10) 9 {main}

Fix for 1.11.0 +
Every function which is registered as a MediaWiki hook must return something so just add TRUE to any Return ;


 * Thanks for the tipp - after I added a true to the one and only return I could find in extensions/FileLinkExtension.0.2/FileLinkExtension.php and also added a return true; to the end of the file/function I don't get the errors anymore, but neither do I get the filelink-button in the edit mode. :(


 * Does anybody have an idea how to fix this?
 * --Katwol 10:46, 30 January 2008 (UTC)

Fix for 1.12.0 +
This version of FileLinkExtension.php works with mediawiki 1.12
 * --Mitchelln 11:45, 28 March 2008 (UTC)

<?php ##_____________________________________________________________________ ##    copyright 2006 Assela Pathirana ##   UNDER GNU GPL ##   Version 0.2 (2006 Sept) ##_____________________________________________________________________ ##  ##    This program is free software; you can redistribute it and/or modify ##   it under the terms of the GNU General Public License as published by  ##    the Free Software Foundation; either version 2 of the License, or  ##    (at your option) any later version. ## ##    This program is distributed in the hope that it will be useful, ##   but WITHOUT ANY WARRANTY; without even the implied warranty of  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##   GNU General Public License for more details. ## ##    You should have received a copy of the GNU General Public License ##   along with this program; if not, write to the Free Software ##   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA ## ##    Inspired by gallery2wiki by Andres Obrero  ##

$wgExtensionFunctions[] = "wfFilelinkExtension";

function wfFilelinkExtension { global $wgParser; global $wgHooks; $wgHooks['ParserBeforeTidy'][] = 'filelinkDo' ; } function filelinkDo (&$parser, &$text){ static $done=0; if ( $done ) { return TRUE; } $done=1; global $wgRequest; global $wgFilelinkExtensionPath; global $wgScriptPath; global $wgUser; global $IP; $sk=$wgUser->getSkin; $action = $wgRequest->getVal( 'action', false ); //Are we in a edit page AND are we allowed to edit if(strtolower($action) == "edit" && $wgUser->isAllowed('edit') && $wgUser->isAllowed('edit')){ //strtolower^^ is not needed, but to be safe //now we know that we are in the edit dialog so add some javascript code to add a new button // This is done by mainfile.js //However, dynamic variables must be given externally. //So here are the neede variables for mainfile.js $vars= "   ;   var filelinkextension_iconimage='"."$wgScriptPath/$wgFilelinkExtensionPath"."/filelinkbutton.jpg' //global variable  var filelinkextension_childfile='"."$wgScriptPath/$wgFilelinkExtensionPath"."/childfile.html' //global variable  "; //Read in the mainfile.js $jscript=file_get_contents("$IP/$wgFilelinkExtensionPath/mainfile.js"); $text="  " .$jscript. "        //Just an entry point for the child window to call insertTags function in wikibits          function insertTagsInMe(one,two,three){              insertTags(one,two,three);          }        ".$text; $text=$vars.$text; }else{ //Either not an edit attempt, or not logged in    //Do nothing be silent without bothering innocent visitors. return false; } return true; } ?>
 * 1) new part###########


 * Hi Mitchelln,
 * thanks for posting the adapted version for mediawiki 1.12.0!
 * After installing it I get no error-messages, but I do not get the extra-button for starting the file-link-"GUI". :-(
 * Can you (or anybody else) give me a tipp how to debug this? Thanks!
 * --Katwol 07:37, 2 April 2008 (UTC)