Making WordPress.org


Ignore:
Timestamp:
04/07/2017 09:16:09 PM (6 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-directory-compat.php

    r5162 r5286  
    816816                $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'repopackage' LIMIT 1", WPORG_THEME_DIRECTORY_BLOGID, $slug ) );
    817817            } elseif ( $type == 'plugin' ) {
    818                 // @todo Update this when the Plugin Directory switches over to WordPress.
    819                 $_compat_topic = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . PLUGINS_TABLE_PREFIX . "topics WHERE topic_slug = %s", $slug ) );
    820                 if ( $_compat_topic ) {
    821                     $_compat_post  = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . PLUGINS_TABLE_PREFIX . "posts WHERE topic_id = %d AND post_position = 1 LIMIT 1", $_compat_topic->topic_id ) );
    822                 }
    823                 if ( $_compat_topic && $_compat_post ) {
    824                     $compat_object = (object) array(
    825                         'post_title'   => $_compat_topic->topic_title,
    826                         'post_name'    => $slug,
    827                         'post_author'  => $_compat_topic->topic_poster,
    828                         'post_content' => $_compat_post->post_text,
    829                     );
    830                 }
     818                $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'plugin' LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $slug ) );
    831819            }
    832820
     
    854842                $authors = array( $author->user_login );
    855843            } else {
    856                 $authors = $wpdb->get_col( $wpdb->prepare( " SELECT user FROM " . PLUGINS_TABLE_PREFIX . "svn_access WHERE `path` = %s", '/' . $slug ) );
     844                $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
     845                // Note: Intentionally not considering posts of 'plugin' post_type with
     846                // 'post_author' matching this author because the field only relates to
     847                // the user who submitted the plugin. It does not confer special access,
     848                // rights, or ownership.
     849                $authors = $wpdb->get_col( $wpdb->prepare(
     850                    "SELECT slug
     851                     FROM {$prefix}terms AS t
     852                     LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
     853                     LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
     854                     WHERE tt.taxonomy = 'plugin_committers' AND tr.object_id = %d",
     855                     $this->plugin->ID
     856                ) );
    857857            }
    858858
     
    880880        $contributors = wp_cache_get( $cache_key, $cache_group );
    881881        if ( false === $contributors ) {
    882             // @todo Update this when the Plugin Directory switches over to WordPress.
    883             $contributors = $wpdb->get_var( $wpdb->prepare(
    884                 "SELECT meta_value FROM " . PLUGINS_TABLE_PREFIX . "meta m LEFT JOIN " . PLUGINS_TABLE_PREFIX . "topics t ON m.object_id = t.topic_id WHERE t.topic_slug = %s AND m.object_type = %s AND m.meta_key = %s",
    885                 $slug, 'bb_topic', 'contributors' ) );
    886             if ( $contributors ) {
    887                 $contributors = unserialize( $contributors );
    888             }
     882            $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
     883            $contributors = $wpdb->get_col( $wpdb->prepare(
     884                "SELECT slug
     885                 FROM {$prefix}terms AS t
     886                 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
     887                 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
     888                 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d",
     889                 $this->plugin->ID
     890            ) );
    889891
    890892            wp_cache_set( $cache_key, $contributors, $cache_group, HOUR_IN_SECONDS );
Note: See TracChangeset for help on using the changeset viewer.