MediaWiki REL1_27
DatabaseUtility.php
Go to the documentation of this file.
1<?php
30class Blob {
32 protected $mData;
33
34 function __construct( $data ) {
35 $this->mData = $data;
36 }
37
38 function fetch() {
39 return $this->mData;
40 }
41}
42
47interface Field {
52 function name();
53
58 function tableName();
59
64 function type();
65
70 function isNullable();
71}
72
77class ResultWrapper implements Iterator {
79 public $result;
80
82 protected $db;
83
85 protected $pos = 0;
86
88 protected $currentRow = null;
89
96 function __construct( $database, $result ) {
97 $this->db = $database;
98
99 if ( $result instanceof ResultWrapper ) {
100 $this->result = $result->result;
101 } else {
102 $this->result = $result;
103 }
104 }
105
111 function numRows() {
112 return $this->db->numRows( $this );
113 }
114
123 function fetchObject() {
124 return $this->db->fetchObject( $this );
125 }
126
134 function fetchRow() {
135 return $this->db->fetchRow( $this );
136 }
137
141 function free() {
142 $this->db->freeResult( $this );
143 unset( $this->result );
144 unset( $this->db );
145 }
146
153 function seek( $row ) {
154 $this->db->dataSeek( $this, $row );
155 }
156
157 /*
158 * ======= Iterator functions =======
159 * Note that using these in combination with the non-iterator functions
160 * above may cause rows to be skipped or repeated.
161 */
162
163 function rewind() {
164 if ( $this->numRows() ) {
165 $this->db->dataSeek( $this, 0 );
166 }
167 $this->pos = 0;
168 $this->currentRow = null;
169 }
170
174 function current() {
175 if ( is_null( $this->currentRow ) ) {
176 $this->next();
177 }
178
179 return $this->currentRow;
180 }
181
185 function key() {
186 return $this->pos;
187 }
188
192 function next() {
193 $this->pos++;
194 $this->currentRow = $this->fetchObject();
195
196 return $this->currentRow;
197 }
198
202 function valid() {
203 return $this->current() !== false;
204 }
205}
206
213 public $result = [];
214
216 protected $db = null;
217
219 protected $pos = 0;
220
222 protected $currentRow = null;
223
227 function __construct( $array ) {
228 $this->result = $array;
229 }
230
234 function numRows() {
235 return count( $this->result );
236 }
237
241 function fetchRow() {
242 if ( $this->pos < count( $this->result ) ) {
243 $this->currentRow = $this->result[$this->pos];
244 } else {
245 $this->currentRow = false;
246 }
247 $this->pos++;
248 if ( is_object( $this->currentRow ) ) {
249 return get_object_vars( $this->currentRow );
250 } else {
251 return $this->currentRow;
252 }
253 }
254
255 function seek( $row ) {
256 $this->pos = $row;
257 }
258
259 function free() {
260 }
261
266 function fetchObject() {
267 $this->fetchRow();
268 if ( $this->currentRow ) {
269 return (object)$this->currentRow;
270 } else {
271 return false;
272 }
273 }
274
275 function rewind() {
276 $this->pos = 0;
277 $this->currentRow = null;
278 }
279
283 function next() {
284 return $this->fetchObject();
285 }
286}
287
295 private $str;
296
302 public function __construct( $s ) {
303 $this->str = $s;
304 }
305
311 public function toString() {
312 return $this->str;
313 }
314}
315
321interface DBMasterPos {
326 public function asOfTime();
327
333 public function hasReached( DBMasterPos $pos );
334
340 public function channelsMatch( DBMasterPos $pos );
341
346 public function __toString();
347}
Utility class.
__construct( $data)
string $mData
Database abstraction object.
Definition Database.php:32
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
seek( $row)
Change the position of the cursor in a result object.
free()
Free a result object.
array stdClass bool $currentRow
fetchObject()
Callers want to be able to access fields with $this->fieldName.
null $db
And it's going to stay that way :D.
Used by DatabaseBase::buildLike() to represent characters that have special meaning in SQL LIKE claus...
__construct( $s)
Store a string into a LikeMatch marker object.
toString()
Return the original stored string.
Result wrapper for grabbing data queried by someone else.
numRows()
Get the number of rows in a result object.
DatabaseBase $db
fetchObject()
Fetch the next row from the given result object, in object form.
fetchRow()
Fetch the next row from the given result object, in associative array form.
__construct( $database, $result)
Create a new result object from a result resource and a Database object.
free()
Free a result object.
object null $currentRow
seek( $row)
Change the position of the cursor in a result object.
the array() calling protocol came about after MediaWiki 1.4rc1.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition hooks.txt:1799
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
An object representing a master or slave position in a replicated setup.
channelsMatch(DBMasterPos $pos)
hasReached(DBMasterPos $pos)
Base for all database-specific classes representing information about database fields.
type()
Database type.
isNullable()
Whether this field can store NULL values.
tableName()
Name of table this field belongs to.
name()
Field name.