Index: trunk/phase3/maintenance/deleteOrphanedRevisions.inc.php |
— | — | @@ -1,32 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Support functions for the deleteOrphanedRevisions maintenance script |
6 | | - * |
7 | | - * @file |
8 | | - * @ingroup Maintenance |
9 | | - * @author Rob Church <robchur@gmail.com> |
10 | | - */ |
11 | | - |
12 | | -/** |
13 | | - * Delete one or more revisions from the database |
14 | | - * Do this inside a transaction |
15 | | - * |
16 | | - * @param $id Array of revision id values |
17 | | - * @param $db Database class (needs to be a master) |
18 | | - */ |
19 | | -function deleteRevisions( $id, &$dbw ) { |
20 | | - if( !is_array( $id ) ) |
21 | | - $id = array( $id ); |
22 | | - $dbw->delete( 'revision', array( 'rev_id' => $id ), 'deleteRevision' ); |
23 | | -} |
24 | | - |
25 | | -/** |
26 | | - * Spit out script usage information and exit |
27 | | - */ |
28 | | -function showUsage() { |
29 | | - echo( "Finds revisions which refer to nonexisting pages and deletes them from the database\n" ); |
30 | | - echo( "USAGE: php deleteOrphanedRevisions.php [--report]\n\n" ); |
31 | | - echo( " --report : Prints out a count of affected revisions but doesn't delete them\n\n" ); |
32 | | -} |
33 | | - |
Index: trunk/phase3/maintenance/importImages.inc.php |
— | — | @@ -1,88 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Support functions for the importImages script |
6 | | - * |
7 | | - * @file |
8 | | - * @ingroup Maintenance |
9 | | - * @author Rob Church <robchur@gmail.com> |
10 | | - */ |
11 | | - |
12 | | -/** |
13 | | - * Search a directory for files with one of a set of extensions |
14 | | - * |
15 | | - * @param $dir Path to directory to search |
16 | | - * @param $exts Array of extensions to search for |
17 | | - * @return mixed Array of filenames on success, or false on failure |
18 | | - */ |
19 | | -function findFiles( $dir, $exts ) { |
20 | | - if( is_dir( $dir ) ) { |
21 | | - if( $dhl = opendir( $dir ) ) { |
22 | | - while( ( $file = readdir( $dhl ) ) !== false ) { |
23 | | - if( is_file( $dir . '/' . $file ) ) { |
24 | | - list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file ); |
25 | | - if( array_search( strtolower( $ext ), $exts ) !== false ) |
26 | | - $files[] = $dir . '/' . $file; |
27 | | - } |
28 | | - } |
29 | | - return $files; |
30 | | - } else { |
31 | | - return false; |
32 | | - } |
33 | | - } else { |
34 | | - return false; |
35 | | - } |
36 | | -} |
37 | | - |
38 | | -/** |
39 | | - * Split a filename into filename and extension |
40 | | - * |
41 | | - * @param $filename Filename |
42 | | - * @return array |
43 | | - */ |
44 | | -function splitFilename( $filename ) { |
45 | | - $parts = explode( '.', $filename ); |
46 | | - $ext = $parts[ count( $parts ) - 1 ]; |
47 | | - unset( $parts[ count( $parts ) - 1 ] ); |
48 | | - $fname = implode( '.', $parts ); |
49 | | - return array( $fname, $ext ); |
50 | | -} |
51 | | - |
52 | | -/** |
53 | | - * Find an auxilliary file with the given extension, matching |
54 | | - * the give base file path. $maxStrip determines how many extensions |
55 | | - * may be stripped from the original file name before appending the |
56 | | - * new extension. For example, with $maxStrip = 1 (the default), |
57 | | - * file files acme.foo.bar.txt and acme.foo.txt would be auxilliary |
58 | | - * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, |
59 | | - * acme.txt would also be acceptable. |
60 | | - * |
61 | | - * @param $file base path |
62 | | - * @param $auxExtension the extension to be appended to the base path |
63 | | - * @param $maxStrip the maximum number of extensions to strip from the base path (default: 1) |
64 | | - * @return string or false |
65 | | - */ |
66 | | -function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { |
67 | | - if ( strpos( $auxExtension, '.' ) !== 0 ) { |
68 | | - $auxExtension = '.' . $auxExtension; |
69 | | - } |
70 | | - |
71 | | - $d = dirname( $file ); |
72 | | - $n = basename( $file ); |
73 | | - |
74 | | - while ( $maxStrip >= 0 ) { |
75 | | - $f = $d . '/' . $n . $auxExtension; |
76 | | - |
77 | | - if ( file_exists( $f ) ) { |
78 | | - return $f; |
79 | | - } |
80 | | - |
81 | | - $idx = strrpos( $n, '.' ); |
82 | | - if ( !$idx ) break; |
83 | | - |
84 | | - $n = substr( $n, 0, $idx ); |
85 | | - $maxStrip -= 1; |
86 | | - } |
87 | | - |
88 | | - return false; |
89 | | -} |
\ No newline at end of file |
Index: trunk/phase3/maintenance/updateArticleCount.inc.php |
— | — | @@ -1,61 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Support class for the updateArticleCount.php maintenance script |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Maintenance |
8 | | - * @author Rob Church <robchur@gmail.com> |
9 | | - */ |
10 | | - |
11 | | -class ArticleCounter { |
12 | | - |
13 | | - var $dbr; |
14 | | - var $namespaces; |
15 | | - |
16 | | - function ArticleCounter() { |
17 | | - global $wgContentNamespaces; |
18 | | - $this->namespaces = $wgContentNamespaces; |
19 | | - $this->dbr = wfGetDB( DB_SLAVE ); |
20 | | - } |
21 | | - |
22 | | - /** |
23 | | - * Produce a comma-delimited set of namespaces |
24 | | - * Includes paranoia |
25 | | - * |
26 | | - * @return string |
27 | | - */ |
28 | | - function makeNsSet() { |
29 | | - foreach( $this->namespaces as $namespace ) |
30 | | - $namespaces[] = intval( $namespace ); |
31 | | - return implode( ', ', $namespaces ); |
32 | | - } |
33 | | - |
34 | | - /** |
35 | | - * Produce SQL for the query |
36 | | - * |
37 | | - * @return string |
38 | | - */ |
39 | | - function makeSql() { |
40 | | - list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' ); |
41 | | - $nsset = $this->makeNsSet(); |
42 | | - return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " . |
43 | | - "FROM $page, $pagelinks " . |
44 | | - "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " . |
45 | | - "AND page_is_redirect = 0 AND page_len > 0"; |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * Count the number of valid content pages in the wiki |
50 | | - * |
51 | | - * @return mixed Integer, or false if there's a problem |
52 | | - */ |
53 | | - function count() { |
54 | | - $res = $this->dbr->query( $this->makeSql(), __METHOD__ ); |
55 | | - $row = $this->dbr->fetchObject( $res ); |
56 | | - $this->dbr->freeResult( $res ); |
57 | | - return $row->pagecount; |
58 | | - } |
59 | | - |
60 | | -} |
61 | | - |
62 | | - |
Index: trunk/phase3/maintenance/reassignEdits.inc.php |
— | — | @@ -1,143 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Support functions for the reassignEdits script |
6 | | - * |
7 | | - * @file |
8 | | - * @ingroup Maintenance |
9 | | - * @author Rob Church <robchur@gmail.com> |
10 | | - * @licence GNU General Public Licence 2.0 or later |
11 | | - */ |
12 | | - |
13 | | -/** |
14 | | - * Reassign edits from one user to another |
15 | | - * |
16 | | - * @param $from User to take edits from |
17 | | - * @param $to User to assign edits to |
18 | | - * @param $rc Update the recent changes table |
19 | | - * @param $report Don't change things; just echo numbers |
20 | | - * @return integer Number of entries changed, or that would be changed |
21 | | - */ |
22 | | -function reassignEdits( &$from, &$to, $rc = false, $report = false ) { |
23 | | - $dbw = wfGetDB( DB_MASTER ); |
24 | | - $dbw->immediateBegin(); |
25 | | - $fname = 'reassignEdits'; |
26 | | - |
27 | | - # Count things |
28 | | - out( "Checking current edits..." ); |
29 | | - $res = $dbw->select( 'revision', 'COUNT(*) AS count', userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); |
30 | | - $row = $dbw->fetchObject( $res ); |
31 | | - $cur = $row->count; |
32 | | - out( "found {$cur}.\n" ); |
33 | | - |
34 | | - out( "Checking deleted edits..." ); |
35 | | - $res = $dbw->select( 'archive', 'COUNT(*) AS count', userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); |
36 | | - $row = $dbw->fetchObject( $res ); |
37 | | - $del = $row->count; |
38 | | - out( "found {$del}.\n" ); |
39 | | - |
40 | | - # Don't count recent changes if we're not supposed to |
41 | | - if( $rc ) { |
42 | | - out( "Checking recent changes..." ); |
43 | | - $res = $dbw->select( 'recentchanges', 'COUNT(*) AS count', userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); |
44 | | - $row = $dbw->fetchObject( $res ); |
45 | | - $rec = $row->count; |
46 | | - out( "found {$rec}.\n" ); |
47 | | - } else { |
48 | | - $rec = 0; |
49 | | - } |
50 | | - |
51 | | - $total = $cur + $del + $rec; |
52 | | - out( "\nTotal entries to change: {$total}\n" ); |
53 | | - |
54 | | - if( !$report ) { |
55 | | - if( $total ) { |
56 | | - # Reassign edits |
57 | | - out( "\nReassigning current edits..." ); |
58 | | - $res = $dbw->update( 'revision', userSpecification( $to, 'rev_user', 'rev_user_text' ), userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); |
59 | | - out( "done.\nReassigning deleted edits..." ); |
60 | | - $res = $dbw->update( 'archive', userSpecification( $to, 'ar_user', 'ar_user_text' ), userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); |
61 | | - out( "done.\n" ); |
62 | | - # Update recent changes if required |
63 | | - if( $rc ) { |
64 | | - out( "Updating recent changes..." ); |
65 | | - $res = $dbw->update( 'recentchanges', userSpecification( $to, 'rc_user', 'rc_user_text' ), userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); |
66 | | - out( "done.\n" ); |
67 | | - } |
68 | | - } |
69 | | - } |
70 | | - |
71 | | - $dbw->immediateCommit(); |
72 | | - return (int)$total; |
73 | | -} |
74 | | - |
75 | | -/** |
76 | | - * Return the most efficient set of user conditions |
77 | | - * i.e. a user => id mapping, or a user_text => text mapping |
78 | | - * |
79 | | - * @param $user User for the condition |
80 | | - * @param $idfield Field name containing the identifier |
81 | | - * @param $utfield Field name containing the user text |
82 | | - * @return array |
83 | | - */ |
84 | | -function userConditions( &$user, $idfield, $utfield ) { |
85 | | - return $user->getId() ? array( $idfield => $user->getId() ) : array( $utfield => $user->getName() ); |
86 | | -} |
87 | | - |
88 | | -/** |
89 | | - * Return user specifications |
90 | | - * i.e. user => id, user_text => text |
91 | | - * |
92 | | - * @param $user User for the spec |
93 | | - * @param $idfield Field name containing the identifier |
94 | | - * @param $utfield Field name containing the user text |
95 | | - * @return array |
96 | | - */ |
97 | | -function userSpecification( &$user, $idfield, $utfield ) { |
98 | | - return array( $idfield => $user->getId(), $utfield => $user->getName() ); |
99 | | -} |
100 | | - |
101 | | -/** |
102 | | - * Echo output if $wgSilent is off |
103 | | - * |
104 | | - * @param $output Output to echo |
105 | | - * @return bool True if the output was echoed |
106 | | - */ |
107 | | -function out( $output ) { |
108 | | - global $wgSilent; |
109 | | - if( !$wgSilent ) { |
110 | | - echo( $output ); |
111 | | - return true; |
112 | | - } else { |
113 | | - return false; |
114 | | - } |
115 | | -} |
116 | | - |
117 | | -/** |
118 | | - * Mutator for $wgSilent |
119 | | - * |
120 | | - * @param $silent Switch on $wgSilent |
121 | | - */ |
122 | | -function silent( $silent = true ) { |
123 | | - global $wgSilent; |
124 | | - $wgSilent = $silent; |
125 | | -} |
126 | | - |
127 | | -/** |
128 | | - * Initialise the user object |
129 | | - * |
130 | | - * @param $username Username or IP address |
131 | | - * @return User |
132 | | - */ |
133 | | -function initialiseUser( $username ) { |
134 | | - if( User::isIP( $username ) ) { |
135 | | - $user = new User(); |
136 | | - $user->setId( 0 ); |
137 | | - $user->setName( $username ); |
138 | | - } else { |
139 | | - $user = User::newFromName( $username ); |
140 | | - } |
141 | | - $user->load(); |
142 | | - return $user; |
143 | | -} |
144 | | - |
Index: trunk/phase3/maintenance/updateArticleCount.inc |
— | — | @@ -0,0 +1,61 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Support class for the updateArticleCount.php maintenance script |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Maintenance |
| 8 | + * @author Rob Church <robchur@gmail.com> |
| 9 | + */ |
| 10 | + |
| 11 | +class ArticleCounter { |
| 12 | + |
| 13 | + var $dbr; |
| 14 | + var $namespaces; |
| 15 | + |
| 16 | + function ArticleCounter() { |
| 17 | + global $wgContentNamespaces; |
| 18 | + $this->namespaces = $wgContentNamespaces; |
| 19 | + $this->dbr = wfGetDB( DB_SLAVE ); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Produce a comma-delimited set of namespaces |
| 24 | + * Includes paranoia |
| 25 | + * |
| 26 | + * @return string |
| 27 | + */ |
| 28 | + function makeNsSet() { |
| 29 | + foreach( $this->namespaces as $namespace ) |
| 30 | + $namespaces[] = intval( $namespace ); |
| 31 | + return implode( ', ', $namespaces ); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Produce SQL for the query |
| 36 | + * |
| 37 | + * @return string |
| 38 | + */ |
| 39 | + function makeSql() { |
| 40 | + list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' ); |
| 41 | + $nsset = $this->makeNsSet(); |
| 42 | + return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " . |
| 43 | + "FROM $page, $pagelinks " . |
| 44 | + "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " . |
| 45 | + "AND page_is_redirect = 0 AND page_len > 0"; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Count the number of valid content pages in the wiki |
| 50 | + * |
| 51 | + * @return mixed Integer, or false if there's a problem |
| 52 | + */ |
| 53 | + function count() { |
| 54 | + $res = $this->dbr->query( $this->makeSql(), __METHOD__ ); |
| 55 | + $row = $this->dbr->fetchObject( $res ); |
| 56 | + $this->dbr->freeResult( $res ); |
| 57 | + return $row->pagecount; |
| 58 | + } |
| 59 | + |
| 60 | +} |
| 61 | + |
| 62 | + |
Property changes on: trunk/phase3/maintenance/updateArticleCount.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 63 | + native |
Index: trunk/phase3/maintenance/updateArticleCount.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | $options = array( 'update', 'help' ); |
13 | 13 | require_once( 'commandLine.inc' ); |
14 | | -require_once( 'updateArticleCount.inc.php' ); |
| 14 | +require_once( 'updateArticleCount.inc' ); |
15 | 15 | echo( "Update Article Count\n\n" ); |
16 | 16 | |
17 | 17 | if( isset( $options['help'] ) && $options['help'] ) { |
Index: trunk/phase3/maintenance/importImages.inc |
— | — | @@ -0,0 +1,88 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Support functions for the importImages script |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Maintenance |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * Search a directory for files with one of a set of extensions |
| 14 | + * |
| 15 | + * @param $dir Path to directory to search |
| 16 | + * @param $exts Array of extensions to search for |
| 17 | + * @return mixed Array of filenames on success, or false on failure |
| 18 | + */ |
| 19 | +function findFiles( $dir, $exts ) { |
| 20 | + if( is_dir( $dir ) ) { |
| 21 | + if( $dhl = opendir( $dir ) ) { |
| 22 | + while( ( $file = readdir( $dhl ) ) !== false ) { |
| 23 | + if( is_file( $dir . '/' . $file ) ) { |
| 24 | + list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file ); |
| 25 | + if( array_search( strtolower( $ext ), $exts ) !== false ) |
| 26 | + $files[] = $dir . '/' . $file; |
| 27 | + } |
| 28 | + } |
| 29 | + return $files; |
| 30 | + } else { |
| 31 | + return false; |
| 32 | + } |
| 33 | + } else { |
| 34 | + return false; |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +/** |
| 39 | + * Split a filename into filename and extension |
| 40 | + * |
| 41 | + * @param $filename Filename |
| 42 | + * @return array |
| 43 | + */ |
| 44 | +function splitFilename( $filename ) { |
| 45 | + $parts = explode( '.', $filename ); |
| 46 | + $ext = $parts[ count( $parts ) - 1 ]; |
| 47 | + unset( $parts[ count( $parts ) - 1 ] ); |
| 48 | + $fname = implode( '.', $parts ); |
| 49 | + return array( $fname, $ext ); |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * Find an auxilliary file with the given extension, matching |
| 54 | + * the give base file path. $maxStrip determines how many extensions |
| 55 | + * may be stripped from the original file name before appending the |
| 56 | + * new extension. For example, with $maxStrip = 1 (the default), |
| 57 | + * file files acme.foo.bar.txt and acme.foo.txt would be auxilliary |
| 58 | + * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, |
| 59 | + * acme.txt would also be acceptable. |
| 60 | + * |
| 61 | + * @param $file base path |
| 62 | + * @param $auxExtension the extension to be appended to the base path |
| 63 | + * @param $maxStrip the maximum number of extensions to strip from the base path (default: 1) |
| 64 | + * @return string or false |
| 65 | + */ |
| 66 | +function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { |
| 67 | + if ( strpos( $auxExtension, '.' ) !== 0 ) { |
| 68 | + $auxExtension = '.' . $auxExtension; |
| 69 | + } |
| 70 | + |
| 71 | + $d = dirname( $file ); |
| 72 | + $n = basename( $file ); |
| 73 | + |
| 74 | + while ( $maxStrip >= 0 ) { |
| 75 | + $f = $d . '/' . $n . $auxExtension; |
| 76 | + |
| 77 | + if ( file_exists( $f ) ) { |
| 78 | + return $f; |
| 79 | + } |
| 80 | + |
| 81 | + $idx = strrpos( $n, '.' ); |
| 82 | + if ( !$idx ) break; |
| 83 | + |
| 84 | + $n = substr( $n, 0, $idx ); |
| 85 | + $maxStrip -= 1; |
| 86 | + } |
| 87 | + |
| 88 | + return false; |
| 89 | +} |
\ No newline at end of file |
Property changes on: trunk/phase3/maintenance/importImages.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 90 | + native |
Index: trunk/phase3/maintenance/importImages.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | $optionsWithArgs = array( 'extensions', 'comment', 'comment-file', 'comment-ext', 'user', 'license' ); |
14 | 14 | require_once( 'commandLine.inc' ); |
15 | | -require_once( 'importImages.inc.php' ); |
| 15 | +require_once( 'importImages.inc' ); |
16 | 16 | $added = $skipped = $overwritten = 0; |
17 | 17 | |
18 | 18 | echo( "Import Images\n\n" ); |
Index: trunk/phase3/maintenance/reassignEdits.inc |
— | — | @@ -0,0 +1,143 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Support functions for the reassignEdits script |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Maintenance |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + * @licence GNU General Public Licence 2.0 or later |
| 11 | + */ |
| 12 | + |
| 13 | +/** |
| 14 | + * Reassign edits from one user to another |
| 15 | + * |
| 16 | + * @param $from User to take edits from |
| 17 | + * @param $to User to assign edits to |
| 18 | + * @param $rc Update the recent changes table |
| 19 | + * @param $report Don't change things; just echo numbers |
| 20 | + * @return integer Number of entries changed, or that would be changed |
| 21 | + */ |
| 22 | +function reassignEdits( &$from, &$to, $rc = false, $report = false ) { |
| 23 | + $dbw = wfGetDB( DB_MASTER ); |
| 24 | + $dbw->immediateBegin(); |
| 25 | + $fname = 'reassignEdits'; |
| 26 | + |
| 27 | + # Count things |
| 28 | + out( "Checking current edits..." ); |
| 29 | + $res = $dbw->select( 'revision', 'COUNT(*) AS count', userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); |
| 30 | + $row = $dbw->fetchObject( $res ); |
| 31 | + $cur = $row->count; |
| 32 | + out( "found {$cur}.\n" ); |
| 33 | + |
| 34 | + out( "Checking deleted edits..." ); |
| 35 | + $res = $dbw->select( 'archive', 'COUNT(*) AS count', userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); |
| 36 | + $row = $dbw->fetchObject( $res ); |
| 37 | + $del = $row->count; |
| 38 | + out( "found {$del}.\n" ); |
| 39 | + |
| 40 | + # Don't count recent changes if we're not supposed to |
| 41 | + if( $rc ) { |
| 42 | + out( "Checking recent changes..." ); |
| 43 | + $res = $dbw->select( 'recentchanges', 'COUNT(*) AS count', userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); |
| 44 | + $row = $dbw->fetchObject( $res ); |
| 45 | + $rec = $row->count; |
| 46 | + out( "found {$rec}.\n" ); |
| 47 | + } else { |
| 48 | + $rec = 0; |
| 49 | + } |
| 50 | + |
| 51 | + $total = $cur + $del + $rec; |
| 52 | + out( "\nTotal entries to change: {$total}\n" ); |
| 53 | + |
| 54 | + if( !$report ) { |
| 55 | + if( $total ) { |
| 56 | + # Reassign edits |
| 57 | + out( "\nReassigning current edits..." ); |
| 58 | + $res = $dbw->update( 'revision', userSpecification( $to, 'rev_user', 'rev_user_text' ), userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); |
| 59 | + out( "done.\nReassigning deleted edits..." ); |
| 60 | + $res = $dbw->update( 'archive', userSpecification( $to, 'ar_user', 'ar_user_text' ), userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); |
| 61 | + out( "done.\n" ); |
| 62 | + # Update recent changes if required |
| 63 | + if( $rc ) { |
| 64 | + out( "Updating recent changes..." ); |
| 65 | + $res = $dbw->update( 'recentchanges', userSpecification( $to, 'rc_user', 'rc_user_text' ), userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); |
| 66 | + out( "done.\n" ); |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + $dbw->immediateCommit(); |
| 72 | + return (int)$total; |
| 73 | +} |
| 74 | + |
| 75 | +/** |
| 76 | + * Return the most efficient set of user conditions |
| 77 | + * i.e. a user => id mapping, or a user_text => text mapping |
| 78 | + * |
| 79 | + * @param $user User for the condition |
| 80 | + * @param $idfield Field name containing the identifier |
| 81 | + * @param $utfield Field name containing the user text |
| 82 | + * @return array |
| 83 | + */ |
| 84 | +function userConditions( &$user, $idfield, $utfield ) { |
| 85 | + return $user->getId() ? array( $idfield => $user->getId() ) : array( $utfield => $user->getName() ); |
| 86 | +} |
| 87 | + |
| 88 | +/** |
| 89 | + * Return user specifications |
| 90 | + * i.e. user => id, user_text => text |
| 91 | + * |
| 92 | + * @param $user User for the spec |
| 93 | + * @param $idfield Field name containing the identifier |
| 94 | + * @param $utfield Field name containing the user text |
| 95 | + * @return array |
| 96 | + */ |
| 97 | +function userSpecification( &$user, $idfield, $utfield ) { |
| 98 | + return array( $idfield => $user->getId(), $utfield => $user->getName() ); |
| 99 | +} |
| 100 | + |
| 101 | +/** |
| 102 | + * Echo output if $wgSilent is off |
| 103 | + * |
| 104 | + * @param $output Output to echo |
| 105 | + * @return bool True if the output was echoed |
| 106 | + */ |
| 107 | +function out( $output ) { |
| 108 | + global $wgSilent; |
| 109 | + if( !$wgSilent ) { |
| 110 | + echo( $output ); |
| 111 | + return true; |
| 112 | + } else { |
| 113 | + return false; |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +/** |
| 118 | + * Mutator for $wgSilent |
| 119 | + * |
| 120 | + * @param $silent Switch on $wgSilent |
| 121 | + */ |
| 122 | +function silent( $silent = true ) { |
| 123 | + global $wgSilent; |
| 124 | + $wgSilent = $silent; |
| 125 | +} |
| 126 | + |
| 127 | +/** |
| 128 | + * Initialise the user object |
| 129 | + * |
| 130 | + * @param $username Username or IP address |
| 131 | + * @return User |
| 132 | + */ |
| 133 | +function initialiseUser( $username ) { |
| 134 | + if( User::isIP( $username ) ) { |
| 135 | + $user = new User(); |
| 136 | + $user->setId( 0 ); |
| 137 | + $user->setName( $username ); |
| 138 | + } else { |
| 139 | + $user = User::newFromName( $username ); |
| 140 | + } |
| 141 | + $user->load(); |
| 142 | + return $user; |
| 143 | +} |
| 144 | + |
Property changes on: trunk/phase3/maintenance/reassignEdits.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 145 | + native |
Index: trunk/phase3/maintenance/reassignEdits.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | $options = array( 'force', 'norc', 'quiet', 'report' ); |
14 | 14 | require_once( 'commandLine.inc' ); |
15 | | -require_once( 'reassignEdits.inc.php' ); |
| 15 | +require_once( 'reassignEdits.inc' ); |
16 | 16 | |
17 | 17 | # Set silent mode; --report overrides --quiet |
18 | 18 | if( !@$options['report'] && @$options['quiet'] ) |
Index: trunk/phase3/maintenance/deleteOrphanedRevisions.inc |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Support functions for the deleteOrphanedRevisions maintenance script |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Maintenance |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * Delete one or more revisions from the database |
| 14 | + * Do this inside a transaction |
| 15 | + * |
| 16 | + * @param $id Array of revision id values |
| 17 | + * @param $db Database class (needs to be a master) |
| 18 | + */ |
| 19 | +function deleteRevisions( $id, &$dbw ) { |
| 20 | + if( !is_array( $id ) ) |
| 21 | + $id = array( $id ); |
| 22 | + $dbw->delete( 'revision', array( 'rev_id' => $id ), 'deleteRevision' ); |
| 23 | +} |
| 24 | + |
| 25 | +/** |
| 26 | + * Spit out script usage information and exit |
| 27 | + */ |
| 28 | +function showUsage() { |
| 29 | + echo( "Finds revisions which refer to nonexisting pages and deletes them from the database\n" ); |
| 30 | + echo( "USAGE: php deleteOrphanedRevisions.php [--report]\n\n" ); |
| 31 | + echo( " --report : Prints out a count of affected revisions but doesn't delete them\n\n" ); |
| 32 | +} |
| 33 | + |
Property changes on: trunk/phase3/maintenance/deleteOrphanedRevisions.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 34 | + native |
Index: trunk/phase3/maintenance/deleteOrphanedRevisions.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | |
14 | 14 | $options = array( 'report', 'help' ); |
15 | 15 | require_once( 'commandLine.inc' ); |
16 | | -require_once( 'deleteOrphanedRevisions.inc.php' ); |
| 16 | +require_once( 'deleteOrphanedRevisions.inc' ); |
17 | 17 | echo( "Delete Orphaned Revisions\n" ); |
18 | 18 | |
19 | 19 | if( isset( $options['help'] ) ) { |
Index: trunk/phase3/docs/php-memcached/ChangeLog |
— | — | @@ -1,45 +1,28 @@ |
2 | | -Release 1.0.10 |
3 | | -* bug fix: changes hashing function to crc32, sprintf %u |
4 | | -* feature: optional compression |
| 2 | +09 Oct 2003: |
| 3 | + 1455 UTC: |
| 4 | + Released version 0.1.2 |
| 5 | + Fixed bug in get_multi; when debugging was enabled but no keys were fetched, |
| 6 | + script execution would halt (uninitialized $val) |
5 | 7 | |
6 | | -Release 1.0.9 |
7 | | -* protocol parsing bug |
| 8 | +08 Oct 2003: |
| 9 | + 1848 UTC: |
| 10 | + Released version 0.1.1 |
8 | 11 | |
9 | | -Release 1.0.8 |
10 | | -* whitespace/punctuation/wording cleanups |
| 12 | + 1825 UTC: |
| 13 | + Fixed bug in memcached::memcached; was attempting to initialize |
| 14 | + memcached::_dead_sock (function) instead of memcached::_dead_hosts |
| 15 | + (oops!) |
11 | 16 | |
12 | | -Release 1.0.7 |
13 | | -* added 3 functions which handle error reporting |
14 | | - error() - returns error number of last error generated, else returns 0 |
15 | | - error_string() - returns a string description of error number retuned |
16 | | - error_clear() - clears the last error number and error string |
17 | | -* removed call to preg_match() in _loaditems() |
18 | | -* only non-scalar values are serialize() before being |
19 | | - sent to the server |
20 | | -* added the optional timestamp argument for delete() |
21 | | - read Documentation file for details |
22 | | -* PHPDocs/PEAR style comments added |
23 | | -* abstract debugging (Brion Vibber <brion@pobox.com>) |
24 | | - |
25 | | -Release 1.0.6 |
26 | | -* removed all array_push() calls |
27 | | -* applied patch provided by Stuart Herbert<stuart@gentoo.org> |
28 | | - corrects possible endless loop. Available at |
29 | | - http://bugs.gentoo.org/show_bug.cgi?id=25385 |
30 | | -* fixed problem with storing large binary files |
31 | | -* added more error checking, specifically on all socket functions |
32 | | -* added support for the INCR and DECR commands |
33 | | - which increment or decrement a value stored in MemCached |
34 | | -* Documentation removed from source and is now available |
35 | | - in the file Documentation |
| 17 | + 1812 UTC: |
| 18 | + Fixed memcached::enable_compression; |
| 19 | + thanks to Justin Matlock <jmat@shutdown.net> for pointing it out |
36 | 20 | |
37 | | -Release 1.0.4 |
38 | | -* initial release, version numbers kept |
39 | | - in sync with MemCached version |
40 | | -* capable of storing any datatype in MemCached |
| 21 | +07 Oct 2003: |
| 22 | + 1635 UTC: |
| 23 | + Fixed call to memcached::_dead_sock in memcached::delete |
| 24 | + Added documentation for class variable $_buckets |
| 25 | + |
| 26 | +06 Oct 2003: |
| 27 | + 2039 UTC: |
| 28 | + Initial release of memcached-client-php; version 0.1 |
| 29 | + |
Index: trunk/phase3/docs/php-memcached/README |
— | — | @@ -0,0 +1 @@ |
| 2 | +HTML documentation is under http://phpca.cytherianage.net/memcached/doc/ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -150,6 +150,7 @@ |
151 | 151 | * Fix array logic in Sanitizer::removeHTMLtags so that it doesn't strip good tags |
152 | 152 | that were redundantly defined. |
153 | 153 | * (bug 14118) SpecialPage::getTitleFor does not return a localised name |
| 154 | +* (bug 18698) Renaming non entry point maintenance scripts from .inc.php to .inc |
154 | 155 | |
155 | 156 | == API changes in 1.16 == |
156 | 157 | |