1 | <?php |
||
32 | class LinkBatch { |
||
33 | /** |
||
34 | * 2-d array, first index namespace, second index dbkey, value arbitrary |
||
35 | */ |
||
36 | public $data = []; |
||
37 | |||
38 | /** |
||
39 | * For debugging which method is using this class. |
||
40 | */ |
||
41 | protected $caller; |
||
42 | |||
43 | /** |
||
44 | * LinkBatch constructor. |
||
45 | * @param LinkTarget[] $arr Initial items to be added to the batch |
||
46 | */ |
||
47 | public function __construct( $arr = [] ) { |
||
48 | foreach ( $arr as $item ) { |
||
49 | $this->addObj( $item ); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Use ->setCaller( __METHOD__ ) to indicate which code is using this |
||
55 | * class. Only used in debugging output. |
||
56 | * @since 1.17 |
||
57 | * |
||
58 | * @param string $caller |
||
59 | */ |
||
60 | public function setCaller( $caller ) { |
||
63 | |||
64 | /** |
||
65 | * @param LinkTarget $linkTarget |
||
66 | */ |
||
67 | public function addObj( $linkTarget ) { |
||
74 | |||
75 | /** |
||
76 | * @param int $ns |
||
77 | * @param string $dbkey |
||
78 | */ |
||
79 | public function add( $ns, $dbkey ) { |
||
89 | |||
90 | /** |
||
91 | * Set the link list to a given 2-d array |
||
92 | * First key is the namespace, second is the DB key, value arbitrary |
||
93 | * |
||
94 | * @param array $array |
||
95 | */ |
||
96 | public function setArray( $array ) { |
||
99 | |||
100 | /** |
||
101 | * Returns true if no pages have been added, false otherwise. |
||
102 | * |
||
103 | * @return bool |
||
104 | */ |
||
105 | public function isEmpty() { |
||
108 | |||
109 | /** |
||
110 | * Returns the size of the batch. |
||
111 | * |
||
112 | * @return int |
||
113 | */ |
||
114 | public function getSize() { |
||
117 | |||
118 | /** |
||
119 | * Do the query and add the results to the LinkCache object |
||
120 | * |
||
121 | * @return array Mapping PDBK to ID |
||
122 | */ |
||
123 | public function execute() { |
||
128 | |||
129 | /** |
||
130 | * Do the query and add the results to a given LinkCache object |
||
131 | * Return an array mapping PDBK to ID |
||
132 | * |
||
133 | * @param LinkCache $cache |
||
134 | * @return array Remaining IDs |
||
135 | */ |
||
136 | protected function executeInto( &$cache ) { |
||
143 | |||
144 | /** |
||
145 | * Add a ResultWrapper containing IDs and titles to a LinkCache object. |
||
146 | * As normal, titles will go into the static Title cache field. |
||
147 | * This function *also* stores extra fields of the title used for link |
||
148 | * parsing to avoid extra DB queries. |
||
149 | * |
||
150 | * @param LinkCache $cache |
||
151 | * @param ResultWrapper $res |
||
152 | * @return array Array of remaining titles |
||
153 | */ |
||
154 | public function addResultToCache( $cache, $res ) { |
||
184 | |||
185 | /** |
||
186 | * Perform the existence test query, return a ResultWrapper with page_id fields |
||
187 | * @return bool|ResultWrapper |
||
188 | */ |
||
189 | public function doQuery() { |
||
213 | |||
214 | /** |
||
215 | * Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch |
||
216 | * |
||
217 | * @return bool Whether the query was successful |
||
218 | */ |
||
219 | public function doGenderQuery() { |
||
234 | |||
235 | /** |
||
236 | * Construct a WHERE clause which will match all the given titles. |
||
237 | * |
||
238 | * @param string $prefix The appropriate table's field name prefix ('page', 'pl', etc) |
||
239 | * @param IDatabase $db DB object to use |
||
240 | * @return string|bool String with SQL where clause fragment, or false if no items. |
||
241 | */ |
||
242 | public function constructSet( $prefix, $db ) { |
||
245 | } |
||
246 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.