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)


 * Hi again,
 * I don't know why (or how in detail), but I managed to solve the missing-button-problem myself:
 * I added a line alert("FileLinkExtension wird gestartet"); right at the beginning of the function addFilelinkButton in mainfile.js and when I started to edit an article the alert-box and(!!!) the button appeared!
 * And - curiouser and curiouser - the button still appears, even though I commentet the line out, so the alert-box doesn't appear anymore. :)
 * --Katwol 10:17, 2 April 2008 (UTC)


 * Very odd. It just worked for me!
 * --Mitchelln 09:17, 3 April 2008 (UTC)

firefox 3 issues
Inside the updateParent function, you must have: netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead'); as the first line. Then inside Firefox, you must edit user.js or go to about:config and set signed.applets.codebase_principal_support to 'true'. Then when the form is presented, the user will be presented with the option of denying or allowing access to this script. One must allow it for this extension to work right. --Otheus 09:46, 10 July 2008 (UTC)


 * Help! Where exactly do I find the updateParent function?
 * I hope your fix is going to make the full path's reappear, when I use the FileLink-Extension, because with Firefox3 I suddenly only get [file:///example.txt descriptive name here] without any path at all. :-(
 * --Katwol 14:15, 10 July 2008 (UTC)


 * I've found it myself - it's in [...]/extensions/FileLinkExtension.0.2/childfile.html
 * and the fix works on the missing file-path. :-)


 * But now I've got another problem: without the fix the extension won't work with FF3, but with it, the extension won't work with FF2 anymore. :-(
 * I need it to work with both FF-versions simultaniously. Is there a way to make the fix sensitive to the firefox-version in use?
 * --Katwol 13:03, 17 July 2008 (UTC)


 * I've "solved" my FF-problem by updating all PCs to Firefox 3. ;-)
 * --Katwol 13:26, 8 August 2008 (UTC)

(RESOLVED) button not displayed
I have mw 1.12 and have run the firefox 3 update. However the button does not display on new pages. You have to save the page and then edit it again for the filelink button to show.. it's rather annoying, does anyone else have that problem, or know how to fix it? Thanks, Matt 13:19, 1 August 2008 (UTC)

Answer: see extension page section on preview button

Error 405
Does anybody get a 405 error when clicking on "OK" button? The error message is

405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

I get it with Firefox and IIS. The browse button works fine without a hitch. I have it working with Firefox and a couple of changes in the about:config but I cant remember how I did it. But all my users are using IE anyway. So i need it to work in IE. I know that I dont need to do anything on server side because it works with my browser with extnsion ant the changes in the about:config. I'm looking for a setting change in IE.

Thanks, --abrillon 20:20, 24 March 2009 (UTC)