suppress_errors example

if ( null !== $pre ) {
        return (bool) $pre;
    }

    $switch = false;
    if ( get_current_blog_id() !== $site_id ) {
        $switch = true;
        remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
        switch_to_blog( $site_id );
    }

    $suppress = $wpdb->suppress_errors();
    $result   = (bool) $wpdb->get_results( "DESCRIBE {$wpdb->posts});
    $wpdb->suppress_errors( $suppress );

    if ( $switch ) {
        restore_current_blog();
        add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
    }

    return $result;
}

function is_blog_installed() {
    global $wpdb;

    /* * Check cache first. If options table goes away and we have true * cached, oh well. */
    if ( wp_cache_get( 'is_blog_installed' ) ) {
        return true;
    }

    $suppress = $wpdb->suppress_errors();
    if ( ! wp_installing() ) {
        $alloptions = wp_load_alloptions();
    }
    // If siteurl is not set to autoload, check it specifically.     if ( ! isset( $alloptions['siteurl'] ) ) {
        $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
    } else {
        $installed = $alloptions['siteurl'];
    }
    $wpdb->suppress_errors( $suppress );

    

function install_blog( $blog_id$blog_title = '' ) {
    global $wpdb$wp_roles;

    _deprecated_function( __FUNCTION__, '5.1.0' );

    // Cast for security.     $blog_id = (int) $blog_id;

    require_once ABSPATH . 'wp-admin/includes/upgrade.php';

    $suppress = $wpdb->suppress_errors();
    if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}) ) {
        die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
    }
    $wpdb->suppress_errors( $suppress );

    $url = get_blogaddress_by_id( $blog_id );

    // Set everything up.     make_db_current_silent( 'blog' );
    populate_options();
    populate_roles();

    
$db_version     = $wpdb->db_version();
    $db_server_info = $wpdb->db_server_info();

    foreach ( $cqueries as $table => $qry ) {
        // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.         if ( in_array( $table$global_tables, true ) && ! wp_should_upgrade_global_tables() ) {
            unset( $cqueries[ $table ]$for_update[ $table ] );
            continue;
        }

        // Fetch the table column structure from the database.         $suppress    = $wpdb->suppress_errors();
        $tablefields = $wpdb->get_results( "DESCRIBE {$table};" );
        $wpdb->suppress_errors( $suppress );

        if ( ! $tablefields ) {
            continue;
        }

        // Clear the field and index arrays.         $cfields                  = array();
        $indices                  = array();
        $indices_without_subparts = array();

        
/* * The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must * fire this manually. We'll fail here if the values are no good. */
        $wpdb->db_connect();

        if ( ! empty( $wpdb->error ) ) {
            wp_die( $wpdb->error->get_error_message() . $tryagain_link );
        }

        $errors = $wpdb->suppress_errors();
        $wpdb->query( "SELECT $prefix);
        $wpdb->suppress_errors( $errors );

        if ( ! $wpdb->last_error ) {
            // MySQL was able to parse the prefix as a value, which we don't want. Bail.             wp_die( __( '<strong>Error:</strong> "Table Prefix" is invalid.' ) );
        }

        // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password().         try {
            $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
            


                    $notoptions[ $option ] = true;
                    wp_cache_set( 'notoptions', $notoptions, 'options' );

                    /** This filter is documented in wp-includes/option.php */
                    return apply_filters( "default_option_{$option}", $default_value$option$passed_default );
                }
            }
        }
    } else {
        $suppress = $wpdb->suppress_errors();
        $row      = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
        $wpdb->suppress_errors( $suppress );

        if ( is_object( $row ) ) {
            $value = $row->option_value;
        } else {
            /** This filter is documented in wp-includes/option.php */
            return apply_filters( "default_option_{$option}", $default_value$option$passed_default );
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.