Changeset 11372
- Timestamp:
- 12/15/2021 04:38:09 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/svn.php
r11371 r11372 21 21 'url' => 'https://develop.svn.wordpress.org', 22 22 'trac' => 'https://core.trac.wordpress.org', 23 'trac_table' => 'trac_core', 23 24 'rev_table' => 'trac_core_revisions', 24 25 'props_table' => 'trac_core_props', … … 29 30 'url' => 'https://meta.svn.wordpress.org', 30 31 'trac' => 'https://meta.trac.wordpress.org', 32 'trac_table' => 'trac_meta', 31 33 'rev_table' => 'trac_meta_revisions', 32 34 'props_table' => 'trac_meta_props', 33 ] 35 ], 36 'plugins' => [ 37 'slug' => 'plugins', 38 'name' => 'Plugins', 39 'url' => 'https://plugins.svn.wordpress.org', 40 'trac' => 'https://plugins.trac.wordpress.org', 41 'trac_table' => 'trac_plugins', 42 'rev_table' => false, 43 'props_table' => false, 44 ], 45 'themes' => [ 46 'slug' => 'themes', 47 'name' => 'Themes', 48 'url' => 'https://themes.svn.wordpress.org', 49 'trac' => 'https://themes.trac.wordpress.org', 50 'trac_table' => 'trac_themes', 51 'rev_table' => false, 52 'props_table' => false, 53 ], 54 'buddypress' => [ 55 'slug' => 'buddypress', 56 'name' => 'BuddyPress', 57 'url' => 'https://buddypress.svn.wordpress.org', 58 'trac' => 'https://buddypress.trac.wordpress.org', 59 'trac_table' => 'trac_buddypress', 60 'rev_table' => false, 61 'props_table' => false, 62 ], 63 'bbpress' => [ 64 'slug' => 'bbpress', 65 'name' => 'bbPress', 66 'url' => 'https://bbpress.svn.wordpress.org', 67 'trac' => 'https://bbpress.trac.wordpress.org', 68 'trac_table' => 'trac_bbpress', 69 'rev_table' => false, 70 'props_table' => false, 71 ], 34 72 ]; 35 73 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/trac-watch.php
r11371 r11372 90 90 91 91 foreach ( SVN\get_svns() as $prefix => $info ) { 92 $wpdb->query( sprintf( $trac_table, 'trac_' . $prefix ) ); 92 if ( ! empty( $info['trac_table'] ) ) { 93 $wpdb->query( sprintf( $trac_table, $info['trac_table'] ) ); 94 } 93 95 if ( ! empty( $info['rev_table'] ) ) { 94 96 $wpdb->query( sprintf( $revisions_table, $info['rev_table'] ) ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-trac-watcher/trac.php
r11371 r11372 1 1 <?php 2 2 namespace WordPressdotorg\Trac\Watcher\Trac; 3 use function WordPressdotorg\Trac\Watcher\SVN\get_svns; 4 use SimpleXmlElement; 3 5 4 6 add_action( 'import_trac_feeds', function() { 5 // Trac RSS feed import from profiles.w.org to be moved here. 7 8 foreach ( get_svns() as $svn ) { 9 if ( empty( $svn['trac'] ) || empty( $svn['trac_table'] ) ) { 10 continue; 11 } 12 13 import_trac_feed( $svn ); 14 } 6 15 } ); 16 17 function import_trac_feed( $svn ) { 18 global $wpdb; 19 20 $feed_url = $svn['trac'] . '/timeline?ticket=on&changeset=on&milestone=on&wiki=on&max=50&daysback=5&format=rss'; 21 22 $feed = wp_remote_retrieve_body( wp_remote_get( $feed_url, array( 'timeout' => 60 ) ) ); 23 if ( ! $feed ) { 24 return; 25 } 26 27 $xml = new SimpleXmlElement( $feed ); 28 if ( ! isset( $xml->channel->item ) ) { 29 return; 30 } 31 32 $trac_table = $svn['trac_table']; // Not user input, safe. 33 34 foreach ( $xml->channel->item as $item ) { 35 $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); 36 $md5_id = md5( strip_tags( $item->title . $dc->creator . $item->pubDate ) ); 37 38 if ( $wpdb->get_var( $wpdb->prepare( "SELECT md5_id FROM {$trac_table} WHERE md5_id = %s LIMIT 1", $md5_id ) ) ) { 39 // if this entry is already in our database, that means all the previous ones should be too 40 break; 41 } 42 43 $wpdb->insert( 44 $trac_table, 45 [ 46 'md5_id' => $md5_id, 47 'description' => trim( strip_tags( (string) $item->description, '<a><strike>' ) ), 48 'summary' => (string) $item->summary, 49 'category' => (string) $item->category, 50 'username' => (string) $dc->creator, 51 'link' => (string) $item->link, 52 'pubdate' => gmdate( 'Y-m-d H:i:s', strtotime( (string) $item->pubDate ) ), 53 'title' => (string) $item->title, 54 ] 55 ); 56 } 57 } 7 58 8 59 function format_trac_markup( $message ) {
Note: See TracChangeset
for help on using the changeset viewer.