From 6ce75b17811b6f7ac528977ba978e9bb8c312f00 Mon Sep 17 00:00:00 2001
From: Ian Longden <ianl@sanger.ac.uk>
Date: Wed, 28 Sep 2005 15:04:01 +0000
Subject: [PATCH] version_check changed to only check when adaptors are
 instantiated or not at all if special file exists

---
 modules/Bio/EnsEMBL/Registry.pm             | 40 +++++++++++++++++++++
 modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm | 35 ------------------
 2 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm
index fbf357a93f..faca667779 100644
--- a/modules/Bio/EnsEMBL/Registry.pm
+++ b/modules/Bio/EnsEMBL/Registry.pm
@@ -108,6 +108,8 @@ use DBI;
 
 use vars qw(%registry_register);
 
+my $API_VERSION = 34;
+
 
 =head2 load_all
 
@@ -580,6 +582,10 @@ sub get_adaptor{
       warning("$module cannot be found.\nException $@\n");
       return undef;
     }
+    if(!defined($registry_register{$species}{lc($group)}{'CHECKED'})){
+      $registry_register{$species}{lc($group)}{'CHECKED'} = 1;
+      $class->version_check($dba);
+    }
     my $adap = "$module"->new($dba);
     Bio::EnsEMBL::Registry->add_adaptor($species, $group, $type, $adap, "reset");
     $ret = $adap;
@@ -1103,5 +1109,39 @@ sub add_new_tracks{
 
 }
 
+sub software_version{
+  return $API_VERSION;
+}
+
+sub version_check{
+  my ($self, $dba) = @_;
+
+  # Check the datbase and versions match
+  # give warning if they do not.
+  if(-e $ENV{HOME}."/.ensemblapi_no_version_check"){
+    return;
+  }
+  my $mca = $self->get_adaptor($dba->species(),$dba->group(),"MetaContainer");
+  my $database_version = 0;
+  if(defined($mca)){
+    $database_version = $mca->get_schema_version();
+  }
+  if($database_version == 0){
+    #try to work out the version
+    if($dba->dbc->dbname() =~ /^_test_db_/){
+      return;
+    }
+    if($dba->dbc->dbname() =~ /\S+_\S+_\S+_(\d+)_\S+/){
+      $database_version = $1;
+    }
+    else{
+      warn("No database version for database ".$dba->dbc->dbname().". You must be using as pre version 34 database with version 34 or later code. You need to update your database or use the appropriate ensembl software release to ensure your script does not crash\n");
+    }
+  }
+  if($database_version != $API_VERSION){
+    warn("For ".$dba->dbc->dbname()." there is a difference in the software release (".$API_VERSION.") and the database release (".$database_version."). You should change one of these to ensure your script does not crash.\n");
+  }
+}
+
 
 1;
diff --git a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm
index c869fcd25a..5189fefe28 100644
--- a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm
+++ b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm
@@ -45,8 +45,6 @@ use Bio::EnsEMBL::DBSQL::DBAdaptor;
 
 use Bio::EnsEMBL::Utils::Exception qw(warning throw  deprecate stack_trace_dump);
 
-my $SOFTWARE_VERSION = 34;
-
 =head2 load_core, load_estgene, load_vega, load_compara, load_pipeline, load_SNP, load_lite
   Arg [1]    : DBAdaptor with DBConnection alredy attached
   Returntype : DBAdaptor;
@@ -60,10 +58,6 @@ my $SOFTWARE_VERSION = 34;
 # 3) 
 #
 
-sub software_version{
-  return $SOFTWARE_VERSION;
-}
-
 
 sub gen_load{
   my ($dba) = @_;
@@ -246,40 +240,11 @@ sub load_and_attach_dnadb_to_core{
   $reg->add_DNAAdaptor($dba->species,$dba->group,$dba->species,"core"); 
 }
 
-# those that do not need to attach to core:-#
-
-sub check_version{
-  my ($dba) = @_;
-
-  # Check the datbase and versions match
-  # give warning if they do not.
-  my $mca = $reg->get_adaptor($dba->species(),$dba->group(),"MetaContainer");
-  my $database_version = 0;
-  if(defined($mca)){
-    $database_version = $mca->get_schema_version();
-  }
-  if($database_version == 0){
-    #try to work out the version
-    if($dba->dbc->dbname() =~ /^_test_db_/){
-      return;
-    }
-    if($dba->dbc->dbname() =~ /\S+_\S+_\S+_(\d+)_\S+/){
-      $database_version = $1;
-    }
-    else{
-      warn("No database version for database ".$dba->dbc->dbname().". You must be using as pre version 34 database with version 34 or later code. You need to update your database or use the appropriate ensembl software release to ensure your script does not crash\n");
-    }
-  }
-  if($database_version != $SOFTWARE_VERSION){
-    warn("For ".$dba->dbc->dbname()." there is a difference in the software release (".$SOFTWARE_VERSION.") and the database release (".$database_version."). You should change one of these to ensure your script does not crash.\n");
-  }
-}
 
 sub load_core{
   my ($dba) = @_;
 
   load_adaptors($dba);
-  check_version($dba);
 }
 
 sub load_compara{
-- 
GitLab