Changeset 11228 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php
- Timestamp:
- 09/14/2021 05:45:59 AM (5 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php
r11227 r11228 5 5 use WP_Http; 6 6 7 class Internal _Stats{7 class Internal { 8 8 9 9 function __construct() { … … 11 11 'methods' => \WP_REST_Server::CREATABLE, 12 12 'callback' => array( $this, 'bulk_update_stats' ), 13 'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ), 14 ) ); 15 16 register_rest_route( 'themes/v1', 'svn-auth', array( 17 'methods' => \WP_REST_Server::READABLE, 18 'callback' => array( $this, 'svn_auth' ), 13 19 'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ), 14 20 ) ); … … 38 44 39 45 return true; 46 } 47 48 /** 49 * Generates a SVN auth file. 50 * 51 * The SVN auth file is printed directly to the output, designed to be consumed by a cron task. 52 */ 53 function svn_auth() { 54 global $wpdb; 55 56 header( 'Content-Type: text/plain' ); 57 58 // Raw SQL to avoid loading every WP_Post / WP_User object causing OOM errors. 59 $themes = $wpdb->get_results( 60 "SELECT p.post_name as slug, u.user_login as user 61 FROM {$wpdb->posts} p 62 JOIN {$wpdb->users} u ON p.post_author = u.ID 63 WHERE p.post_type = 'repopackage' AND p.post_status IN( 'publish', 'delist' ) 64 ORDER BY p.post_name ASC" 65 ); 66 67 // Some users need write access to all themes, such as the dropbox user. 68 $all_access_users = get_option( 'svn_all_access', array() ); 69 $all_access_users[] = 'themedropbox'; 70 echo "[/]\n"; 71 echo "* = r\n"; 72 foreach ( array_unique( $all_access_users ) as $u ) { 73 echo "{$u} = rw\n"; 74 } 75 echo "\n"; 76 77 // Theme Authors. 78 foreach ( $themes as $r ) { 79 if ( ! $r->slug ) { 80 // This should never occur, but just to ensure this never produces [/]. 81 continue; 82 } 83 84 printf( 85 "[%s]\n%s = rw\n\n", 86 '/' . $r->slug, 87 $r->user 88 ); 89 90 } 91 92 exit(); 40 93 } 41 94 … … 118 171 119 172 } 120 new Internal _Stats();173 new Internal();
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)