Defines.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. require_once __DIR__ . '/compat/normal/UtfNormalDefines.php';
  25. use Wikimedia\Rdbms\IDatabase;
  26. /**
  27. * @defgroup Constants MediaWiki constants
  28. */
  29. # Obsolete aliases
  30. /**
  31. * @deprecated since 1.28
  32. */
  33. define( 'DB_SLAVE', -1 );
  34. /**@{
  35. * Obsolete IDatabase::makeList() constants
  36. * These are also available as Database class constants
  37. */
  38. define( 'LIST_COMMA', IDatabase::LIST_COMMA );
  39. define( 'LIST_AND', IDatabase::LIST_AND );
  40. define( 'LIST_SET', IDatabase::LIST_SET );
  41. define( 'LIST_NAMES', IDatabase::LIST_NAMES );
  42. define( 'LIST_OR', IDatabase::LIST_OR );
  43. /**@}*/
  44. /**@{
  45. * Virtual namespaces; don't appear in the page database
  46. */
  47. define( 'NS_MEDIA', -2 );
  48. define( 'NS_SPECIAL', -1 );
  49. /**@}*/
  50. /**@{
  51. * Real namespaces
  52. *
  53. * Number 100 and beyond are reserved for custom namespaces;
  54. * DO NOT assign standard namespaces at 100 or beyond.
  55. * DO NOT Change integer values as they are most probably hardcoded everywhere
  56. * see bug #696 which talked about that.
  57. */
  58. define( 'NS_MAIN', 0 );
  59. define( 'NS_TALK', 1 );
  60. define( 'NS_USER', 2 );
  61. define( 'NS_USER_TALK', 3 );
  62. define( 'NS_PROJECT', 4 );
  63. define( 'NS_PROJECT_TALK', 5 );
  64. define( 'NS_FILE', 6 );
  65. define( 'NS_FILE_TALK', 7 );
  66. define( 'NS_MEDIAWIKI', 8 );
  67. define( 'NS_MEDIAWIKI_TALK', 9 );
  68. define( 'NS_TEMPLATE', 10 );
  69. define( 'NS_TEMPLATE_TALK', 11 );
  70. define( 'NS_HELP', 12 );
  71. define( 'NS_HELP_TALK', 13 );
  72. define( 'NS_CATEGORY', 14 );
  73. define( 'NS_CATEGORY_TALK', 15 );
  74. /**
  75. * NS_IMAGE and NS_IMAGE_TALK are the pre-v1.14 names for NS_FILE and
  76. * NS_FILE_TALK respectively, and are kept for compatibility.
  77. *
  78. * When writing code that should be compatible with older MediaWiki
  79. * versions, either stick to the old names or define the new constants
  80. * yourself, if they're not defined already.
  81. *
  82. * @deprecated since 1.14
  83. */
  84. define( 'NS_IMAGE', NS_FILE );
  85. /**
  86. * @deprecated since 1.14
  87. */
  88. define( 'NS_IMAGE_TALK', NS_FILE_TALK );
  89. /**@}*/
  90. /**@{
  91. * Cache type
  92. */
  93. define( 'CACHE_ANYTHING', -1 ); // Use anything, as long as it works
  94. define( 'CACHE_NONE', 0 ); // Do not cache
  95. define( 'CACHE_DB', 1 ); // Store cache objects in the DB
  96. define( 'CACHE_MEMCACHED', 2 ); // MemCached, must specify servers in $wgMemCacheServers
  97. define( 'CACHE_ACCEL', 3 ); // APC or WinCache
  98. /**@}*/
  99. /**@{
  100. * Antivirus result codes, for use in $wgAntivirusSetup.
  101. */
  102. define( 'AV_NO_VIRUS', 0 ); # scan ok, no virus found
  103. define( 'AV_VIRUS_FOUND', 1 ); # virus found!
  104. define( 'AV_SCAN_ABORTED', -1 ); # scan aborted, the file is probably immune
  105. define( 'AV_SCAN_FAILED', false ); # scan failed (scanner not found or error in scanner)
  106. /**@}*/
  107. /**@{
  108. * Anti-lock flags
  109. * Was used by $wgAntiLockFlags, which was removed with 1.25
  110. * Constants kept to not have warnings when used in LocalSettings
  111. */
  112. define( 'ALF_PRELOAD_LINKS', 1 ); // unused
  113. define( 'ALF_PRELOAD_EXISTENCE', 2 ); // unused
  114. define( 'ALF_NO_LINK_LOCK', 4 ); // unused
  115. define( 'ALF_NO_BLOCK_LOCK', 8 ); // unused
  116. /**@}*/
  117. /**@{
  118. * Date format selectors; used in user preference storage and by
  119. * Language::date() and co.
  120. */
  121. define( 'MW_DATE_DEFAULT', 'default' );
  122. define( 'MW_DATE_MDY', 'mdy' );
  123. define( 'MW_DATE_DMY', 'dmy' );
  124. define( 'MW_DATE_YMD', 'ymd' );
  125. define( 'MW_DATE_ISO', 'ISO 8601' );
  126. /**@}*/
  127. /**@{
  128. * RecentChange type identifiers
  129. */
  130. define( 'RC_EDIT', 0 );
  131. define( 'RC_NEW', 1 );
  132. define( 'RC_LOG', 3 );
  133. define( 'RC_EXTERNAL', 5 );
  134. define( 'RC_CATEGORIZE', 6 );
  135. /**@}*/
  136. /**@{
  137. * Article edit flags
  138. */
  139. define( 'EDIT_NEW', 1 );
  140. define( 'EDIT_UPDATE', 2 );
  141. define( 'EDIT_MINOR', 4 );
  142. define( 'EDIT_SUPPRESS_RC', 8 );
  143. define( 'EDIT_FORCE_BOT', 16 );
  144. define( 'EDIT_DEFER_UPDATES', 32 ); // Unused since 1.27
  145. define( 'EDIT_AUTOSUMMARY', 64 );
  146. define( 'EDIT_INTERNAL', 128 );
  147. /**@}*/
  148. /**@{
  149. * Hook support constants
  150. */
  151. define( 'MW_SUPPORTS_PARSERFIRSTCALLINIT', 1 );
  152. define( 'MW_SUPPORTS_LOCALISATIONCACHE', 1 );
  153. define( 'MW_SUPPORTS_CONTENTHANDLER', 1 );
  154. define( 'MW_EDITFILTERMERGED_SUPPORTS_API', 1 );
  155. /**@}*/
  156. /** Support for $wgResourceModules */
  157. define( 'MW_SUPPORTS_RESOURCE_MODULES', 1 );
  158. /**@{
  159. * Allowed values for Parser::$mOutputType
  160. * Parameter to Parser::startExternalParse().
  161. * Use of Parser consts is preferred:
  162. * - Parser::OT_HTML
  163. * - Parser::OT_WIKI
  164. * - Parser::OT_PREPROCESS
  165. * - Parser::OT_MSG
  166. * - Parser::OT_PLAIN
  167. */
  168. define( 'OT_HTML', 1 );
  169. define( 'OT_WIKI', 2 );
  170. define( 'OT_PREPROCESS', 3 );
  171. define( 'OT_MSG', 3 ); // b/c alias for OT_PREPROCESS
  172. define( 'OT_PLAIN', 4 );
  173. /**@}*/
  174. /**@{
  175. * Flags for Parser::setFunctionHook
  176. * Use of Parser consts is preferred:
  177. * - Parser::SFH_NO_HASH
  178. * - Parser::SFH_OBJECT_ARGS
  179. */
  180. define( 'SFH_NO_HASH', 1 );
  181. define( 'SFH_OBJECT_ARGS', 2 );
  182. /**@}*/
  183. /**@{
  184. * Autopromote conditions (must be here and not in Autopromote.php, so that
  185. * they're loaded for DefaultSettings.php before AutoLoader.php)
  186. */
  187. define( 'APCOND_EDITCOUNT', 1 );
  188. define( 'APCOND_AGE', 2 );
  189. define( 'APCOND_EMAILCONFIRMED', 3 );
  190. define( 'APCOND_INGROUPS', 4 );
  191. define( 'APCOND_ISIP', 5 );
  192. define( 'APCOND_IPINRANGE', 6 );
  193. define( 'APCOND_AGE_FROM_EDIT', 7 );
  194. define( 'APCOND_BLOCKED', 8 );
  195. define( 'APCOND_ISBOT', 9 );
  196. /**@}*/
  197. /** @{
  198. * Protocol constants for wfExpandUrl()
  199. */
  200. define( 'PROTO_HTTP', 'http://' );
  201. define( 'PROTO_HTTPS', 'https://' );
  202. define( 'PROTO_RELATIVE', '//' );
  203. define( 'PROTO_CURRENT', null );
  204. define( 'PROTO_CANONICAL', 1 );
  205. define( 'PROTO_INTERNAL', 2 );
  206. /**@}*/
  207. /**@{
  208. * Content model ids, used by Content and ContentHandler.
  209. * These IDs will be exposed in the API and XML dumps.
  210. *
  211. * Extensions that define their own content model IDs should take
  212. * care to avoid conflicts. Using the extension name as a prefix is recommended,
  213. * for example 'myextension-somecontent'.
  214. */
  215. define( 'CONTENT_MODEL_WIKITEXT', 'wikitext' );
  216. define( 'CONTENT_MODEL_JAVASCRIPT', 'javascript' );
  217. define( 'CONTENT_MODEL_CSS', 'css' );
  218. define( 'CONTENT_MODEL_TEXT', 'text' );
  219. define( 'CONTENT_MODEL_JSON', 'json' );
  220. /**@}*/
  221. /**@{
  222. * Content formats, used by Content and ContentHandler.
  223. * These should be MIME types, and will be exposed in the API and XML dumps.
  224. *
  225. * Extensions are free to use the below formats, or define their own.
  226. * It is recommended to stick with the conventions for MIME types.
  227. */
  228. // wikitext
  229. define( 'CONTENT_FORMAT_WIKITEXT', 'text/x-wiki' );
  230. // for js pages
  231. define( 'CONTENT_FORMAT_JAVASCRIPT', 'text/javascript' );
  232. // for css pages
  233. define( 'CONTENT_FORMAT_CSS', 'text/css' );
  234. // for future use, e.g. with some plain-html messages.
  235. define( 'CONTENT_FORMAT_TEXT', 'text/plain' );
  236. // for future use, e.g. with some plain-html messages.
  237. define( 'CONTENT_FORMAT_HTML', 'text/html' );
  238. // for future use with the api and for extensions
  239. define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' );
  240. // for future use with the api, and for use by extensions
  241. define( 'CONTENT_FORMAT_JSON', 'application/json' );
  242. // for future use with the api, and for use by extensions
  243. define( 'CONTENT_FORMAT_XML', 'application/xml' );
  244. /**@}*/
  245. /**@{
  246. * Max string length for shell invocations; based on binfmts.h
  247. */
  248. define( 'SHELL_MAX_ARG_STRLEN', '100000' );
  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.
  255. *
  256. * - MIGRATION_OLD: Only read and write the old schema. The new schema need not
  257. * even exist. This is used from when the patch is merged until the schema
  258. * change is actually applied to the database.
  259. * - MIGRATION_WRITE_BOTH: Write both the old and new schema. Read the new
  260. * schema preferentially, falling back to the old. This is used while the
  261. * change is being tested, allowing easy roll-back to the old schema.
  262. * - MIGRATION_WRITE_NEW: Write only the new schema. Read the new schema
  263. * preferentially, falling back to the old. This is used while running the
  264. * maintenance script to migrate existing entries in the old schema to the
  265. * new schema.
  266. * - MIGRATION_NEW: Only read and write the new schema. The old schema (and the
  267. * feature flag) may now be removed.
  268. */
  269. define( 'MIGRATION_OLD', 0 );
  270. define( 'MIGRATION_WRITE_BOTH', 1 );
  271. define( 'MIGRATION_WRITE_NEW', 2 );
  272. define( 'MIGRATION_NEW', 3 );
  273. /**@}*/