Last modified: 2014-07-08 13:09:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T69498, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 67498 - Frames aren't available outside of functions in modules
Frames aren't available outside of functions in modules
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Unprioritized normal with 1 vote (vote)
: ---
Assigned To: Brad Jorsch
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-03 21:50 UTC by Jackmcbarn
Modified: 2014-07-08 13:09 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jackmcbarn 2014-07-03 21:50:03 UTC
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.
Comment 1 Gerrit Notification Bot 2014-07-07 16:58:53 UTC
Change 144478 had a related patch set uploaded by Anomie:
Improve mw.getCurrentFrame handling

https://gerrit.wikimedia.org/r/144478
Comment 2 Gerrit Notification Bot 2014-07-07 18:26:50 UTC
Change 144478 merged by jenkins-bot:
Improve mw.getCurrentFrame handling

https://gerrit.wikimedia.org/r/144478
Comment 3 Gerrit Notification Bot 2014-07-07 20:15:47 UTC
Change 144511 had a related patch set uploaded by Jackmcbarn:
Improve mw.getCurrentFrame handling

https://gerrit.wikimedia.org/r/144511
Comment 4 Gerrit Notification Bot 2014-07-08 13:09:09 UTC
Change 144511 merged by jenkins-bot:
Improve mw.getCurrentFrame handling

https://gerrit.wikimedia.org/r/144511

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links