-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Brion,
thanks for your quick answer!
On 25/09/10 00:27, Brion Vibber wrote:
Hi David! I've actually been peeking at this extension as I'd like to use something like this to generate scannable QR codes with Android software download links for other projects. :)
Yeah, I was really astonished that there wasn't already a qrcode extension.
- QrCodes are generated for pages that do not have or transclude a
{{#qrcode:}} function call, in this case properties [2,3,4].
I haven't fully traced out the execution, but I do notice a few things in the code that look suspicious.
It looks like you're naming the destination file based on the wiki page that has the {{#qrcode}} in it by pulling $wgTitle:
// Use this page's title as part of the filename (Also regenerates
qrcodes when the label changes). $this->_dstFileName = 'QR-'.$wgTitle->getDBKey().$append.'.png';
This might be the cause of some of your problems here... background jobs may run re-parses of other seemingly unconnected wiki pages during a request, and other fun things where $wgTitle isn't what you expect, and that might be one cause of it triggering with an unexpected title. You may find that it's more reliable to use $parser->getTitle(), which should definitely return the title for the page being actively parsed.
Ok, I'll try that one then, or not, as you suggest below.
More generally, using the calling page's title means that you can't easily put multiple codes on a single page, and the same code used on different pages will get copied unnecessarily.
Well you can use multiple codes on a single page, as demonstrated on the Sandbox [a] and made possible by the $append variable, but you're certainly right about the latter part.
I'd recommend naming the file using a hash of the properties used to generate the image, instead of naming it for the using page. This will make your code a bit more independent of where it gets called from, and will let you both put multiple code images on one page and let common images be shared among multiple pages.
Will do that too then.
One potential problem is garbage collection: a code that gets generated and used, then removed and not used again will still have been loaded into the system. This is an existing problem with things like the texvc math system, but is a bit more visible here because the images appear in the local uploads area within the wiki. (However they'll be deletable by admins, so not too awful!)
Having them uploaded was one of the main reasons I saved the images and don't just return a url to the src attribute of an image tag. But I guess you could have a bot run over it or I suppose there's a hook triggered on deleting a page which would allow to also delete qrcodes embedded into/linked to it.
- Looking at the database, the mixup hypothesis is confirmed:
It's possible that the internal uploading process interferes with global parsing state when it generates and saves the description page for the wiki; if so, fixing that may require jumping through some interesting hoops. :)
Well then let's hope that the $parser->getTitle() alternative solves the problem.
David
- -- The Hackerspace in Luxembourg! syn2cat a.s.b.l. - Promoting social and technical innovations 11, rue du cimetière | Pavillon "Am Hueflach" L-8018 Strassen | Luxembourg http://www.hackerspace.lu - ---- mailto:david@hackerspace.lu xmpp:kwisatz@jabber.hackerspaces.org mobile: +43 650 73 63 834 | +352 691 44 23 24 ++++++++++++++++++++++++++++++++++++++++++++ Wear your geek: http://syn2cat.spreadshirt.net