WordPress.org

Make WordPress Core

Ticket #15332: 15332.patch

File 15332.patch, 2.0 KB (added by mordauk, 6 years ago)
  • src/wp-admin/includes/upgrade.php

     
    20412041
    20422042        $cqueries = array(); // Creation Queries
    20432043        $iqueries = array(); // Insertion Queries
     2044        $vqueries = array(); // View Queries
    20442045        $for_update = array();
    20452046
    20462047        // Create a tablename index for an array ($cqueries) of queries
     
    20542055                        $iqueries[] = $qry;
    20552056                } elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
    20562057                        $iqueries[] = $qry;
     2058                } elseif ( preg_match( "|CREATE VIEW ([^ ]*)|", $qry, $matches ) ) {
     2059                        $vqueries[] = $qry;
     2060                } elseif ( preg_match( "|CREATE ALGORITHM([^ ]*)|", $qry, $matches ) ) {
     2061                        $vqueries[] = $qry;
     2062                } elseif ( preg_match( "|CREATE OR REPLACE VIEW ([^ ]*)|", $qry, $matches ) ) {
     2063                        $vqueries[] = $qry;
     2064                } elseif ( preg_match( "|CREATE OR REPLACE ALGORITHM([^ ]*)|", $qry, $matches ) ) {
     2065                        $vqueries[] = $qry;
    20572066                } else {
    20582067                        // Unrecognized query type
    20592068                }
     
    20812090         */
    20822091        $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
    20832092
     2093        /**
     2094         * Filter the dbDelta SQL queries for creating or replacing views.
     2095         *
     2096         * Queries filterable via this hook contain "CREATE VIEW" or "CREATE OR REPLACE VIEW".
     2097         *
     2098         * @since x.x.x
     2099         *
     2100         * @param array $iqueries An array of dbDelta insert or update SQL queries.
     2101         */
     2102        $vqueries = apply_filters( 'dbdelta_iview_queries', $vqueries );
     2103
    20842104        $global_tables = $wpdb->tables( 'global' );
    20852105        foreach ( $cqueries as $table => $qry ) {
    20862106                // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
     
    22572277                unset( $cqueries[ $table ], $for_update[ $table ] );
    22582278        }
    22592279
    2260         $allqueries = array_merge($cqueries, $iqueries);
     2280        foreach( $vqueries as $table => $query ) {
     2281                $for_update[] = $query;
     2282        }
     2283
     2284        $allqueries = array_merge($cqueries, $iqueries, $vqueries);
    22612285        if ($execute) {
    22622286                foreach ($allqueries as $query) {
    22632287                        // todo: Remove this?