MediaWiki  master
FakeResultWrapper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
6 
17  function __construct( array $rows ) {
18  parent::__construct( null, $rows );
19  }
20 
21  function numRows() {
22  return count( $this->result );
23  }
24 
25  function fetchObject() {
26  $current = $this->current();
27 
28  $this->next();
29 
30  return $current;
31  }
32 
33  function fetchRow() {
34  $row = $this->valid() ? $this->result[$this->pos] : false;
35 
36  $this->next();
37 
38  return is_object( $row ) ? (array)$row : $row;
39  }
40 
41  function seek( $pos ) {
42  $this->pos = $pos;
43  }
44 
45  function free() {
46  $this->result = null;
47  }
48 
49  function rewind() {
50  $this->pos = 0;
51  }
52 
53  function current() {
54  $row = $this->valid() ? $this->result[$this->pos] : false;
55 
56  return is_array( $row ) ? (object)$row : $row;
57  }
58 
59  function key() {
60  return $this->pos;
61  }
62 
63  function next() {
64  $this->pos++;
65 
66  return $this->current();
67  }
68 
69  function valid() {
70  return array_key_exists( $this->pos, $this->result );
71  }
72 }
73 
77 class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2633
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Result wrapper for grabbing data queried from an IDatabase object.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
numRows()
Get the number of rows in a result object.
fetchRow()
Fetch the next row from the given result object, in associative array form.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
seek( $pos)
Change the position of the cursor in a result object.
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:35
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Overloads the relevant methods of the real ResultsWrapper so it doesn&#39;t go anywhere near an actual da...
fetchObject()
Fetch the next row from the given result object, in object form.