Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php |
— | — | @@ -14,6 +14,9 @@ |
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 | 17 | * -e <endid> Stop refreshing at given article ID, useful for partial refreshing |
| 18 | + * -n <numids> Stop refreshing after processing a given number of IDs, useful for partial refreshing |
| 19 | + * --startidfile <startidfile> Read <startid> from a file instead of the arguments and write the next id |
| 20 | + * to the file when finished. Useful for continual partial refreshing from cron. |
18 | 21 | * -b <backend> Execute the operation for the storage backend of the given name |
19 | 22 | * (default is to use the current backend) |
20 | 23 | * -v Be verbose about the progress. |
— | — | @@ -22,7 +25,7 @@ |
23 | 26 | * -t Will refresh only type pages (and other explicitly named namespaces) |
24 | 27 | * --page=<pagelist> will refresh only the pages of the given names, with | used as a separator. |
25 | 28 | * 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. |
| 29 | + * Options -s, -e, -n, --startidfile, -c, -p, -t are ignored if --page is given. |
27 | 30 | * -f Fully delete all content instead of just refreshing relevant entries. This will also |
28 | 31 | * rebuild the whole storage structure. May leave the wiki temporarily incomplete. |
29 | 32 | * --server=<server> The protocol and server name to as base URLs, e.g. |
— | — | @@ -35,7 +38,7 @@ |
36 | 39 | * @ingroup SMWMaintenance |
37 | 40 | */ |
38 | 41 | |
39 | | -$optionsWithArgs = array( 'd', 's', 'e', 'b', 'server', 'page' ); // -d <delay>, -s <startid>, -e <endid>, -b <backend> |
| 42 | +$optionsWithArgs = array( 'd', 's', 'e', 'n', 'b', 'startidfile', 'server', 'page' ); // -d <delay>, -s <startid>, -e <endid>, -n <numids>, --startidfile <startidfile> -b <backend> |
40 | 43 | |
41 | 44 | require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
42 | 45 | ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
— | — | @@ -61,13 +64,27 @@ |
62 | 65 | $pages = false; |
63 | 66 | } |
64 | 67 | |
| 68 | +$writeToStartidfile = false; |
65 | 69 | if ( array_key_exists( 's', $options ) ) { |
66 | 70 | $start = max( 1, intval( $options['s'] ) ); |
| 71 | +} elseif ( array_key_exists( 'startidfile', $options ) ) { |
| 72 | + if ( !is_writable( file_exists( $options['startidfile'] ) ? $options['startidfile'] : dirname( $options['startidfile'] ) ) ) { |
| 73 | + die("Cannot use a startidfile that we can't write to.\n"); |
| 74 | + } |
| 75 | + $writeToStartidfile = true; |
| 76 | + if ( is_readable( $options['startidfile'] ) ) { |
| 77 | + $start = max( 1, intval( file_get_contents( $options['startidfile'] ) ) ); |
| 78 | + } else { |
| 79 | + $start = 1; |
| 80 | + } |
67 | 81 | } else { |
68 | 82 | $start = 1; |
69 | 83 | } |
| 84 | + |
70 | 85 | if ( array_key_exists( 'e', $options ) ) { // Note: this might reasonably be larger than the page count |
71 | 86 | $end = intval( $options['e'] ); |
| 87 | +} elseif ( array_key_exists( 'n', $options ) ) { |
| 88 | + $end = $start + intval( $options['n'] ); |
72 | 89 | } else { |
73 | 90 | $end = false; |
74 | 91 | } |
— | — | @@ -158,6 +175,9 @@ |
159 | 176 | $num_files++; |
160 | 177 | $linkCache->clear(); // avoid memory leaks |
161 | 178 | } |
| 179 | + if ( $writeToStartidfile ) { |
| 180 | + file_put_contents( $options['startidfile'], "$id" ); |
| 181 | + } |
162 | 182 | print "$num_files IDs refreshed.\n"; |
163 | 183 | } else { |
164 | 184 | print "Refreshing specified pages!\n\n"; |