Making WordPress.org


Ignore:
Timestamp:
04/07/2017 09:16:09 PM (9 years ago)
Author:
coffee2code
Message:

Support Forums: Update to query against the new Plugin Directory WP tables.

Updates get_object_by_slug_and_type(), get_authors(), get_contributors(), get_plugin_slugs_by_committer(), get_plugin_slugs_by_contributor().

Fixes #2701.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php

    r5097 r5286  
    133133                                                'taxonomy'    => 'topic-plugin',
    134134                                                'field'       => 'slug',
    135                                                 'terms'       => self::get_plugin_slugs_by_committer( $this->user->user_login ),
     135                                                'terms'       => self::get_plugin_slugs_by_committer( $this->user->user_nicename ),
    136136                                        ) ),
    137137                                        'show_stickies'   => false,
     
    145145                                                'taxonomy'    => 'topic-plugin',
    146146                                                'field'       => 'slug',
    147                                                 'terms'       => $this->get_plugin_slugs_by_contributor( $this->user ),
     147                                                'terms'       => $this->get_plugin_slugs_by_contributor( $this->user->user_nicename ),
    148148                                        ) ),
    149149                                        'show_stickies'   => false,
     
    168168                if ( $view == 'plugin-committer' ) {
    169169
    170                         $slugs = self::get_plugin_slugs_by_committer( $this->user->user_login );
     170                        $slugs = self::get_plugin_slugs_by_committer( $this->user->user_nicename );
    171171
    172172                        // Add plugin-committer view.
     
    191191                } elseif ( $view == 'plugin-contributor' ) {
    192192
    193                         $slugs = self::get_plugin_slugs_by_contributor( $this->user );
     193                        $slugs = self::get_plugin_slugs_by_contributor( $this->user->user_nicename );
    194194
    195195                        // Add plugin-contributor view.
     
    453453        }
    454454
    455         public static function get_plugin_slugs_by_committer( $user_login ) {
     455        public static function get_plugin_slugs_by_committer( $user_nicename ) {
    456456                global $wpdb;
    457                 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `path` FROM `" . PLUGINS_TABLE_PREFIX . "svn_access` WHERE `user` = %s AND `access` = 'rw'", $user_login ) );
    458                 return self::clean_slugs( $slugs );
    459         }
    460 
    461         public static function get_plugin_slugs_by_contributor( $user ) {
     457
     458                $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
     459                $slugs = $wpdb->get_col( $wpdb->prepare(
     460                        "SELECT post_name
     461                         FROM {$prefix}posts AS p
     462                         LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id
     463                         LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
     464                         LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id
     465                         WHERE tt.taxonomy = 'plugin_committers' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s
     466                         ORDER BY p.post_title ASC",
     467                        $user_nicename
     468                ) );
     469
     470                return $slugs;
     471        }
     472
     473        public static function get_plugin_slugs_by_contributor( $user_nicename ) {
    462474                global $wpdb;
    463                 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_poster` = %d AND topic_open = 1 AND topic_status = 0", $user->ID ) );
    464                 $slugs = self::clean_slugs( $slugs );
    465                 if ( $contributor = $wpdb->get_col( $wpdb->prepare( "SELECT `object_id` FROM `" . PLUGINS_TABLE_PREFIX . "meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'contributors' AND `meta_value` LIKE %s", '%"' . str_replace( array( '%', '_' ), array( '\\%', '\\_' ), $user->user_login ) . '"%' ) ) ) {
    466                         if ( $contributor_slugs = $wpdb->get_col( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_id` IN (" . join( ',', $contributor ) . ") AND topic_open = 1 AND topic_status = 0" ) ) {
    467                                 $slugs = array_unique( array_merge( $slugs, $contributor_slugs ) );
    468                         }
    469                 }
     475
     476                $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
     477                $slugs = $wpdb->get_col( $wpdb->prepare(
     478                        "SELECT post_name
     479                         FROM {$prefix}posts AS p
     480                         LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id
     481                         LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
     482                         LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id
     483                         WHERE tt.taxonomy = 'plugin_contributors' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s
     484                         ORDER BY p.post_title ASC",
     485                        $user_nicename
     486                ) );
     487
    470488                return $slugs;
    471489        }
Note: See TracChangeset for help on using the changeset viewer.