WordPress.org

Make WordPress Core

Ticket #26937: 26937.12.patch

File 26937.12.patch, 1.2 KB (added by ethitter, 4 years ago)
  • src/wp-includes/link-template.php

     
    14361436                        $clauses      = array_merge( $clauses, $sort_clauses );
    14371437                }
    14381438
     1439                /**
     1440                 * Posts table was aliased as `p` for backwards compatibility during legacy filter application.
     1441                 * As `WP_Query` expects the posts table to be referenced as the value stored in `$wpdb->posts`, we must remove the aliasing.
     1442                 */
     1443                $clauses['join'] = str_replace( 'AS p ', '', $clauses['join'] );
     1444                $clauses = array_map( array( $this, 'restore_posts_table' ), $clauses );
     1445
    14391446                return $clauses;
    14401447        }
    14411448
     
    14531460        }
    14541461
    14551462        /**
     1463         * Restore posts table to the value from `$wpdb`, as expected by `WP_Query`
     1464         *
     1465         * @global $wpdb
     1466         * @param string  Clause to unalias
     1467         * @return string
     1468         */
     1469        protected function restore_posts_table( $clause ) {
     1470                global $wpdb;
     1471
     1472                return preg_replace( '#\bp\b#', "{$wpdb->posts}", $clause );
     1473        }
     1474
     1475        /**
    14561476         * Apply the deprecated `join` clause filter to the clause built by WP_Query.
    14571477         *
    14581478         * @param string $join