The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MonLabo
Summary Activity Tracker Tasks Docs SCM Files Dokuwiki Continious Integration Listes Sympa

SCM Repository

authorHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Fri, 2 Oct 2020 17:41:04 +0000 (19:41 +0200)
committerHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Fri, 2 Oct 2020 17:41:04 +0000 (19:41 +0200)
includes/MonLabo-db.php

index ecf5f27..6ff5ba7 100644 (file)
@@ -327,31 +327,23 @@ class MonLabo_db {
        }
 
        public function migrate() {
-
-               global $wpdb;
-               $sql = $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'MonLabo_settings_group0' );
-
-               $row = $wpdb->get_row( $sql );
-               if ( !empty( $row ) ) {
-                       $options0 = unserialize( $row->option_value );
-                       if  (
-                                       ( !isset( $options0 ) )
-                                       or ( !isset( $options0['MonLabo_activated_version'] ) )
-                               ) {
-                               //Enter here only if MonLabo_activated_version does not exist
-                               $plugin_version = 0.0;
-                       } else {
-                               $plugin_version = floatval( $options0['MonLabo_activated_version'] );
-                       }
-                       if ( ( $plugin_version < 3.1 ) ) {
-                               $this->migrate_to_version_3_1();
-                       }
-
-                       //Mise à jour de la version activée
-                       $options0['MonLabo_activated_version'] = get_version();
-                       update_option( 'MonLabo_settings_group0', $options0 );
-                       return $this;
+               $options0 = get_option( 'MonLabo_settings_group0' );
+               if  (
+                               ( !isset( $options0 ) )
+                               or ( !isset( $options0['MonLabo_activated_version'] ) )
+                       ) {
+                       //Enter here only if MonLabo_activated_version does not exist
+                       $plugin_version = 0.0;
+               } else {
+                       $plugin_version = floatval( $options0['MonLabo_activated_version'] );
+               }
+               if ( ( $plugin_version < 3.1 ) ) {
+                       $this->migrate_to_version_3_1();
+                       $options0 = get_option( 'MonLabo_settings_group0' );
                }
+               $options0['MonLabo_activated_version'] = get_version();
+               update_option( 'MonLabo_settings_group0', $options0 );
+               return $this;
        }
 
        public function migrate_to_version_3_1() {