Last modified: 2013-07-24 15:32:53 UTC
some templates on commons, e.g., Template:Institution, include modules that use lua scripting. exporting those templates and then importing them into another wiki causes an error - “Import failed: Format text/plain is not supported for content model Scribunto error”. in LocalSettings.php -------------------- require_once("$IP/extensions/ParserFunctions/ParserFunctions.php"); require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php"); require_once("$IP/extensions/Scribunto/Scribunto.php"); $wgScribuntoDefaultEngine = 'luastandalone'; $wgScribuntoUseGeSHi = true; $wgScribuntoUseCodeEditor = true; require_once("$IP/extensions/TemplateSandbox/TemplateSandbox.php"); $wgExtraNamespaces[828] = 'Module'; $wgExtraNamespaces[829] = 'Module_talk'; steps to reproduce ------------------ 1. go to http://commons.wikimedia.org/wiki/Special:Export 2. export the Template:Institution √ Include only the current revision, not the full history √ Include templates √ Save as file 3. go to local wiki http://mywiki/wiki/Special:Import 4. select the file saved in step 2. results ------- 1. all templates import without issue 2. Import failed: Format text/plain is not supported for content model Scribunto 3. outdated history link gets created for the module page, e.g., http://mywiki/wiki/Module:Languages - The revision #0 of the page named "Languages" does not exist. This is usually caused by following an outdated history link to a page that has been deleted. Details can be found in the deletion log. expected results ---------------- 1. all templates import without issue 2. all modules import without issue current method for avoiding the issue ------------------------------------- 1. in the exported xml file remove any Module pages 2. create the Module pages manually 3. import using the modified export file
Another method to avoid the issue is to replace "<format>text/plain</format>" in the dump with whatever format your wiki is expecting. You could also upgrade Scribunto on your wiki to a version that includes Gerrit change #61468. *** This bug has been marked as a duplicate of bug 45750 ***
(In reply to comment #1) thanks brad, i can confirm that the Gerrit change #61468 took care of this issue. regarding the change to "<format>text/plain</format>", how would i find out what format the wiki is expecting?
(In reply to comment #2) > regarding > the change to "<format>text/plain</format>", how would i find out what format > the wiki is expecting? One way would be to export a module page from your wiki and see what format it says. Or you could ask the API, something like https://en.wikipedia.org/w/api.php?format=jsonfm&action=query&prop=revisions&rvprop=content&titles=Module:Bananas
(In reply to comment #3) the format of the modules in the export of Template:Institution is <format>text/plain</format>, so there’s no change to <format> in that case that would help, it still fails without applying the Gerrit change you mentioned. in that Gerrit change, is the isSupportedFormat method necessary? i was able to apply the change to the constructor only - $formats = array( 'CONTENT_FORMAT_TEXT' ) to $formats = array( CONTENT_FORMAT_TEXT ) and that took care of the issue; i didn’t need to add the isSupportedFormat method.
(In reply to comment #4) > (In reply to comment #3) > the format of the modules in the export of Template:Institution is > <format>text/plain</format>, so there’s no change to <format> in that case > that You misunderstood me, I think. What do you get if you export a module page from "mywiki"? Or more correctly, what did you get before applying the patch that let you import? > in that Gerrit change, is the isSupportedFormat method necessary? i was able > to > apply the change to the constructor only - $formats = array( > 'CONTENT_FORMAT_TEXT' ) to $formats = array( CONTENT_FORMAT_TEXT ) and that > took care of the issue; i didn’t need to add the isSupportedFormat method. IIRC, it makes existing module pages continue to work if you have $wgContentHandlerUseDB set to true (which is the default).
(In reply to comment #5) > (In reply to comment #4) > > (In reply to comment #3) > > the format of the modules in the export of Template:Institution is > > <format>text/plain</format>, so there’s no change to <format> in that case > > that > > You misunderstood me, I think. What do you get if you export a module page > from > "mywiki"? Or more correctly, what did you get before applying the patch that > let you import? yes, i misunderstood what you meant by what do i get when i export the module. when i export Module:Date from my local dev wiki without the patch, i get <format>CONTENT_FORMAT_TEXT</format>. with just the change to the __construct method i get <format>text/plain</format>. in any case, it looks like the latest version of Scribunto contains the patch including the isSupportedFormat method and everything works fine with that so i’m glad to see that. thanks for your continued follow-up.