Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to write to Scribunto Module namespace #28

Closed
l1ghtsword opened this issue Oct 26, 2020 · 4 comments
Closed

Unable to write to Scribunto Module namespace #28

l1ghtsword opened this issue Oct 26, 2020 · 4 comments

Comments

@l1ghtsword
Copy link

l1ghtsword commented Oct 26, 2020

Hello,

I am working on a automated task handler to do various update and maintenance routines and ran into a bit of an issue with Jwiki only when attempting to write to Module:<pagename>...

I'm honestly stumped as to what is causing the issue, i confirmed bot permissions are set and added ".withDebug(true)" to the builder to the Wiki object.

I can see it is loading the namespace as:

"828": {
        "id": 828,
        "case": "first-letter",
        "subpages": "",
        "canonical": "Module",
        "*": "Module"
      },

When it attempts to create a page or edit an existing page (overwrite) with the String "testpage" it gives:

DEBUG: [L1ghtsword @ wiki.<domain>.net]: {
  "error": {
    "code": "scribunto-lua-error-location",
    "info": "Lua error at line 1: \u0027\u003d\u0027 expected near \u0027\u0027.",
    "*": "See https://wiki.<domain>.net/wiki/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at \u0026lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce\u0026gt; for notice of API deprecations and breaking changes."
  }
}

I worked out that " \u0027 " is " ' " and " \u003d " is " = " but i'm not sure why these are being prepended to the wiki text when editing... Is it possible to prevent that from happening when trying to write to id 828?

@fastily
Copy link
Owner

fastily commented Oct 26, 2020

Hi @l1ghtsword,

iirc MediaWiki (by default) prevents you from saving syntactically incorrect Lua. Instead of using the string test page, try a string like

print("Hello World!")

@l1ghtsword
Copy link
Author

l1ghtsword commented Oct 26, 2020

@fastily
oh my goodness you're right... that explains why the test failed...

Okay, more background.
I'm writing this routine to add a return statement which when called will return a table of named keys and values.

It just so happens one of those names happens to contain a letter, '3rd_age_bow'
Now, i know when creating the String to surround the String name in apostrophes to cast it as a string. I also double checked and could create the page in modules by writing name = '3rd_age_bow'

However, when i attempt to do this via Jwiki, it seems to parse as Malformed number anyway.
java code:
(name = 3rd_age_bow)

String table = "return {\n" + 
               "    name                 = \'" + name + "\'\n" +
               "}";
wiki.edit("Module:Items/3rd_age_bow", table, "a reason");
DEBUG: [L1ghtsword @ wiki.<domain>.net]: {
  "error": {
    "code": "scribunto-lua-error-location",
    "info": "Lua error at line 2: malformed number near \u00273rd_age_bow\u0027.",
    "*": "See https://wiki.<domain>.net/wiki/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at \u0026lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce\u0026gt; for notice of API deprecations and breaking changes."
  }
}

@fastily
Copy link
Owner

fastily commented Oct 26, 2020

I can't reproduce this error

What happens when you add

System.out.println(table);

after wiki.edit("Module:Items/3rd_age_bow", table, "a reason");

Also, could you please share the version of (visit Special:Version) of Lua and MediaWiki are you using and/or any other relevant pieces of code?

@l1ghtsword
Copy link
Author

l1ghtsword commented Oct 27, 2020

Okay i spent a bit more time on this (thank you for confirming on your end btw)
Now that i know it's just me sending bad LUA i paid closer attention to the error's and row/ column entries. There are multiple attributes, separated by line breaks. I needed to do a bit more string manipulation to remove random apostrophes, add a comma to the end of each line before the line break in all the declarations and test a bunch.

Long story short, i found all the pieces i was missing and have ruled out Jwiki as the issue entirely.
There is no issue i can see with writing to NS 828 outside of make sure what you write is valid in LUA.

Thanks a bunch, appreciate the quick responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants