24require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
38This
script will clean up the category
table by removing entries
for empty
39categories without a description page and
adding entries
for empty categories
40with a description page. It will
print out progress indicators every
batch. The
41script is perfectly safe to run on large, live wikis, and running it multiple
42times is harmless. You may want to use the throttling
options if it
's causing
43too much load; they will not affect correctness.
45If the script is stopped and later resumed, you can use the --mode and --begin
46options with the last printed progress indicator to pick up where you left off.
48When the script has finished, it will make a note of this in the database, and
49will not run again without the --force option.
55 '"add" empty categories with description
pages,
"remove" empty categories
'
56 . 'without description
pages, or
"both"',
62 'Only
do categories whose names are alphabetically after the provided
name',
68 'Wait
this many milliseconds after each
batch. Default: 0
',
74 protected function getUpdateKey() {
75 return 'cleanup empty categories
';
78 protected function doDBUpdates() {
79 $mode = $this->getOption( 'mode
', 'both
' );
80 $begin = $this->getOption( 'begin', '' );
81 $throttle = $this->getOption( 'throttle
', 0 );
83 if ( !in_array( $mode, [ 'add
', 'remove', 'both
' ] ) ) {
84 $this->output( "--mode must be 'add
', 'remove', or 'both
'.\n" );
88 $dbw = $this->getDB( DB_MASTER );
90 $throttle = intval( $throttle );
92 if ( $mode === 'add
' || $mode === 'both
' ) {
93 if ( $begin !== '' ) {
94 $where = [ 'page_title >
' . $dbw->addQuotes( $begin ) ];
99 $this->output( "Adding empty categories with description pages...\n" );
101 # Find which category to update
102 $rows = $dbw->select(
103 [ 'page
', 'category
' ],
105 array_merge( $where, [
106 'page_namespace
' => NS_CATEGORY,
111 'ORDER BY
' => 'page_title
',
112 'LIMIT
' => $this->getBatchSize(),
115 'category
' => [ 'LEFT JOIN
', 'page_title = cat_title
' ],
118 if ( !$rows || $rows->numRows() <= 0 ) {
122 foreach ( $rows as $row ) {
123 $name = $row->page_title;
124 $where = [ 'page_title >
' . $dbw->addQuotes( $name ) ];
126 # Use the row to update the category count
127 $cat = Category::newFromName( $name );
128 if ( !is_object( $cat ) ) {
129 $this->output( "The category named $name is not valid?!\n" );
131 $cat->refreshCounts();
134 $this->output( "--mode=$mode --begin=$name\n" );
137 usleep( $throttle * 1000 );
143 if ( $mode === 'remove' || $mode === 'both
' ) {
144 if ( $begin !== '' ) {
145 $where = [ 'cat_title >
' . $dbw->addQuotes( $begin ) ];
150 $this->output( "Removing empty categories without description pages...\n" );
152 # Find which category to update
153 $rows = $dbw->select(
154 [ 'category
', 'page
' ],
156 array_merge( $where, [
157 'page_title
' => null,
162 'ORDER BY
' => 'cat_title
',
163 'LIMIT
' => $this->getBatchSize(),
166 'page
' => [ 'LEFT JOIN
', [
167 'page_namespace
' => NS_CATEGORY, 'page_title = cat_title
'
171 if ( !$rows || $rows->numRows() <= 0 ) {
174 foreach ( $rows as $row ) {
175 $name = $row->cat_title;
176 $where = [ 'cat_title >
' . $dbw->addQuotes( $name ) ];
178 # Use the row to update the category count
179 $cat = Category::newFromName( $name );
180 if ( !is_object( $cat ) ) {
181 $this->output( "The category named $name is not valid?!\n" );
183 $cat->refreshCounts();
187 $this->output( "--mode=remove --begin=$name\n" );
190 usleep( $throttle * 1000 );
194 $this->output( "Category cleanup complete.\n" );
200$maintClass = CleanupEmptyCategories::class;
201require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script to clean up empty categories in the category table.
__construct()
Default constructor.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
addDescription( $text)
Set the description text.
The ContentHandler facility adds support for arbitrary content types on wiki pages
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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. '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 '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:Array with elements of the form "language:title" in the order that they will be output. & $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':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. 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) name
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
while(( $__line=Maintenance::readconsole()) !==false) print
script(document.cookie)%253c/script%253e</pre ></div > !! end !! test XSS is escaped(inline) !!input< source lang
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a batch
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by similarly to how extensions are installed You can then make that skin the default by adding