2
0
forked from Wavyzz/dolibarr

Merge branch '9.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	.travis.yml
	dev/setup/codesniffer/ruleset.xml
This commit is contained in:
Laurent Destailleur
2019-01-20 20:36:45 +01:00
11 changed files with 70 additions and 51 deletions

View File

@@ -60,6 +60,7 @@ matrix:
fast_finish: true
allow_failures:
- php: nightly
- php: '7.3'
# We exclude some combinations not usefull to save Travis CPU
exclude:
- php: '5.5'
@@ -78,7 +79,7 @@ matrix:
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- php: '7.2'
- php: '7.3'
env: DB=postgresql
- php: nightly
env: DB=postgresql
@@ -133,7 +134,7 @@ install:
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then
composer -n require phpunit/phpunit ^5
fi
if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require phpunit/phpunit ^5
fi
echo
@@ -168,13 +169,9 @@ before_script:
echo "Set timezone"
echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then
#echo
#echo "Enabling APC for PHP <= 5.4"
# Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6!
#echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly!
echo
echo "Enabling Memcached for PHP <= 5.4"
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly!
echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
fi
phpenv rehash
@@ -215,6 +212,7 @@ before_script:
fi
if [ "$DB" = 'postgresql' ]; then
#pgloader mysql://root:pass@127.0.0.1/dolibarr_35 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev
echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis
pgloader mysql://root@127.0.0.1/travis postgresql:///travis
fi
# TODO: SQLite
@@ -232,9 +230,11 @@ before_script:
echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then
echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_port=\'3306\'';' >> $CONF_FILE
fi
if [ "$DB" = 'postgresql' ]; then
echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE
echo '$'dolibarr_main_db_port=\'5432\'';' >> $CONF_FILE
fi
# TODO: SQLite
echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
@@ -256,7 +256,7 @@ before_script:
# enable php-fpm
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- |
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
# Copy the included pool
sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
fi
@@ -279,11 +279,12 @@ before_script:
script:
- |
echo "Checking webserver availability by a wget -O - http://127.0.0.1"
# Ensure we catch errors
set -e
# Ensure we stop on error with set -e
set +e
# The wget should return a page with line '<meta name="generator" content="Dolibarr installer">
wget -O - http://127.0.0.1 > test.html
head test.html
sudo cat /var/log/apache2/travis_error_log
set +e
echo
@@ -312,7 +313,7 @@ script:
- |
echo "Upgrading Dolibarr"
# Ensure we catch errors
# Ensure we catch errors. Set this to +e if you want to go to the end to see log files.
set +e
cd htdocs/install
php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log
@@ -328,7 +329,7 @@ script:
php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log
php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log
php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log
php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log
php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log
php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log
php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log
php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log
@@ -337,10 +338,10 @@ script:
php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log
php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log
php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log
php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log
php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log
php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log
php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log
php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log
php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log
php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log
php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log
php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log
@@ -348,10 +349,14 @@ script:
php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log
php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log
php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log
# Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log
echo $?
cd -
set +e
echo
#cat /tmp/dolibarr_install.log
cat $TRAVIS_BUILD_DIR/enablemodule.log
- |
echo "Unit testing"
@@ -375,7 +380,7 @@ after_success:
after_failure:
- |
echo Failure detected, so we show samples of log to help diagnose
# This part of code is executed only if previous commande that fails are enclosed with set +e
# This part of code is executed only if previous command that fails are enclosed with set +e
# Upgrade log files
for ficlog in `ls $TRAVIS_BUILD_DIR/*.log`
do
@@ -384,7 +389,7 @@ after_failure:
done
# Apache log file
echo "Debugging informations for file apache error.log"
sudo cat /var/log/apache2/error.log
sudo cat /var/log/apache2/travis_error_log
if [ "$DEBUG" = true ]; then
# Dolibarr log file
echo "Debugging informations for file dolibarr.log (latest 50 lines)"

View File

@@ -1,5 +1,6 @@
<VirtualHost *:80>
DocumentRoot %TRAVIS_BUILD_DIR%/htdocs
ErrorLog /var/log/apache2/travis_error_log
<Directory "%TRAVIS_BUILD_DIR%/htdocs/">
Options FollowSymLinks MultiViews ExecCGI

View File

@@ -53,6 +53,9 @@
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed">
<severity>0</severity>
</rule>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed">
<severity>0</severity>
</rule>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass">
<severity>0</severity>
</rule>

View File

@@ -165,7 +165,7 @@ class AccountingAccount extends CommonObject
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
$sql .= " WHERE";
if ($rowid) {
$sql .= " a.rowid = '" . $rowid . "'";
$sql .= " a.rowid = " . (int) $rowid;
} elseif ($account_number) {
$sql .= " a.account_number = '" . $this->db->escape($account_number) . "'";
}
@@ -212,7 +212,7 @@ class AccountingAccount extends CommonObject
/**
* Insert new accounting account in chart of accounts
*
* @param User $user Use making action
* @param User $user User making action
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
@@ -273,11 +273,11 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
$sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->db->escape($this->pcg_subtype) . "'");
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'");
$sql .= ", " . (empty($this->account_parent) ? '0' : "'" . $this->db->escape($this->account_parent) . "'");
$sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . (empty($this->account_category) ? 0 : $this->db->escape($this->account_category));
$sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent);
$sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id;
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
$sql .= ", " . (int) $this->active;
$sql .= ")";
$this->db->begin();
@@ -285,7 +285,7 @@ class AccountingAccount extends CommonObject
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$error++;
$this->errors[] = "Error " . $this->db->lasterror();
}
@@ -307,12 +307,12 @@ class AccountingAccount extends CommonObject
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
return -1 * $error;
} else {
$this->db->commit();
return $this->id;
@@ -344,11 +344,11 @@ class AccountingAccount extends CommonObject
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
$sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null");
$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
$sql .= " , account_parent = '" . $this->db->escape($this->account_parent) . "'";
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : $this->db->escape($this->account_category));
$sql .= " , account_parent = " . (int) $this->account_parent;
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''");
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . $this->active;
$sql .= " , active = " . (int) $this->active;
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
@@ -373,10 +373,10 @@ class AccountingAccount extends CommonObject
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
$sql .= "UNION";
$sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
$sql.= " WHERE fk_code_ventilation=" . $this->id . ")";
$sql.= "UNION";
$sql.= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql.= " WHERE fk_code_ventilation=" . $this->id . ")";
dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@@ -574,7 +574,7 @@ if (! function_exists('dol_getprefix'))
/**
* Return a prefix to use for this Dolibarr instance, for session/cookie names or email id.
* The prefix for session is unique in a web context only and is unique for instance and avoid conflict
* between multi-instances, even when having two instances with one root dir or two instances in virtual servers.
* between multi-instances, even when having two instances with same root dir or two instances in same virtual servers.
* The prefix for email is unique if MAIL_PREFIX_FOR_EMAIL_ID is set to a value, otherwise value may be same than other instance.
*
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
@@ -592,16 +592,16 @@ if (! function_exists('dol_getprefix'))
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"];
}
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
}
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"]))
{
return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
// Use this for a "readable" cookie name
return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
// Use this for a "readable" key
//return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
}
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
}
}

View File

@@ -139,7 +139,7 @@ class modDeplacement extends DolibarrModules
$childids = $user->getAllChildIds();
$childids[]=$user->id;
if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')';
if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $this->export_sql_end[$r] .=' AND d.fk_user IN ('.join(',',$childids).')';
}
}

View File

@@ -256,3 +256,5 @@ CREATE TABLE llx_pos_cash_fence(
import_key VARCHAR(14)
) ENGINE=innodb;
-- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN account_number varchar(32) NOT NULL;
-- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_number SET NOT NULL;

View File

@@ -843,7 +843,7 @@ class SupplierProposal extends CommonObject
*/
function create($user, $notrigger=0)
{
global $langs,$conf,$mysoc,$hookmanager;
global $langs, $conf, $mysoc, $hookmanager;
$error=0;
$now=dol_now();

View File

@@ -44,7 +44,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class AccountingAccountTest extends PHPUnit_Framework_TestCase
class AccountingAccountTest extends PHPUnit\Framework\TestCase
{
protected $savconf;
protected $savuser;
@@ -79,7 +79,7 @@ class AccountingAccountTest extends PHPUnit_Framework_TestCase
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; die(); }
if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; exit(-1); }
print __METHOD__."\n";
}
@@ -138,6 +138,7 @@ class AccountingAccountTest extends PHPUnit_Framework_TestCase
$localobject->account_category = 0;
$localobject->pcg_type = 'XXXXX';
$localobject->pcg_subtype = 'XXXXX';
$localobject->account_number = '411123456';
$localobject->account_parent = 0;
$localobject->label = 'Account specimen';
$localobject->active = 0;

View File

@@ -129,13 +129,13 @@ class ModulesTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark',
'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices',
'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
$modulelist=array('Accounting','Adherent','Agenda','Api','Asset','Banque','Barcode','BlockedLog','Bookmark',
'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','DataPolicy','Dav','Deplacement','DocumentGeneration','Don','DynamicPrices',
'ECM','EmailCollector','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan',
'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency',
'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource',
'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow');
'Salaries','Service','SocialNetworks','Societe','Stock','Stripe','SupplierProposal','Syslog','TakePos','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow');
foreach($modulelist as $modlabel)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';

View File

@@ -203,8 +203,8 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
/**
* testSupplierProposalValid
*
* @param Proposal $localobject Proposal
* @return Proposal
* @param SupplierProposal $localobject Proposal
* @return SupplierProposal
*
* @depends testSupplierProposalAddLine
* The depends says test is run only if previous is ok
@@ -217,7 +217,14 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$result = $user->addrights(0, 'supplier_proposal');
$this->assertLessThan($result, 0);
$result = $user->getrights('supplier_proposal', 1);
//$this->assertLessThan($result, 0);
$result=$localobject->valid($user);
$this->assertLessThan($result, 0);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
@@ -227,7 +234,7 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
/**
* testSupplierProposalOther
*
* @param Proposal $localobject Proposal
* @param SupplierProposal $localobject Proposal
* @return int
*
* @depends testSupplierProposalValid