77 public function seed( $articleIds, $categories,
$mode =
'AND' ) {
78 $this->articles = $articleIds;
79 $this->next = $articleIds;
82 # Set the list of target categories; convert them to DBKEY form first
84 foreach ( $categories
as $c ) {
88 $this->targets[$c] = $c;
98 public function run() {
100 while ( count( $this->next ) > 0 ) {
104 # Now check if this applies to the individual articles
109 if ( $this->
check( $article, $conds ) ) {
110 # Matches the conditions
134 if ( in_array( $id,
$path ) ) {
140 # Shortcut (runtime paranoia): No conditions=all matched
141 if ( count( $conds ) == 0 ) {
145 if ( !isset( $this->parents[$id] ) ) {
149 # iterate through the parents
150 foreach ( $this->parents[$id]
as $p ) {
153 # Is this a condition?
154 if ( isset( $conds[$pname] ) ) {
155 # This key is in the category list!
156 if ( $this->mode ==
'OR' ) {
157 # One found, that's enough!
161 # Assuming "AND" as default
162 unset( $conds[$pname] );
163 if ( count( $conds ) == 0 ) {
164 # All conditions met, done
170 # Not done yet, try sub-parents
171 if ( !isset( $this->name2id[$pname] ) ) {
175 $done = $this->
check( $this->name2id[$pname], $conds,
$path );
176 if ( $done || count( $conds ) == 0 ) {
177 # Subparents have done it!
189 # Find all parents of the article currently in $this->next
191 $res = $this->dbr->select(
194 [
'cl_from' => $this->next ],
201 if ( !isset( $this->parents[$o->cl_from] ) ) {
202 $this->parents[$o->cl_from] = [];
204 $this->parents[$o->cl_from][$k] = $o;
206 # Ignore those we already have
207 if ( in_array( $k, $this->deadend ) ) {
211 if ( isset( $this->name2id[$k] ) ) {
221 # Find the IDs of all category pages in $layer, if they exist
222 if ( count( $layer ) > 0 ) {
223 $res = $this->dbr->select(
225 [
'page_id',
'page_title' ],
226 [
'page_namespace' =>
NS_CATEGORY,
'page_title' => $layer ],
231 $name = $o->page_title;
232 $this->name2id[
$name] = $id;
234 unset( $layer[
$name] );
239 foreach ( $layer
as $v ) {
240 $this->deadend[$v] = $v;
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
The "CategoryFinder" class takes a list of articles, creates an internal representation of all their ...
check($id, &$conds, $path=[])
This functions recurses through the parent representation, trying to match the conditions.
IDatabase $dbr
Read-DB slave.
array $deadend
Array of DBKEY category names for categories that don't have a page.
array $parents
Array of [ID => array()].
int[] $articles
The original article IDs passed to the seed function.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
run()
Iterates through the parent tree starting with the seed values, then checks the articles if they matc...
array $targets
Array of DBKEY category names.
getParents()
Get the parents.
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
scanNextLayer()
Scans a "parent layer" of the articles/categories in $this->next.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
array $next
Array of article/category IDs.
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
seed($articleIds, $categories, $mode= 'AND')
Initializes the instance.
string $mode
"AND" or "OR"
Allows to change the fields on the form that will be generated $name