Merge "Import: Handle uploads with sha1 starting with 0 properly"
[mediawiki.git] / includes / context / IContextSource.php
blob750389ddd5135b9a9732e5b16588af70b2a94d90
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @since 1.18
20 * @author Happy-melon
21 * @file
24 /**
25 * Interface for objects which can provide a MediaWiki context on request
27 * Context objects contain request-dependent objects that manage the core
28 * web request/response logic for essentially all requests to MediaWiki.
29 * The contained objects include:
30 * a) Key objects that depend (for construction/loading) on the HTTP request
31 * b) Key objects used for response building and PHP session state control
32 * c) Performance metric deltas accumulated from request execution
33 * d) The site configuration object
34 * All of the objects are useful for the vast majority of MediaWiki requests.
35 * The site configuration object is included on grounds of extreme
36 * utility, even though it should not actually depend on the web request.
38 * More specifically, the scope of the context includes:
39 * a) Objects that represent the HTTP request/response and PHP session state
40 * b) Object representing the MediaWiki user (as determined by the HTTP request)
41 * c) Primary MediaWiki output builder objects (OutputPage, user skin object)
42 * d) The language object for the user/request
43 * e) The title and wiki page objects requested via URL (if any)
44 * f) Performance metric deltas accumulated from request execution
45 * g) The site configuration object
47 * This class is not intended as a service-locator nor a service singleton.
48 * Objects that only depend on site configuration do not belong here (aside
49 * from Config itself). Objects that represent persistent data stores do not
50 * belong here either. Session state changes should only be propagated on
51 * shutdown by separate persistence handler objects, for example.
53 interface IContextSource {
54 /**
55 * Get the WebRequest object
57 * @return WebRequest
59 public function getRequest();
61 /**
62 * Get the Title object
64 * @return Title|null
66 public function getTitle();
68 /**
69 * Check whether a WikiPage object can be get with getWikiPage().
70 * Callers should expect that an exception is thrown from getWikiPage()
71 * if this method returns false.
73 * @since 1.19
74 * @return bool
76 public function canUseWikiPage();
78 /**
79 * Get the WikiPage object.
80 * May throw an exception if there's no Title object set or the Title object
81 * belongs to a special namespace that doesn't have WikiPage, so use first
82 * canUseWikiPage() to check whether this method can be called safely.
84 * @since 1.19
85 * @return WikiPage
87 public function getWikiPage();
89 /**
90 * Get the OutputPage object
92 * @return OutputPage
94 public function getOutput();
96 /**
97 * Get the User object
99 * @return User
101 public function getUser();
104 * Get the Language object
106 * @return Language
107 * @since 1.19
109 public function getLanguage();
112 * Get the Skin object
114 * @return Skin
116 public function getSkin();
119 * Get the site configuration
121 * @since 1.23
122 * @return Config
124 public function getConfig();
127 * Get the stats object
129 * @since 1.25
130 * @return BufferingStatsdDataFactory
132 public function getStats();
135 * Get the timing object
137 * @since 1.27
138 * @return Timing
140 public function getTiming();
143 * Get a Message object with context set. See wfMessage for parameters.
145 * @param mixed ...
146 * @return Message
148 public function msg();
151 * Export the resolved user IP, HTTP headers, user ID, and session ID.
152 * The result will be reasonably sized to allow for serialization.
154 * @return array
155 * @since 1.21
157 public function exportSession();