MediaWiki  1.23.12
purgeOldText.inc
Go to the documentation of this file.
1 <?php
2 
26 function PurgeRedundantText( $delete = false ) {
27 
28  # Data should come off the master, wrapped in a transaction
29  $dbw = wfGetDB( DB_MASTER );
30  $dbw->begin( __METHOD__ );
31 
32  $tbl_arc = $dbw->tableName( 'archive' );
33  $tbl_rev = $dbw->tableName( 'revision' );
34  $tbl_txt = $dbw->tableName( 'text' );
35 
36  # Get "active" text records from the revisions table
37  echo "Searching for active text records in revisions table...";
38  $res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" );
39  foreach ( $res as $row ) {
40  $cur[] = $row->rev_text_id;
41  }
42  echo "done.\n";
43 
44  # Get "active" text records from the archive table
45  echo "Searching for active text records in archive table...";
46  $res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" );
47  $cur = array();
48  foreach ( $res as $row ) {
49  $cur[] = $row->ar_text_id;
50  }
51  echo "done.\n";
52 
53  # Get the IDs of all text records not in these sets
54  echo "Searching for inactive text records...";
55  $set = implode( ', ', $cur );
56  $res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" );
57  $old = array();
58  foreach ( $res as $row ) {
59  $old[] = $row->old_id;
60  }
61  echo "done.\n";
62 
63  # Inform the user of what we're going to do
64  $count = count( $old );
65  echo "$count inactive items found.\n";
66 
67  # Delete as appropriate
68  if ( $delete && $count ) {
69  echo "Deleting...";
70  $set = implode( ', ', $old );
71  $dbw->query( "DELETE FROM $tbl_txt WHERE old_id IN ( $set )" );
72  echo "done.\n";
73  }
74 
75  # Done
76  $dbw->commit( __METHOD__ );
77 
78 }
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
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
Definition: skin.txt:62
PurgeRedundantText
PurgeRedundantText( $delete=false)
Definition: purgeOldText.inc:26
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$count
$count
Definition: UtfNormalTest2.php:96
as
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
Definition: distributors.txt:9
$res
$res
Definition: database.txt:21