From 9fff30416ac4cb66049adbe2ef4fe95057d8b1e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Jul 2014 20:12:21 +0200 Subject: [PATCH] Qual: Remove usage of getStaticMember function dir constants. --- htdocs/admin/system/database.php | 2 +- htdocs/admin/system/index.php | 2 +- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/dolibarr_import.php | 2 +- htdocs/admin/tools/export.php | 2 +- htdocs/core/db/DoliDB.class.php | 4 ---- htdocs/core/db/mssql.class.php | 4 ++-- htdocs/core/db/mysql.class.php | 4 ++-- htdocs/core/db/mysqli.class.php | 4 ++-- htdocs/core/db/pgsql.class.php | 4 ++-- htdocs/core/db/sqlite.class.php | 4 ++-- htdocs/install/etape1.php | 2 -- htdocs/install/fileconf.php | 6 +++--- htdocs/install/upgrade.php | 2 +- 14 files changed, 19 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index d9833a13d0115..d7f39530502dd 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -44,7 +44,7 @@ // Database print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index a9d6cfa1afb39..71ce99d55250f 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -86,7 +86,7 @@ // Database print '
'.$langs->trans("Database").'
'.$langs->trans("Version").''.getStaticMember(get_class($db),'label').' '.$db->getVersion().'
'.$langs->trans("Version").''.$db::label.' '.$db->getVersion().'
'.$langs->trans("DatabaseServer").''.$conf->db->host.'
'.$langs->trans("DatabasePort").''.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'
'.$langs->trans("DatabaseName").''.$conf->db->name.'
'; print "\n"; -$dblabel=getStaticMember(get_class($db),'label'); +$dblabel=$db::label; $dbversion=$db->getVersion(); print "\n"; print '
".$langs->trans("Database")."
".$langs->trans("Version")."" .$dblabel." ".$dbversion."
'; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 8154cfffb0803..9f4e62155c25b 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -65,7 +65,7 @@ $form=new Form($db); $formfile = new FormFile($db); -$label=getStaticMember($db, 'label'); +$label=$db::label; $help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; llxHeader('','',$help_url); diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 61e7e1e68a14f..b18aefc75a544 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -38,7 +38,7 @@ * View */ -$label=getStaticMember($db, 'label'); +$label=$db::label; $help_url='EN:Restores|FR:Restaurations|ES:Restauraciones'; llxHeader('','',$help_url); diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 8dccf89de096e..ca12f3fbc380d 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -416,7 +416,7 @@ function backup_tables($outputfile, $tables='*') // Print headers and global mysql config vars $sqlhead = ''; - $sqlhead .= "-- ".getStaticMember($db, 'label')." dump via php + $sqlhead .= "-- ".$db::label." dump via php -- -- Host: ".$db->db->host_info." Database: ".$db->database_name." -- ------------------------------------------------------ diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index aa0792c5970ad..e0921f7acac98 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -32,14 +32,10 @@ abstract class DoliDB implements Database public $db; //! Database type public $type; - //! Database label - static $label; //! Charset used to force charset when creating database public $forcecharset='utf8'; //! Collate used to force collate when creating database public $forcecollate='utf8_general_ci'; - //! Min database version - static $versionmin; //! Resultset of last query private $_results; //! 1 if connected, else 0 diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 39b9afdb75bad..820706cd6f1fd 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -33,13 +33,13 @@ class DoliDBMssql extends DoliDB //! Database type public $type='mssql'; //! Database label - static $label='MSSQL'; + const label='MSSQL'; //! Charset used to force charset when creating database var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value //! Version min database - static $versionmin=array(2000); + const versionmin='2000'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 8f852aba3ec9e..ac1a6d0e2f62e 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -34,9 +34,9 @@ class DoliDBMysql extends DoliDB //! Database type public $type='mysql'; //! Database label - static $label='MySQL'; + const label='MySQL'; //! Version min database - static $versionmin=array(4,1,0); + const versionmin='4.1.0'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index d44e37b7591f8..e86490ac88c57 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -34,9 +34,9 @@ class DoliDBMysqli extends DoliDB //! Database type public $type='mysqli'; //! Database label - static $label='MySQL'; + const label='MySQL'; //! Version min database - static $versionmin=array(4,1,0); + const versionmin='4.1.0'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 61de279e24c29..9110d7cea06dd 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -37,13 +37,13 @@ class DoliDBPgsql extends DoliDB //! Database type public $type='pgsql'; // Name of manager //! Database label - static $label='PostgreSQL'; // Label of manager + const label='PostgreSQL'; // Label of manager //! Charset var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database var $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database - static $versionmin=array(8,4,0); // Version min database + const versionmin='8.4.0'; // Version min database //! Resultset of last query private $_results; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 924f489fc4d3a..fbae9300dddcc 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -34,9 +34,9 @@ class DoliDBSqlite extends DoliDB //! Database type public $type='sqlite'; //! Database label - static $label='PDO Sqlite'; + const label='PDO Sqlite'; //! Version min database - static $versionmin=array(3,0,0); + const versionmin='3.0.0'; //! Resultset of last query private $_results; diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 43d063bf2701f..831283c6a4679 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -256,8 +256,6 @@ { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); $defaultCharacterSet=$db->forcecharset; $defaultDBSortingCollation=$db->forcecollate; } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 665d766a8ddc8..7e681e1b21b66 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -307,10 +307,10 @@ include_once $dir."/".$file; if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation - + // Version min of database - $versionbasemin=getStaticMember($class, 'versionmin'); - $note='('.getStaticMember($class, 'label').' >= '.versiontostring($versionbasemin).')'; + $versionbasemin=explode('.',$class::versionmin); + $note='('.$class::label.' >= '.$class::versionmin.')'; // Switch to mysql if mysqli is not present if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 875f5974dd75d..f88047e50176d 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -168,7 +168,7 @@ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version"); // Test database version - $versionmindb=getStaticMember(get_class($db),'versionmin'); + $versionmindb=$db::versionmin; //print join('.',$versionarray).' - '.join('.',$versionmindb); if (count($versionmindb) && count($versionarray) && versioncompare($versionarray,$versionmindb) < 0)