Index: trunk/extensions/OracleTextSearch/maintainenceFixOTSLinks.php |
— | — | @@ -1,6 +1,11 @@ |
2 | 2 | <?php |
3 | | -/* run this script out of your $IP/maintenance folder */ |
4 | | -require_once( 'Maintenance.php' ); |
| 3 | +if ( getenv( 'MW_INSTALL_PATH' ) !== false ) { |
| 4 | + $IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +} else { |
| 6 | + $dir = dirname( __FILE__ ); |
| 7 | + $IP = "$dir/../.."; |
| 8 | +} |
| 9 | +require_once( "$IP/maintenance/Maintenance.php" ); |
5 | 10 | |
6 | 11 | class FixOTSLinks extends Maintenance { |
7 | 12 | public function __construct() { |
— | — | @@ -12,9 +17,9 @@ |
13 | 18 | public function execute() { |
14 | 19 | $doAll = $this->hasOption( 'all' ); |
15 | 20 | if ($doAll) { |
16 | | - $this->output( "Recreate all index links to documents\n\n" ); |
| 21 | + $this->output( "Recreating all index links to documents ", 'OracleTextSearch' ); |
17 | 22 | } else { |
18 | | - $this->output( "Recreate missing index links to documents\n\n" ); |
| 23 | + $this->output( "Recreating missing index links to documents ", 'OracleTextSearch' ); |
19 | 24 | } |
20 | 25 | $this->doRecreate($doAll); |
21 | 26 | } |
— | — | @@ -28,36 +33,40 @@ |
29 | 34 | |
30 | 35 | $searchWhere = $all ? '' : ' AND NOT EXISTS (SELECT null FROM '.$tbl_idx.' WHERE si_page=p.page_id AND si_url IS NOT null)'; |
31 | 36 | $result = $dbw->doQuery('SELECT p.page_id FROM '.$tbl_pag.' p WHERE p.page_namespace = '.NS_FILE.$searchWhere ); |
32 | | - $this->output($result->numRows().' files found.'."\n\n"); |
| 37 | + $this->output( "[".$result->numRows()." files found] ", 'OracleTextSearch' ); |
33 | 38 | |
34 | 39 | $syncIdx = false; |
35 | | - |
| 40 | + $countDone = 0; |
| 41 | + $countSkipped = 0; |
| 42 | + |
36 | 43 | while (($row = $result->fetchObject()) !== false) { |
37 | 44 | $titleObj = Title::newFromID($row->page_id); |
38 | 45 | $file = wfLocalFile($titleObj->getText()); |
39 | 46 | |
40 | | - $this->output('Updating "'.$titleObj->getText().'" ... '); |
41 | | - |
42 | 47 | if (in_array( $file->getMimeType(), $wgExIndexMIMETypes )) { |
43 | 48 | $url = $wgExIndexOnHTTP ? preg_replace( '/^https:/i', 'http:', $file->getFullUrl() ) : $file->getFullUrl(); |
44 | 49 | $dbw->update('searchindex', |
45 | 50 | array( 'si_url' => $url ), |
46 | 51 | array( 'si_page' => $row->page_id ), |
47 | 52 | 'SearchIndexUpdate:update' ); |
48 | | - $this->output('complete'."\n"); |
49 | 53 | $syncIdx = true; |
50 | 54 | } else { |
51 | | - $this->output('skipped (unsupported or excluded mime-type)'."\n"); |
| 55 | + $countSkipped++; |
52 | 56 | } |
| 57 | + $countDone++; |
53 | 58 | } |
54 | 59 | |
55 | 60 | if ( $syncIdx ) { |
56 | | - $this->output("\n".'Syncing Index'."\n"); |
| 61 | + $this->output( " Syncing... ", 'OracleTextSearch'); |
57 | 62 | $index = $dbw->getProperty('mTablePrefix')."si_url_idx"; |
58 | 63 | $dbw->query( "CALL ctx_ddl.sync_index('$index')" ); |
59 | 64 | } |
60 | 65 | |
61 | | - $this->output('Recreate finished'); |
| 66 | + $this->output(" Finished ($countDone processed", 'OracleTextSearch'); |
| 67 | + if ( $countSkipped > 0 ) { |
| 68 | + $this->output(", $countSkipped skipped ", 'OracleTextSearch'); |
| 69 | + } |
| 70 | + $this->output(")", 'OracleTextSearch'); |
62 | 71 | } |
63 | 72 | } |
64 | 73 | |