https://bugzilla.wikimedia.org/show_bug.cgi?id=67498

            Bug ID: 67498
           Summary: Frames aren't available outside of functions in
                    modules
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Scribunto
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
       Web browser: ---
   Mobile Platform: ---

Create the following as Module:Foo:

local p = {}

local f = mw.getCurrentFrame()

function p.main(frame)
    return 'The title of the current frame is ' .. f:getTitle()
end

return p

When {{#invoke:Foo|main}} is used in a page, a script error will be generated
because f is nil. Note the bug is not present in the console, where running
=p.main() will produce the expected result.

Also, if the following is created as Module:Bar:

local p = {}

local d = os.date()

function p.main(frame)
    return 'The date when the module was ran was ' .. d
end

return p

{{#invoke:Bar|main}} will return a script error because the TTL logic in
os.date() assumes that frames are available at this point, when in fact they
are not. Again, this only malfunctions when called from wikitext; =p.main()
works properly from the console.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to