MediaWiki REL1_34
|
Category objects are immutable, strictly speaking. More...
Public Member Functions | |
getFileCount () | |
getID () | |
getMembers ( $limit=false, $offset='') | |
Fetch a TitleArray of up to $limit category members, beginning after the category sort key $offset. | |
getName () | |
getPageCount () | |
getSubcatCount () | |
getTitle () | |
refreshCounts () | |
Refresh the counts for this category. | |
refreshCountsIfEmpty () | |
Call refreshCounts() if there are no entries in the categorylinks table or if the category table has a row that states that there are no entries. | |
refreshCountsIfSmall ( $maxSize=self::ROW_COUNT_SMALL) | |
Call refreshCounts() if there are few entries in the categorylinks table. | |
Static Public Member Functions | |
static | newFromID ( $id) |
Factory function. | |
static | newFromName ( $name) |
Factory function. | |
static | newFromRow ( $row, $title=null) |
Factory function, for constructing a Category object from a result set. | |
static | newFromTitle ( $title) |
Factory function. | |
Public Attributes | |
const | LAZY_INIT_ROW = 1 |
const | LOAD_ONLY = 0 |
const | ROW_COUNT_SMALL = 100 |
Protected Member Functions | |
initialize ( $mode=self::LOAD_ONLY) | |
Set up all member variables using a database query. | |
Private Member Functions | |
__construct () | |
getX ( $key) | |
Generic accessor. | |
Private Attributes | |
$mFiles = null | |
$mID = null | |
$mName = null | |
Name of the category, normalized to DB-key form. | |
$mPages = null | |
Counts of membership (cat_pages, cat_subcats, cat_files) | |
$mSubcats = null | |
Title | $mTitle = null |
Category page title. | |
Category objects are immutable, strictly speaking.
If you call methods that change the database, like to refresh link counts, the objects will be appropriately reinitialized. Member variables are lazy-initialized.
Definition at line 29 of file Category.php.
|
private |
Definition at line 46 of file Category.php.
Category::getFileCount | ( | ) |
Definition at line 244 of file Category.php.
References getX().
Category::getID | ( | ) |
Definition at line 223 of file Category.php.
References getX().
Category::getMembers | ( | $limit = false, | |
$offset = '' ) |
Fetch a TitleArray of up to $limit category members, beginning after the category sort key $offset.
int | bool | $limit | |
string | $offset |
Definition at line 271 of file Category.php.
References $dbr, DB_REPLICA, getName(), TitleArray\newFromResult(), and wfGetDB().
Category::getName | ( | ) |
Definition at line 216 of file Category.php.
References getX().
Referenced by getMembers(), and refreshCountsIfSmall().
Category::getPageCount | ( | ) |
Definition at line 230 of file Category.php.
References getX().
Category::getSubcatCount | ( | ) |
Definition at line 237 of file Category.php.
References getX().
Category::getTitle | ( | ) |
Definition at line 251 of file Category.php.
References $mTitle, initialize(), and NS_CATEGORY.
Referenced by CategoryTreeCategoryViewer\addSubcategoryObject(), and CategoryViewer\addSubcategoryObject().
|
private |
Generic accessor.
string | $key |
Definition at line 304 of file Category.php.
References initialize().
Referenced by getFileCount(), getID(), getName(), getPageCount(), and getSubcatCount().
|
protected |
Set up all member variables using a database query.
int | $mode | One of (Category::LOAD_ONLY, Category::LAZY_INIT_ROW) |
MWException |
Definition at line 55 of file Category.php.
References $dbr, DB_REPLICA, and wfGetDB().
Referenced by getTitle(), getX(), and refreshCounts().
|
static |
Factory function.
int | $id | A category id |
Definition at line 161 of file Category.php.
|
static |
Factory function.
string | $name | A category name (no "Category:" prefix). It need not be normalized, with spaces replaced by underscores. |
Definition at line 126 of file Category.php.
References $title, and NS_CATEGORY.
Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories().
|
static |
Factory function, for constructing a Category object from a result set.
object | $row | Result set row, must contain the cat_xxx fields. If the fields are null, the resulting Category object will represent an empty category if a title object was given. If the fields are null and no title was given, this method fails and returns false. |
Title | null | $title | Optional title object for the category represented by the given row. May be provided if it is already known, to avoid having to re-create a title object later. |
Definition at line 179 of file Category.php.
References $title.
|
static |
Factory function.
Definition at line 146 of file Category.php.
References $title.
Category::refreshCounts | ( | ) |
Refresh the counts for this category.
Definition at line 316 of file Category.php.
References DB_MASTER, getTitle(), initialize(), NS_CATEGORY, NS_FILE, wfGetDB(), and wfReadOnly().
Referenced by refreshCountsIfSmall().
Category::refreshCountsIfEmpty | ( | ) |
Call refreshCounts() if there are no entries in the categorylinks table or if the category table has a row that states that there are no entries.
Due to lock errors or other failures, the precomputed counts can get out of sync, making it hard to know when to delete the category row without checking the categorylinks table.
Definition at line 435 of file Category.php.
References refreshCountsIfSmall().
Category::refreshCountsIfSmall | ( | $maxSize = self::ROW_COUNT_SMALL | ) |
Call refreshCounts() if there are few entries in the categorylinks table.
Due to lock errors or other failures, the precomputed counts can get out of sync, making it hard to know when to delete the category row without checking the categorylinks table.
This method will do a non-locking select first to reduce contention.
int | $maxSize | Only refresh if there are this or less many backlinks |
Definition at line 452 of file Category.php.
References DB_MASTER, getName(), refreshCounts(), and wfGetDB().
Referenced by refreshCountsIfEmpty().
|
private |
Definition at line 39 of file Category.php.
|
private |
Definition at line 32 of file Category.php.
|
private |
Name of the category, normalized to DB-key form.
Definition at line 31 of file Category.php.
|
private |
Counts of membership (cat_pages, cat_subcats, cat_files)
Definition at line 39 of file Category.php.
|
private |
Definition at line 39 of file Category.php.
|
private |
Category page title.
Definition at line 37 of file Category.php.
const Category::LAZY_INIT_ROW = 1 |
Definition at line 42 of file Category.php.
const Category::LOAD_ONLY = 0 |
Definition at line 41 of file Category.php.
const Category::ROW_COUNT_SMALL = 100 |
Definition at line 44 of file Category.php.