Go to the documentation of this file.
24 require_once __DIR__ .
'/Maintenance.php';
33 parent::__construct();
34 $this->mDescription =
"Refresh link tables";
35 $this->
addOption(
'dfn-only',
'Delete links from nonexistent articles only' );
36 $this->
addOption(
'new-only',
'Only affect articles with just a single edit' );
37 $this->
addOption(
'redirects-only',
'Only fix redirects, not all links' );
38 $this->
addOption(
'old-redirects-only',
'Only fix redirects with no redirect table entry' );
39 $this->
addOption(
'm',
'Maximum replication lag',
false,
true );
40 $this->
addOption(
'e',
'Last page id to refresh',
false,
true );
41 $this->
addArg(
'start',
'Page_id to start from, default 1',
false );
48 $start = $this->
getArg( 0, 1 );
49 $new = $this->
getOption(
'new-only',
false );
51 $redir = $this->
getOption(
'redirects-only',
false );
52 $oldRedir = $this->
getOption(
'old-redirects-only',
false );
53 $this->
doRefreshLinks( $start, $new, $max, $end, $redir, $oldRedir );
68 $end = 0, $redirectsOnly =
false, $oldRedirectsOnly =
false ) {
71 $reportingInterval = 100;
73 $start = intval( $start );
78 # Don't generate extension images (e.g. Timeline)
84 $what = $redirectsOnly ?
"redirects" :
"links";
86 if ( $oldRedirectsOnly ) {
87 # This entire code path is cut-and-pasted from below. Hurrah.
95 $conds[] =
"page_id >= $start";
97 $conds[] =
"page_id BETWEEN $start AND $end";
101 array(
'page',
'redirect' ),
106 array(
'redirect' =>
array(
"LEFT JOIN",
"page_id=rd_from" ) )
108 $num =
$res->numRows();
109 $this->
output(
"Refreshing $num old redirects from $start...\n" );
113 foreach (
$res as $row ) {
114 if ( !( ++$i % $reportingInterval ) ) {
120 } elseif ( $newOnly ) {
121 $this->
output(
"Refreshing $what from " );
126 "page_id >= $start" ),
129 $num =
$res->numRows();
130 $this->
output(
"$num new articles...\n" );
133 foreach (
$res as $row ) {
134 if ( !( ++$i % $reportingInterval ) ) {
138 if ( $redirectsOnly ) {
146 $maxPage =
$dbr->selectField(
'page',
'max(page_id)',
false );
147 $maxRD =
$dbr->selectField(
'redirect',
'max(rd_from)',
false );
148 $end = max( $maxPage, $maxRD );
150 $this->
output(
"Refreshing redirects table.\n" );
151 $this->
output(
"Starting from page_id $start of $end.\n" );
153 for ( $id = $start; $id <= $end; $id++ ) {
155 if ( !( $id % $reportingInterval ) ) {
162 if ( !$redirectsOnly ) {
163 $this->
output(
"Refreshing links tables.\n" );
164 $this->
output(
"Starting from page_id $start of $end.\n" );
166 for ( $id = $start; $id <= $end; $id++ ) {
168 if ( !( $id % $reportingInterval ) ) {
194 if ( $page ===
null ) {
197 $dbw->delete(
'redirect',
array(
'rd_from' => $id ),
204 if ( $content !==
null ) {
205 $rt = $content->getUltimateRedirectTarget();
208 if ( $rt ===
null ) {
211 $dbw->delete(
'redirect',
array(
'rd_from' => $id ), __METHOD__ );
214 $page->insertRedirectEntry( $rt );
219 $dbw->update(
'page',
array(
'page_is_redirect' => $fieldValue ),
220 array(
'page_id' => $id ), __METHOD__ );
232 if ( $page ===
null ) {
237 if ( $content ===
null ) {
242 $dbw->begin( __METHOD__ );
244 $updates = $content->getSecondaryDataUpdates( $page->getTitle() );
247 $dbw->commit( __METHOD__ );
266 $dbr->bufferResults(
false );
268 $linksTables =
array(
269 'pagelinks' =>
'pl_from',
270 'imagelinks' =>
'il_from',
271 'categorylinks' =>
'cl_from',
272 'templatelinks' =>
'tl_from',
273 'externallinks' =>
'el_from',
274 'iwlinks' =>
'iwl_from',
275 'langlinks' =>
'll_from',
276 'redirect' =>
'rd_from',
277 'page_props' =>
'pp_page',
280 foreach ( $linksTables
as $table => $field ) {
281 $this->
output(
"Retrieving illegal entries from $table... " );
284 $results =
$dbr->select(
285 array( $table,
'page' ),
287 array(
'page_id' =>
null ),
290 array(
'page' =>
array(
'LEFT JOIN',
"$field=page_id" ) )
296 foreach ( $results
as $row ) {
298 $list[] = $row->$field;
299 if ( ( $counter % $batchSize ) == 0 ) {
301 $dbw->delete( $table,
array( $field => $list ), __METHOD__ );
303 $this->
output( $counter .
".." );
307 $this->
output( $counter );
308 if ( count( $list ) > 0 ) {
309 $dbw->delete( $table,
array( $field => $list ), __METHOD__ );
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been 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 etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static runUpdates( $updates)
Convenience method, calls doUpdate() on every DataUpdate in the array.
__construct()
Default constructor.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
if( $wgAPIRequestLog) $lb
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Maintenance script to refresh link tables.
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
static newFromID( $id, $from='fromdb')
Constructor from a page id.
deleteLinksFromNonexistent( $maxLag=0, $batchSize=100)
Removes non-existing links from pages from pagelinks, imagelinks, categorylinks, templatelinks,...
getOption( $name, $default=null)
Get an option, or return the default.
& wfGetLBFactory()
Get the load balancer factory object.
addArg( $arg, $description, $required=true)
Add some args that are needed.
fixRedirect( $id)
Update the redirect entry for a given page.
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
execute()
Do the actual work.
output( $out, $channel=null)
Throw some output to the user.
doRefreshLinks( $start, $newOnly=false, $maxLag=false, $end=0, $redirectsOnly=false, $oldRedirectsOnly=false)
Do the actual link refreshing.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.
static & singleton()
Get an instance of this class.
setBatchSize( $s=0)
Set the batch size.
static fixLinksFromArticle( $id)
Run LinksUpdate for all links on a given page_id.