Changeset 131

Show
Ignore:
Timestamp:
12/19/07 18:51:31 (1 year ago)
Author:
pdingle
Message:

added upgrade case where db is at v3 but not all options are present

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/RB-0.9/wp-infocard/wp/admin.pw.php

    r130 r131  
    595595                if (pw_admin::getOption('pw_infocard_key')) 
    596596                { 
    597                         $output .= pw_db_upgrade::upgradeDBv2ToDBv3(); 
     597                        global $wpdb; 
     598                        // we are at least DBv2, maybe DBv3 
     599                        $query = "describe wp_infocard_identities"; 
     600                        $identity_info = $wpdb->get_results( $query, OBJECT );   
     601 
     602                        $cardhash_present = FALSE; 
     603                        foreach (array_values($identity_info) as $x) 
     604                                if ($x->Field == 'cardhash') 
     605                                        $cardhash_present = TRUE; 
     606                                 
     607                        if ($cardhash_present) 
     608                        { 
     609                                // DB is already v3, just fix options 
     610                                $output .= "<p>Version DBv3 detected</p>"; 
     611                                pw_admin::setOption('pw_db_version', 'DB v3'); 
     612                        } 
     613                        else 
     614                        { 
     615                                // DB is v2,  must upgrade 
     616                                $output .= "<p>Version DBv2 detected</p>"; 
     617                                $output .= pw_db_upgrade::upgradeDBv2ToDBv3(); 
     618                        } 
     619 
    598620                        return $output . "</p>";                 
    599621                } 
     
    601623                if (pw_admin::getOption('infocard_key')) 
    602624                { 
    603                         $output .= pw_db_upgrade::upgradeDBv1ToDBv3(); 
     625                        $output .= "<p>Version DBv1 detected</p>"; 
     626                        //$output .= pw_db_upgrade::upgradeDBv1ToDBv3(); 
    604627                        return $output . "</p>"; 
    605628                }