Defines.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?php
  2. /**
  3. * A few constants that might be needed during LocalSettings.php.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. */
  22. require_once __DIR__ . '/libs/mime/defines.php';
  23. require_once __DIR__ . '/libs/rdbms/defines.php';
  24. use Wikimedia\Rdbms\IDatabase;
  25. /**
  26. * @defgroup Constants MediaWiki constants
  27. */
  28. # Obsolete aliases
  29. /** @{
  30. * Obsolete IDatabase::makeList() constants
  31. * These are also available as Database class constants
  32. */
  33. define( 'LIST_COMMA', IDatabase::LIST_COMMA );
  34. define( 'LIST_AND', IDatabase::LIST_AND );
  35. define( 'LIST_SET', IDatabase::LIST_SET );
  36. define( 'LIST_NAMES', IDatabase::LIST_NAMES );
  37. define( 'LIST_OR', IDatabase::LIST_OR );
  38. /** @} */
  39. /** @{
  40. * Virtual namespaces; don't appear in the page database
  41. */
  42. define( 'NS_MEDIA', -2 );
  43. define( 'NS_SPECIAL', -1 );
  44. /** @} */
  45. /** @{
  46. * Real namespaces
  47. *
  48. * Number 100 and beyond are reserved for custom namespaces;
  49. * DO NOT assign standard namespaces at 100 or beyond.
  50. * DO NOT Change integer values as they are most probably hardcoded everywhere
  51. * see T2696 which talked about that.
  52. */
  53. define( 'NS_MAIN', 0 );
  54. define( 'NS_TALK', 1 );
  55. define( 'NS_USER', 2 );
  56. define( 'NS_USER_TALK', 3 );
  57. define( 'NS_PROJECT', 4 );
  58. define( 'NS_PROJECT_TALK', 5 );
  59. define( 'NS_FILE', 6 );
  60. define( 'NS_FILE_TALK', 7 );
  61. define( 'NS_MEDIAWIKI', 8 );
  62. define( 'NS_MEDIAWIKI_TALK', 9 );
  63. define( 'NS_TEMPLATE', 10 );
  64. define( 'NS_TEMPLATE_TALK', 11 );
  65. define( 'NS_HELP', 12 );
  66. define( 'NS_HELP_TALK', 13 );
  67. define( 'NS_CATEGORY', 14 );
  68. define( 'NS_CATEGORY_TALK', 15 );
  69. /** @} */
  70. /** @{
  71. * Cache type
  72. */
  73. define( 'CACHE_ANYTHING', -1 ); // Use anything, as long as it works
  74. define( 'CACHE_NONE', 0 ); // Do not cache
  75. define( 'CACHE_DB', 1 ); // Store cache objects in the DB
  76. define( 'CACHE_MEMCACHED', 2 ); // MemCached, must specify servers in $wgMemCacheServers
  77. define( 'CACHE_ACCEL', 3 ); // APC or WinCache
  78. /** @} */
  79. /** @{
  80. * Antivirus result codes, for use in $wgAntivirusSetup.
  81. */
  82. define( 'AV_NO_VIRUS', 0 ); # scan ok, no virus found
  83. define( 'AV_VIRUS_FOUND', 1 ); # virus found!
  84. define( 'AV_SCAN_ABORTED', -1 ); # scan aborted, the file is probably immune
  85. define( 'AV_SCAN_FAILED', false ); # scan failed (scanner not found or error in scanner)
  86. /** @} */
  87. /** @{
  88. * Anti-lock flags
  89. * Was used by $wgAntiLockFlags, which was removed with 1.25
  90. * Constants kept to not have warnings when used in LocalSettings
  91. */
  92. define( 'ALF_PRELOAD_LINKS', 1 ); // unused
  93. define( 'ALF_PRELOAD_EXISTENCE', 2 ); // unused
  94. define( 'ALF_NO_LINK_LOCK', 4 ); // unused
  95. define( 'ALF_NO_BLOCK_LOCK', 8 ); // unused
  96. /** @} */
  97. /** @{
  98. * Date format selectors; used in user preference storage and by
  99. * Language::date() and co.
  100. */
  101. define( 'MW_DATE_DEFAULT', 'default' );
  102. define( 'MW_DATE_MDY', 'mdy' );
  103. define( 'MW_DATE_DMY', 'dmy' );
  104. define( 'MW_DATE_YMD', 'ymd' );
  105. define( 'MW_DATE_ISO', 'ISO 8601' );
  106. /** @} */
  107. /** @{
  108. * RecentChange type identifiers
  109. */
  110. define( 'RC_EDIT', 0 );
  111. define( 'RC_NEW', 1 );
  112. define( 'RC_LOG', 3 );
  113. define( 'RC_EXTERNAL', 5 );
  114. define( 'RC_CATEGORIZE', 6 );
  115. /** @} */
  116. /** @{
  117. * Article edit flags
  118. */
  119. define( 'EDIT_NEW', 1 );
  120. define( 'EDIT_UPDATE', 2 );
  121. define( 'EDIT_MINOR', 4 );
  122. define( 'EDIT_SUPPRESS_RC', 8 );
  123. define( 'EDIT_FORCE_BOT', 16 );
  124. define( 'EDIT_DEFER_UPDATES', 32 ); // Unused since 1.27
  125. define( 'EDIT_AUTOSUMMARY', 64 );
  126. define( 'EDIT_INTERNAL', 128 );
  127. /** @} */
  128. /** @{
  129. * Hook support constants
  130. */
  131. define( 'MW_SUPPORTS_PARSERFIRSTCALLINIT', 1 );
  132. define( 'MW_SUPPORTS_LOCALISATIONCACHE', 1 );
  133. define( 'MW_SUPPORTS_CONTENTHANDLER', 1 );
  134. define( 'MW_EDITFILTERMERGED_SUPPORTS_API', 1 );
  135. /** @} */
  136. /** Support for $wgResourceModules */
  137. define( 'MW_SUPPORTS_RESOURCE_MODULES', 1 );
  138. /** @{
  139. * Allowed values for Parser::$mOutputType
  140. * Parameter to Parser::startExternalParse().
  141. * Use of Parser consts is preferred:
  142. * - Parser::OT_HTML
  143. * - Parser::OT_WIKI
  144. * - Parser::OT_PREPROCESS
  145. * - Parser::OT_MSG
  146. * - Parser::OT_PLAIN
  147. */
  148. define( 'OT_HTML', 1 );
  149. define( 'OT_WIKI', 2 );
  150. define( 'OT_PREPROCESS', 3 );
  151. define( 'OT_MSG', 3 ); // b/c alias for OT_PREPROCESS
  152. define( 'OT_PLAIN', 4 );
  153. /** @} */
  154. /** @{
  155. * Flags for Parser::setFunctionHook
  156. * Use of Parser consts is preferred:
  157. * - Parser::SFH_NO_HASH
  158. * - Parser::SFH_OBJECT_ARGS
  159. */
  160. define( 'SFH_NO_HASH', 1 );
  161. define( 'SFH_OBJECT_ARGS', 2 );
  162. /** @} */
  163. /** @{
  164. * Autopromote conditions (must be here and not in Autopromote.php, so that
  165. * they're loaded for DefaultSettings.php before AutoLoader.php)
  166. */
  167. define( 'APCOND_EDITCOUNT', 1 );
  168. define( 'APCOND_AGE', 2 );
  169. define( 'APCOND_EMAILCONFIRMED', 3 );
  170. define( 'APCOND_INGROUPS', 4 );
  171. define( 'APCOND_ISIP', 5 );
  172. define( 'APCOND_IPINRANGE', 6 );
  173. define( 'APCOND_AGE_FROM_EDIT', 7 );
  174. define( 'APCOND_BLOCKED', 8 );
  175. define( 'APCOND_ISBOT', 9 );
  176. /** @} */
  177. /** @{
  178. * Protocol constants for wfExpandUrl()
  179. */
  180. define( 'PROTO_HTTP', 'http://' );
  181. define( 'PROTO_HTTPS', 'https://' );
  182. define( 'PROTO_RELATIVE', '//' );
  183. define( 'PROTO_CURRENT', null );
  184. define( 'PROTO_CANONICAL', 1 );
  185. define( 'PROTO_INTERNAL', 2 );
  186. /** @} */
  187. /** @{
  188. * Content model ids, used by Content and ContentHandler.
  189. * These IDs will be exposed in the API and XML dumps.
  190. *
  191. * Extensions that define their own content model IDs should take
  192. * care to avoid conflicts. Using the extension name as a prefix is recommended,
  193. * for example 'myextension-somecontent'.
  194. */
  195. define( 'CONTENT_MODEL_WIKITEXT', 'wikitext' );
  196. define( 'CONTENT_MODEL_JAVASCRIPT', 'javascript' );
  197. define( 'CONTENT_MODEL_CSS', 'css' );
  198. define( 'CONTENT_MODEL_TEXT', 'text' );
  199. define( 'CONTENT_MODEL_JSON', 'json' );
  200. /** @} */
  201. /** @{
  202. * Content formats, used by Content and ContentHandler.
  203. * These should be MIME types, and will be exposed in the API and XML dumps.
  204. *
  205. * Extensions are free to use the below formats, or define their own.
  206. * It is recommended to stick with the conventions for MIME types.
  207. */
  208. // wikitext
  209. define( 'CONTENT_FORMAT_WIKITEXT', 'text/x-wiki' );
  210. // for js pages
  211. define( 'CONTENT_FORMAT_JAVASCRIPT', 'text/javascript' );
  212. // for css pages
  213. define( 'CONTENT_FORMAT_CSS', 'text/css' );
  214. // for future use, e.g. with some plain-html messages.
  215. define( 'CONTENT_FORMAT_TEXT', 'text/plain' );
  216. // for future use, e.g. with some plain-html messages.
  217. define( 'CONTENT_FORMAT_HTML', 'text/html' );
  218. // for future use with the api and for extensions
  219. define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' );
  220. // for future use with the api, and for use by extensions
  221. define( 'CONTENT_FORMAT_JSON', 'application/json' );
  222. // for future use with the api, and for use by extensions
  223. define( 'CONTENT_FORMAT_XML', 'application/xml' );
  224. /** @} */
  225. /** @{
  226. * Max string length for shell invocations; based on binfmts.h
  227. */
  228. define( 'SHELL_MAX_ARG_STRLEN', '100000' );
  229. /** @} */
  230. /** @{
  231. * Schema compatibility flags.
  232. *
  233. * Used as flags in a bit field that indicates whether the old or new schema (or both)
  234. * are read or written.
  235. *
  236. * - SCHEMA_COMPAT_WRITE_OLD: Whether information is written to the old schema.
  237. * - SCHEMA_COMPAT_READ_OLD: Whether information stored in the old schema is read.
  238. * - SCHEMA_COMPAT_WRITE_NEW: Whether information is written to the new schema.
  239. * - SCHEMA_COMPAT_READ_NEW: Whether information stored in the new schema is read.
  240. */
  241. define( 'SCHEMA_COMPAT_WRITE_OLD', 0x01 );
  242. define( 'SCHEMA_COMPAT_READ_OLD', 0x02 );
  243. define( 'SCHEMA_COMPAT_WRITE_NEW', 0x10 );
  244. define( 'SCHEMA_COMPAT_READ_NEW', 0x20 );
  245. define( 'SCHEMA_COMPAT_WRITE_BOTH', SCHEMA_COMPAT_WRITE_OLD | SCHEMA_COMPAT_WRITE_NEW );
  246. define( 'SCHEMA_COMPAT_READ_BOTH', SCHEMA_COMPAT_READ_OLD | SCHEMA_COMPAT_READ_NEW );
  247. define( 'SCHEMA_COMPAT_OLD', SCHEMA_COMPAT_WRITE_OLD | SCHEMA_COMPAT_READ_OLD );
  248. define( 'SCHEMA_COMPAT_NEW', SCHEMA_COMPAT_WRITE_NEW | SCHEMA_COMPAT_READ_NEW );
  249. /** @} */
  250. /** @{
  251. * Schema change migration flags.
  252. *
  253. * Used as values of a feature flag for an orderly transition from an old
  254. * schema to a new schema. The numeric values of these constants are compatible with the
  255. * SCHEMA_COMPAT_XXX bitfield semantics. High bits are used to ensure that the numeric
  256. * ordering follows the order in which the migration stages should be used.
  257. *
  258. * - MIGRATION_OLD: Only read and write the old schema. The new schema need not
  259. * even exist. This is used from when the patch is merged until the schema
  260. * change is actually applied to the database.
  261. * - MIGRATION_WRITE_BOTH: Write both the old and new schema. Read the new
  262. * schema preferentially, falling back to the old. This is used while the
  263. * change is being tested, allowing easy roll-back to the old schema.
  264. * - MIGRATION_WRITE_NEW: Write only the new schema. Read the new schema
  265. * preferentially, falling back to the old. This is used while running the
  266. * maintenance script to migrate existing entries in the old schema to the
  267. * new schema.
  268. * - MIGRATION_NEW: Only read and write the new schema. The old schema (and the
  269. * feature flag) may now be removed.
  270. */
  271. define( 'MIGRATION_OLD', 0x00000000 | SCHEMA_COMPAT_OLD );
  272. define( 'MIGRATION_WRITE_BOTH', 0x10000000 | SCHEMA_COMPAT_READ_BOTH | SCHEMA_COMPAT_WRITE_BOTH );
  273. define( 'MIGRATION_WRITE_NEW', 0x20000000 | SCHEMA_COMPAT_READ_BOTH | SCHEMA_COMPAT_WRITE_NEW );
  274. define( 'MIGRATION_NEW', 0x30000000 | SCHEMA_COMPAT_NEW );
  275. /** @} */
  276. /** @{
  277. * XML dump schema versions, for use with XmlDumpWriter.
  278. * See also the corresponding export-nnnn.xsd files in the docs directory,
  279. * which are also listed at <https://www.mediawiki.org/xml/>.
  280. * Note that not all old schema versions are represented here, as several
  281. * were already unsupported at the time these constants were introduced.
  282. */
  283. define( 'XML_DUMP_SCHEMA_VERSION_10', '0.10' );
  284. define( 'XML_DUMP_SCHEMA_VERSION_11', '0.11' );
  285. /** @} */