Hello all, sorry if this is a noobish question, but I get strange problems when trying to upload a newly generated image from within an extension. It's seems the title of the calling page gets corrupted getting the name of the uploaded file), and sometimes the resulting image, despite being called File:XXX, end up in the main namespace. At times there are also a lot of UNIQ/QINU-strings in the page. These problems seem to appear both when doing the upload from the job queue, and when uploading at once. I am, by the way, not using any globals like $wgOut.> > This is the actual upload lines (it inside an Semantic MediaWiki Result Printer class, but I've had the same problems when trying it in an ordinary MediaWiki parser function): $ulUser= User::newFromName($myUserName); $mUpload = new UploadFromUrl(); $mUpload->initializePathInfo ( $filename, $tempdir, false ); $status = $mUpload->getLocalFile()->upload( $tempdir . '/' . $filename, $tempdir, $description, 0, false, false, $ulUser ); if ( $status->isGood() ) { unlink($tempdir . '/' . $filename); return true; } else { ... } I'm not a programmer, so the code is probably quite ugly. I'm not even sure this is the proper way to do a file upload, but it's the only way I found working. Any help would be greatly appreciated (e.g. examples of extensions doing file uploads, making it work)! Best regardsLeo Wallentin Leonard Wallentin leo_wallentin at hotmail.com +46 (0)735-933 543http://s%C3%A4songsmat.nu
http://nairobikoll.se/ http://twitter.com/leo_wallentin Skype: leo_wallentin
This type of issue (lots of UNIQ_....'s in output) is usually caused by calling $wgParser->parse() method when already parsing stuff. In this case you're probably already parsing stuff because its being executed from an smw printer (I'm not familar with SMW, but i assume that's called from some parser hook or something). I would guess (but haven't checked) that the upload method calls $wgParser->parse somewhere along the line, probably when its creating the image description page. The babel extension had a very similar issue with auto-creating categories. See the BabelAutoCreate.class.php file in the Babel extension.
Cheers, -bawolff
Thank you Bawolff, that was really helpful! Sounds like that could very well be the case.I will take a close look at the Babel extension. /Leo