A patch to cache articles after conversion to HTML but before insertion
[mediawiki.git] / maintenance / rcdumper.php
bloba90497d8529d67bab5c16944df9c6a58bd951ba5
1 <?
3 $wgCommandLineMode = true;
5 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
6 if ( $argv[1] ) {
7 $lang = $argv[1];
8 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
9 $newpath = "/apache/common/php$sep";
10 } else {
11 $settingsFile = "../LocalSettings.php";
12 $newpath = "";
15 if ( $argv[2] ) {
16 print $argv[2] . "\n";
17 $patterns = explode( ",", $argv[2]);
18 } else {
19 $patterns = false;
22 if ( ! is_readable( $settingsFile ) ) {
23 print "A copy of your installation's LocalSettings.php\n" .
24 "must exist in the source directory.\n";
25 exit();
28 $wgCommandLineMode = true;
29 $DP = "../includes";
30 include_once( $settingsFile );
32 ini_set( "include_path", "$newpath$IP$sep$include_path" );
34 include_once( "Setup.php" );
35 $wgTitle = Title::newFromText( "RC dumper" );
36 $wgCommandLineMode = true;
37 set_time_limit(0);
39 $res = wfQuery( "SELECT rc_timestamp FROM recentchanges ORDER BY rc_timestamp DESC LIMIT 1", DB_READ );
40 $row = wfFetchObject( $res );
41 $oldTimestamp = $row->rc_timestamp;
43 while (1) {
44 $res = wfQuery( "SELECT * FROM recentchanges WHERE rc_timestamp>'$oldTimestamp' ORDER BY rc_timestamp", DB_READ );
45 while ( $row = wfFetchObject( $res ) ) {
46 $ns = $wgLang->getNsText( $row->rc_namespace ) ;
47 if ( $ns ) {
48 $title = "$ns:{$row->rc_title}";
49 } else {
50 $title = $row->rc_title;
52 /*if ( strlen( $row->rc_comment ) > 50 ) {
53 $comment = substr( $row->rc_comment, 0, 50 );
54 } else {*/
55 $comment = $row->rc_comment;
56 // }
57 $bad = array("\n", "\r");
58 $empty = array("", "");
59 $comment = str_replace($bad, $empty, $comment);
60 $title = str_replace($bad, $empty, $title);
61 $user = str_replace($bad, $empty, $row->rc_user_text);
62 $url = "http://$lang.wikipedia.org/wiki/" . urlencode($title);
64 if ( $patterns ) {
65 foreach ( $patterns as $pattern ) {
66 if ( preg_match( $pattern, $comment ) ) {
67 print chr(7);
68 break;
72 print( "$url ($user) $comment\n" );
73 $oldTimestamp = $row->rc_timestamp;
75 sleep(5);
78 exit();