Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php |
— | — | @@ -13,13 +13,16 @@ |
14 | 14 | * |
15 | 15 | * -d <delay> Wait for this many milliseconds after processing an article, useful for limiting server load. |
16 | 16 | * -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 |
19 | 19 | * (default is to use the current backend) |
20 | 20 | * -v Be verbose about the progress. |
21 | 21 | * -c Will refresh only category pages (and other explicitly named namespaces) |
22 | 22 | * -p Will refresh only property pages (and other explicitly named namespaces) |
23 | 23 | * -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. |
24 | 27 | * -f Fully delete all content instead of just refreshing relevant entries. This will also |
25 | 28 | * rebuild the whole storage structure. May leave the wiki temporarily incomplete. |
26 | 29 | * --server=<server> The protocol and server name to as base URLs, e.g. |
— | — | @@ -32,7 +35,7 @@ |
33 | 36 | * @ingroup SMWMaintenance |
34 | 37 | */ |
35 | 38 | |
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> |
37 | 40 | |
38 | 41 | require_once ( getenv('MW_INSTALL_PATH') !== false |
39 | 42 | ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
— | — | @@ -52,6 +55,12 @@ |
53 | 56 | $delay = false; |
54 | 57 | } |
55 | 58 | |
| 59 | +if ( isset( $options['page'] ) ) { |
| 60 | + $pages = explode('|',$options['page']); |
| 61 | +} else { |
| 62 | + $pages = false; |
| 63 | +} |
| 64 | + |
56 | 65 | if ( array_key_exists( 's', $options ) ) { |
57 | 66 | $start = max(1,intval($options['s'])); |
58 | 67 | } else { |
— | — | @@ -107,27 +116,42 @@ |
108 | 117 | echo "\nAll storage structures have been deleted and recreated.\n\n"; |
109 | 118 | } |
110 | 119 | |
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 | | - |
119 | 120 | $linkCache =& LinkCache::singleton(); |
120 | | -$id = $start; |
121 | 121 | $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 |
129 | 142 | } |
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"; |
132 | 158 | } |
133 | | - |
134 | | -print "$num_files IDs refreshed.\n"; |