mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
exit code must be >= 0 (#35311)
This commit is contained in:
@@ -78,7 +78,7 @@ while ($i < $argc) {
|
||||
$tmp = explode(':', $result['includeconstant'], 3); // $includeconstant has been set with previous parse_str()
|
||||
if (count($tmp) != 3) {
|
||||
print "Error: Bad parameter includeconstant=".$result['includeconstant'] ."\n";
|
||||
exit -1;
|
||||
exit(1);
|
||||
}
|
||||
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ if (empty($argv[1])) {
|
||||
print "Usage: $script_file nbofrecord\n";
|
||||
print "Usage: $script_file 100\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('GEN_NUMBER_FACTURE', ((int) $argv[1]) ?? 1);
|
||||
|
||||
@@ -64,7 +64,7 @@ if (empty($argv[1])) {
|
||||
print "Usage: $script_file nbofrecord\n";
|
||||
print "Usage: $script_file 100\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('GEN_NUMBER_COMMANDE', ((int) $argv[1]) ?? 10);
|
||||
|
||||
@@ -62,7 +62,7 @@ if (empty($argv[1])) {
|
||||
print "Usage: $script_file nbofrecord\n";
|
||||
print "Usage: $script_file 100\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('GEN_NUMBER_PRODUIT', ((int) $argv[1]) ?? 100);
|
||||
|
||||
@@ -60,7 +60,7 @@ if (empty($argv[1])) {
|
||||
print "Usage: $script_file nbofrecord\n";
|
||||
print "Usage: $script_file 100\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('GEN_NUMBER_PROPAL', ((int) $argv[1]) ?? 10);
|
||||
|
||||
@@ -65,7 +65,7 @@ if (empty($argv[1])) {
|
||||
print "Usage: $script_file nbofrecord\n";
|
||||
print "Usage: $script_file 100\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('GEN_NUMBER_SOCIETE', ((int) $argv[1]) ?? 10);
|
||||
|
||||
@@ -71,12 +71,12 @@ if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) |
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ret = $user->fetch('', 'admin');
|
||||
|
||||
@@ -71,12 +71,12 @@ if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) |
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ret = $user->fetch('', 'admin');
|
||||
|
||||
@@ -71,12 +71,12 @@ if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) |
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
|
||||
@@ -32,7 +32,7 @@ $path=__DIR__.'/';
|
||||
// Test si mode batch
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@@ -187,13 +187,13 @@ if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option can be ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (empty($option)) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option must be defined with a value in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if ($option != 'all') {
|
||||
$listofoptions=explode(',', $option);
|
||||
@@ -202,7 +202,7 @@ if ($option != 'all') {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date !=
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($date == 'all') {
|
||||
|
||||
@@ -84,7 +84,7 @@ if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile
|
||||
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
|
||||
print "Return code: 0 if success, <>0 if error\n";
|
||||
print "Warning, this script may take a long time.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ $connection = ssh2_connect($server, 22);
|
||||
if ($connection) {
|
||||
if (!@ssh2_auth_password($connection, $login, $password)) {
|
||||
dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
|
||||
exit(-5);
|
||||
exit(5);
|
||||
} else {
|
||||
//$stream = ssh2_exec($connection, '/usr/bin/php -i');
|
||||
/*
|
||||
@@ -143,7 +143,7 @@ if ($connection) {
|
||||
}
|
||||
} else {
|
||||
print 'Failed to connect to ssh2 to '.$server;
|
||||
exit(-6);
|
||||
exit(6);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ print "Update dates to current year for database name = ".$db->database_name."\n
|
||||
if (empty($confirm)) {
|
||||
print "Usage: $script_file confirm\n";
|
||||
print "Return code: 0 if success, <>0 if error\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -106,11 +106,11 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
|
||||
|
||||
if (empty($user) || empty($user->id)) {
|
||||
print 'Page is called as an include but $user and its permission loaded with loadRights() are not defined. We stop here.';
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (empty($object)) {
|
||||
print 'Page is called as an include but $object is not defined. We stop here.';
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ if ($id > 0 && empty($object->id)) {
|
||||
$res = $object->fetch($id);
|
||||
if ($object->id <= 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ if ($rss) {
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorFailToCreateFile", $outputfile);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ if ($rss) {
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorFailToCreateFile", $outputfile);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ if ($rss) {
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorFailToCreateFile", $outputfile);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ if ($rss) {
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorFailToCreateFile", $outputfile);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,14 +170,14 @@ if ($rss) {
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorFailToCreateFile", $outputfile);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ function detectModule()
|
||||
$tab = glob("core/modules/mod*.class.php");
|
||||
if (count($tab) == 0) {
|
||||
echo "[fail] Error on auto detect data : there is no mod*.class.php file into core/modules dir\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (count($tab) == 1) {
|
||||
$file = $tab[0];
|
||||
@@ -87,11 +87,11 @@ function detectModule()
|
||||
echo "extract data from $file\n";
|
||||
if (!file_exists($file) || $name == "") {
|
||||
echo "[fail] Error on auto detect data\n";
|
||||
exit(-2);
|
||||
exit(2);
|
||||
}
|
||||
} else {
|
||||
echo "[fail] Error there is more than one mod*.class.php file into core/modules dir\n";
|
||||
exit(-3);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
//extract version from file
|
||||
@@ -105,7 +105,7 @@ function detectModule()
|
||||
|
||||
if (version_compare($version, '0.0.1', '>=') != 1) {
|
||||
echo "[fail] Error auto extract version fail\n";
|
||||
exit(-4);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
echo "module name = $name, version = $version\n";
|
||||
@@ -145,11 +145,11 @@ function secureUnlink($path)
|
||||
clearstatcache();
|
||||
if (file_exists($path)) { // @phpstan-ignore-line
|
||||
echo "[fail] unlink of $path fail !\n";
|
||||
exit(-5);
|
||||
exit(5);
|
||||
}
|
||||
} else {
|
||||
echo "[fail] unlink of $path fail !\n";
|
||||
exit(-6);
|
||||
exit(6);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -298,7 +298,7 @@ foreach ($listOfModuleContent as $moduleContent) {
|
||||
if (!rcopy($entry, $dst . '/' . $entry)) {
|
||||
echo "[fail] Error on copy " . $entry . " to " . $dst . "/" . $entry . "\n";
|
||||
echo "Please take time to analyze the problem and fix the bug\n";
|
||||
exit(-8);
|
||||
exit(8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,5 +312,5 @@ if (file_exists($outzip)) {
|
||||
echo "[success] module archive is ready : $outzip ...\n";
|
||||
} else {
|
||||
echo "[fail] build zip error\n";
|
||||
exit(-9);
|
||||
exit(9);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ $path = __DIR__.'/';
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@@ -95,7 +95,7 @@ if (!$res && file_exists("../../../master.inc.php")) {
|
||||
}
|
||||
if (!$res) {
|
||||
print "Include of master fails";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file).
|
||||
// $user is created but empty.
|
||||
@@ -129,7 +129,7 @@ $hookmanager->initHooks(array('cli'));
|
||||
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
||||
if (!isset($argv[1])) { // Check parameters
|
||||
print "Usage: ".$script_file." param1 param2 ...\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
print '--- start'."\n";
|
||||
print 'Argument 1='.$argv[1]."\n";
|
||||
|
||||
@@ -61,7 +61,7 @@ if (is_numeric($entity)) {
|
||||
// Error if CLI mode
|
||||
if (php_sapi_name() == "cli") {
|
||||
echo "Error: This page can't be used as a CLI script. For the CLI version of script, launch cron_run_job.php available into scripts/cron/ directory.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// core library
|
||||
@@ -179,12 +179,12 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
|
||||
if ($result < 0) {
|
||||
echo "\nUser Error: ".$user->error."\n";
|
||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
echo "\nUser login: ".$userlogin." does not exists for entity ".$conf->entity."\n";
|
||||
dol_syslog("User login:".$userlogin." does not exists", LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$user->loadRights();
|
||||
|
||||
@@ -952,7 +952,7 @@ if ($socid > 0 && empty($object->id)) {
|
||||
$result = $object->fetch($socid);
|
||||
if ($result <= 0) {
|
||||
dol_print_error(null, $object->error);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ if (!getDolGlobalString('LDAP_MEMBER_DN')) {
|
||||
}
|
||||
if ($typeid <= 0) {
|
||||
print $langs->trans("Error").': Parameter id_member_type is not a valid ref of an existing member type'."\n";
|
||||
exit(-2);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ class AccountingAccountTest extends CommonClassTest
|
||||
|
||||
if (!isModEnabled('accounting')) {
|
||||
print __METHOD__." module accounting must be enabled.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print __METHOD__."\n";
|
||||
|
||||
Reference in New Issue
Block a user