r46924 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46923‎ | r46924 | r46925 >
Date:15:59, 6 February 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
parameter to refreh data for fixed (list of) page name(s), incorporating a feature request from Jie Bao
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php
@@ -13,13 +13,16 @@
1414 *
1515 * -d <delay> Wait for this many milliseconds after processing an article, useful for limiting server load.
1616 * -s <startid> Start refreshing at given article ID, useful for partial refreshing
17 - * -e <endid> Stop refreshing at given article ID, useful for partial refreshing
18 - * -b <backend> Execute the operation for the storage backend of the given name
 17+ * -e <endid> Stop refreshing at given article ID, useful for partial refreshing
 18+ * -b <backend> Execute the operation for the storage backend of the given name
1919 * (default is to use the current backend)
2020 * -v Be verbose about the progress.
2121 * -c Will refresh only category pages (and other explicitly named namespaces)
2222 * -p Will refresh only property pages (and other explicitly named namespaces)
2323 * -t Will refresh only type pages (and other explicitly named namespaces)
 24+ * --page=<pagelist> will refresh only the pages of the given names, with | used as a separator.
 25+ * Example: --page="Page 1|Page 2" refreshes Page 1 and Page 2
 26+ * Options -s, -e, -c, -p, -t are ignored if --page is given.
2427 * -f Fully delete all content instead of just refreshing relevant entries. This will also
2528 * rebuild the whole storage structure. May leave the wiki temporarily incomplete.
2629 * --server=<server> The protocol and server name to as base URLs, e.g.
@@ -32,7 +35,7 @@
3336 * @ingroup SMWMaintenance
3437 */
3538
36 -$optionsWithArgs = array( 'd', 's', 'e', 'b', 'server'); // -d <delay>, -s <startid>, -e <endid>, -b <backend>
 39+$optionsWithArgs = array( 'd', 's', 'e', 'b', 'server','page'); // -d <delay>, -s <startid>, -e <endid>, -b <backend>
3740
3841 require_once ( getenv('MW_INSTALL_PATH') !== false
3942 ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
@@ -52,6 +55,12 @@
5356 $delay = false;
5457 }
5558
 59+if ( isset( $options['page'] ) ) {
 60+ $pages = explode('|',$options['page']);
 61+} else {
 62+ $pages = false;
 63+}
 64+
5665 if ( array_key_exists( 's', $options ) ) {
5766 $start = max(1,intval($options['s']));
5867 } else {
@@ -107,27 +116,42 @@
108117 echo "\nAll storage structures have been deleted and recreated.\n\n";
109118 }
110119
111 -print "Refreshing all semantic data in the database!\n---\n" .
112 -" Some versions of PHP suffer from memory leaks in long-running scripts.\n" .
113 -" If your machine gets very slow after many pages (typically more than\n" .
114 -" 1000) were refreshed, please abort with CTRL-C and resume this script\n" .
115 -" at the last processed page id using the parameter -s (use -v to display\n" .
116 -" page ids during refresh). Continue this until all pages were refreshed.\n---\n";
117 -print "Processing all IDs from $start to " . ($end?"$end":"last ID") . " ...\n";
118 -
119120 $linkCache =& LinkCache::singleton();
120 -$id = $start;
121121 $num_files = 0;
122 -while ( ((!$end) || ($id <= $end)) && ($id > 0) ) {
123 - if ($verbose) {
124 - print "($num_files) Processing ID " . $id . " ...\n";
125 - }
126 - smwfGetStore()->refreshData($id, 1, $filter, false);
127 - if ( ($delay !== false) && (($num_files+1) % 100 === 0) ) {
128 - usleep($delay);
 122+if ($pages == false) {
 123+ print "Refreshing all semantic data in the database!\n---\n" .
 124+ " Some versions of PHP suffer from memory leaks in long-running scripts.\n" .
 125+ " If your machine gets very slow after many pages (typically more than\n" .
 126+ " 1000) were refreshed, please abort with CTRL-C and resume this script\n" .
 127+ " at the last processed page id using the parameter -s (use -v to display\n" .
 128+ " page ids during refresh). Continue this until all pages were refreshed.\n---\n";
 129+ print "Processing all IDs from $start to " . ($end?"$end":"last ID") . " ...\n";
 130+
 131+ $id = $start;
 132+ while ( ((!$end) || ($id <= $end)) && ($id > 0) ) {
 133+ if ($verbose) {
 134+ print "($num_files) Processing ID " . $id . " ...\n";
 135+ }
 136+ smwfGetStore()->refreshData($id, 1, $filter, false);
 137+ if ( ($delay !== false) && (($num_files+1) % 100 === 0) ) {
 138+ usleep($delay);
 139+ }
 140+ $num_files++;
 141+ $linkCache->clear(); // avoid memory leaks
129142 }
130 - $num_files++;
131 - $linkCache->clear(); // avoid memory leaks
 143+ print "$num_files IDs refreshed.\n";
 144+} else {
 145+ print "Refreshing specified pages!\n\n";
 146+ foreach ($pages as $page) {
 147+ if ($verbose) {
 148+ print "($num_files) Processing page " . $page . " ...\n";
 149+ }
 150+ $title = Title::newFromText($page);
 151+ if ( $title !== NULL ) {
 152+ $updatejob = new SMWUpdateJob($title);
 153+ $updatejob->run();
 154+ }
 155+ $num_files++;
 156+ }
 157+ print "$num_files pages refreshed.\n";
132158 }
133 -
134 -print "$num_files IDs refreshed.\n";

Status & tagging log