40px | This Lua module is used on 13,000,000+ pages, or roughly 293920% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. Transclusion count updated automatically (see documentation). |
40x40px | This 模块 is used {{#if:|{{{1}}}|in system messages}}. Changes to it can cause immediate changes to the Wikipedia user interface. {{#ifeq:828|6||To avoid large-scale disruption, any changes should first be tested in this 模块's [[{{#if:{{#ifeq:No glob|sandbox|1}}{{#ifeq:No globals|doc|1}}|模块:No globals|模块:No globals}}/sandbox|/sandbox]] or [[{{#if:{{#ifeq:No glob|sandbox|1}}{{#ifeq:No globals|doc|1}}|模块:No globals|模块:No globals}}/testcases|/testcases]] subpage, or in your own user space. The tested changes can then be added in one single edit to this 模块.}} Please discuss any changes {{#if:|at [[{{{2}}}]]|on the [[{{#if:{{#ifeq:No glob|sandbox|1}}{{#ifeq:No globals|doc|1}}|模块讨论:No globals|模块讨论:No globals}}|talk page]]}} before implementing them. |
{{#switch:
{{#if: | | {{#ifeq:模块|模块 | module | other }} }}| module =
{{#switch: protected
| pre-alpha | prealpha | pa = 40x40px | alpha | a = 26x26px | beta | b = 40x40px | release | r | general | g = 40x40px | protected | protect | p = [[File:{{#switch:Lua错误 在模块:Effective_protection_level的第14行:attempt to index local 'title' (a nil value)|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]] | semiprotected | semiprotect | semi =40x40px}} | {{#switch: protected
| pre-alpha | prealpha | pa = This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | alpha | a = This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | beta | b = This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | release | r | general | g = This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | protected | protect | p = This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | semiprotected | semiprotect | semi = This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is semi-protected from editing.{{#switch: No globals|doc|sandbox= | {{#ifeq: | true | | }} }} | #default = 模板:Error}} |
| other | #default = 模板:Error }}
This module causes an error if any nil global is read or if any global is written to, with the exception of arg. To use, add <syntaxhighlight lang="lua" inline>require('Module:No globals')</syntaxhighlight> to the top of the module using it. The arg variable is excluded because it is necessary for Scribunto's require function to work properly. (See the Scribunto source code here.)
See also编辑
- Module:Log globals – adds all nil global reads/writes to the lua log
{{#if:{{#ifeq:No glob|sandbox|1}}{{#ifeq:No globals|doc|1}}|| }}
local mt = getmetatable(_G) or {} function mt.__index (t, k) if k ~= 'arg' then error('Tried to read nil global ' .. tostring(k), 2) end return nil end function mt.__newindex(t, k, v) if k ~= 'arg' then error('Tried to write global ' .. tostring(k), 2) end rawset(t, k, v) end setmetatable(_G, mt)