Index: trunk/extensions/ArchiveLinks/ArchiveLinks.php |
— | — | @@ -19,14 +19,18 @@ |
20 | 20 | |
21 | 21 | $wgHooks['ArticleSaveComplete'][] = 'ArchiveLinks::queueExternalLinks'; |
22 | 22 | $wgHooks['LinkerMakeExternalLink'][] = 'ArchiveLinks::rewriteLinks'; |
| 23 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'ArchiveLinks::schemaUpdates'; |
23 | 24 | |
24 | 25 | $wgSpecialPages['ModifyArchiveBlacklist'] = 'SpecialModifyArchiveBlacklist'; |
25 | 26 | $wgSpecialPages['ViewArchive'] = 'SpecialViewArchive'; |
26 | 27 | |
| 28 | +$wgAutoloadClasses['ApiQueryArchiveFeed'] = "$path/ApiQueryArchiveFeed.php"; |
| 29 | +$wgAPIListModules['archivefeed'] = 'ApiQueryArchiveFeed'; |
| 30 | + |
27 | 31 | $wgArchiveLinksConfig = array( |
28 | | - 'archive_service' => 'wikiwix', |
| 32 | + 'archive_service' => 'internet_archive', |
29 | 33 | 'use_multiple_archives' => false, |
30 | 34 | 'run_spider_in_loop' => false, |
31 | 35 | 'in_progress_ignore_delay' => 7200, |
32 | | - 'generate_feed' => true, |
| 36 | + 'generate_feed' => false, |
33 | 37 | ); |
\ No newline at end of file |
Index: trunk/extensions/ArchiveLinks/setuptables.sql |
— | — | @@ -1,22 +1,22 @@ |
2 | | -CREATE TABLE IF NOT EXISTS `el_archive_blacklist` ( |
| 2 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/`el_archive_blacklist` ( |
3 | 3 | `bl_id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
4 | 4 | `bl_type` tinyint(4) NOT NULL, |
5 | 5 | `bl_url` varchar(10000) NOT NULL, |
6 | 6 | `bl_expiry` int(11) unsigned NOT NULL, |
7 | 7 | `bl_reason` varchar(255) NOT NULL, |
8 | 8 | PRIMARY KEY (`bl_id`) |
9 | | -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; |
| 9 | +) /*$wgDBTableOptions*/; |
10 | 10 | |
11 | | -CREATE TABLE IF NOT EXISTS `el_archive_log` ( |
| 11 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/`el_archive_log` ( |
12 | 12 | `log_id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
13 | 13 | `log_result` tinyint(4) NOT NULL, |
14 | 14 | `log_url` varchar(10000) NOT NULL, |
15 | 15 | `log_time` int(11) unsigned NOT NULL, |
16 | 16 | `log_http_code` varchar(255) NOT NULL, |
17 | 17 | PRIMARY KEY (`log_id`) |
18 | | -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; |
| 18 | +) /*$wgDBTableOptions*/; |
19 | 19 | |
20 | | -CREATE TABLE IF NOT EXISTS `el_archive_queue` ( |
| 20 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/`el_archive_queue` ( |
21 | 21 | `queue_id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
22 | 22 | `page_id` int(11) unsigned NOT NULL, |
23 | 23 | `url` varchar(10000) NOT NULL, |
— | — | @@ -24,12 +24,20 @@ |
25 | 25 | `insertion_time` int(11) unsigned NOT NULL, |
26 | 26 | `in_progress` varchar(50) NOT NULL, |
27 | 27 | PRIMARY KEY (`queue_id`) |
28 | | -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=105 ; |
| 28 | +) /*$wgDBTableOptions*/; |
29 | 29 | |
30 | | -CREATE TABLE IF NOT EXISTS `el_archive_link_history` ( |
| 30 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/`el_archive_link_history` ( |
31 | 31 | `hist_id` int(11) unsigned NOT NULL, |
32 | 32 | `hist_page_id` int(11) unsigned NOT NULL, |
33 | 33 | `hist_url` varchar(10000) NOT NULL, |
34 | 34 | `hist_insertion_time` int(11) unsigned NOT NULL, |
35 | 35 | PRIMARY KEY (`hist_id`) |
36 | | -) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
\ No newline at end of file |
| 36 | +) /*$wgDBTableOptions*/; |
| 37 | + |
| 38 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/`el_archive_resource` ( |
| 39 | + `resource_id` int(11) NOT NULL, |
| 40 | + `el_id` int(11) NOT NULL, |
| 41 | + `resource_url` varchar(10000) NOT NULL, |
| 42 | + `resource_location` varchar(10000) NOT NULL, |
| 43 | + PRIMARY KEY (`resource_id`) |
| 44 | +) /*$wgDBTableOptions*/; |
Index: trunk/extensions/ArchiveLinks/ArchiveLinks.class.php |
— | — | @@ -42,6 +42,8 @@ |
43 | 43 | $old_id = $article->getTitle(); |
44 | 44 | $old_id = $old_id->getPreviousRevisionID( $page_id ); |
45 | 45 | |
| 46 | + die('firing'); |
| 47 | + |
46 | 48 | $db_result['links_on_page'] = $db_master->select( 'el_archive_link_history', '*', array( 'hist_page_id' => $page_id ), __METHOD__ ); |
47 | 49 | |
48 | 50 | $old_external_links = array(); |
— | — | @@ -55,7 +57,7 @@ |
56 | 58 | $new_external_links = array_diff( $external_links, $old_external_links ); |
57 | 59 | unset( $old_external_links ); |
58 | 60 | |
59 | | - die( var_dump( $old_external_links ) ); |
| 61 | + //die( var_dump( $old_external_links ) ); |
60 | 62 | } elseif ( count( $external_links ) > 0 ) { |
61 | 63 | $new_external_links = $external_links; |
62 | 64 | } |
— | — | @@ -67,27 +69,13 @@ |
68 | 70 | if ( count( $new_external_links ) <= $wgArchiveLinksConfig['link_insert_max'] ) { |
69 | 71 | //insert the links into the queue now |
70 | 72 | foreach( $new_external_links as $link ) { |
71 | | - /*$db_result['blacklist'] = $db_slave->select( 'el_archive_blacklist', '*', array( 'bl_url' => $link ), __METHOD__, array( 'LIMIT' => '1', ) ); |
| 73 | + $this->feed_insert_links( $link ); |
| 74 | + |
| 75 | + /* |
72 | 76 | |
73 | 77 | |
74 | 78 | /* |
75 | | - if ( $db_result['blacklist-numrows'] === 0 && $db_result['queue-numrows'] === 0 ) { |
76 | | - //this link is new to the wiki |
77 | | - $db_master->insert( 'el_archive_queue', array( |
78 | | - 'page_id' => $page_id, |
79 | | - 'url' => $link, |
80 | | - 'delay_time' => '0', |
81 | | - 'insertion_time' => $time, |
82 | | - 'in_progress' => '0', |
83 | | - )); |
84 | | - |
85 | | - $db_master->insert( 'el_archive_link_history', array( |
86 | | - 'page_id' => $page_id, |
87 | | - 'url' => $link, |
88 | | - 'delay_time' => '0', |
89 | | - 'insertion_time' => $time, |
90 | | - 'in_progress' => '0', |
91 | | - )); |
| 79 | + |
92 | 80 | } elseif ( $db_result['history-row']['hist_insertion_time'] >= $time - $wgArchiveLinksConfig['global_rearchive_time'] ) { |
93 | 81 | $db_result['history_page'] = $db_slave->select( 'el_archive_link_history', '*', array( 'hist_url' => $link, 'page_id' => $page_id ), __METHOD__, array( 'LIMIT' => '1', 'ORDER BY' => 'hist_id DESC' ) ); |
94 | 82 | |
— | — | @@ -224,11 +212,64 @@ |
225 | 213 | $url = $this->strencode( $url ); |
226 | 214 | } |
227 | 215 | |
228 | | - $db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', array( 'url' => $link ), __METHOD__, array( 'LIMIT' => '1', ) ); |
229 | | - |
230 | | - $db_result['queue-numrows'] = $db_result['queue']->numRows(); |
231 | | - $db_result['blacklist-numrows'] = $db_result['blacklist']->numRows(); |
| 216 | + $db_result['queue'] = $db_slave->select( 'el_archive_queue', '*', array( 'url' => $link ), __METHOD__, array( 'LIMIT' => '1', ) ); |
| 217 | + $db_result['blacklist'] = $db_slave->select( 'el_archive_blacklist', '*', array( 'bl_url' => $link ), __METHOD__, array( 'LIMIT' => '1', ) ); |
| 218 | + |
| 219 | + $db_result['queue-numrows'] = $db_result['queue']->numRows(); |
| 220 | + $db_result['blacklist-numrows'] = $db_result['blacklist']->numRows(); |
| 221 | + |
| 222 | + if ( $db_result['blacklist-numrows'] === 0 && $db_result['queue-numrows'] === 0 ) { |
| 223 | + $db_master->insert( 'el_archive_queue', array( |
| 224 | + 'page_id' => $page_id, |
| 225 | + 'url' => $link, |
| 226 | + 'delay_time' => '0', |
| 227 | + 'insertion_time' => $time, |
| 228 | + 'in_progress' => '0', |
| 229 | + )); |
| 230 | + |
| 231 | + $db_master->insert( 'el_archive_link_history', array( |
| 232 | + 'page_id' => $page_id, |
| 233 | + 'url' => $link, |
| 234 | + 'delay_time' => '0', |
| 235 | + 'insertion_time' => $time, |
| 236 | + 'in_progress' => '0', |
| 237 | + )); |
| 238 | + } |
232 | 239 | } |
| 240 | + |
| 241 | + public static function schemaUpdate ( $updater = null ) { |
| 242 | + $path = dirname( __FILE__ ); |
| 243 | + $updater->addExtesionUpdate( array( |
| 244 | + 'addTable', |
| 245 | + 'el_archive_link_history', |
| 246 | + $path . '/setuptables.sql', |
| 247 | + true |
| 248 | + )); |
| 249 | + $updater->addExtesionUpdate( array( |
| 250 | + 'addTable', |
| 251 | + 'el_archive_queue', |
| 252 | + $path . '/setuptables.sql', |
| 253 | + true |
| 254 | + )); |
| 255 | + $updater->addExtesionUpdate( array( |
| 256 | + 'addTable', |
| 257 | + 'el_archive_log', |
| 258 | + $path . '/setuptables.sql', |
| 259 | + true |
| 260 | + )); |
| 261 | + $updater->addExtesionUpdate( array( |
| 262 | + 'addTable', |
| 263 | + 'el_archive_resource', |
| 264 | + $path . '/setuptables.sql', |
| 265 | + true |
| 266 | + )); |
| 267 | + $updater->addExtesionUpdate( array( |
| 268 | + 'addTable', |
| 269 | + 'el_archive_link_blacklist', |
| 270 | + $path . '/setuptables.sql', |
| 271 | + true |
| 272 | + )); |
| 273 | + } |
233 | 274 | } |
234 | 275 | |
235 | 276 | class InsertURLsIntoQueue extends Job { |