Merge branch 'develop' into patch-11
This commit is contained in:
commit
caa5ed527f
33 changed files with 300 additions and 132 deletions
|
|
@ -23,7 +23,8 @@ The following changes may create regressions for some external modules, but were
|
|||
* Some API HTTP return code were moved from 401 to 403 to better follow REST specification.
|
||||
* dolibarrtriggers class VERSION_XXX constants have been deprecated. Please use array dictionary VERSIONS['XXX'].
|
||||
* Properties ->date_update and ->date_modification were merged into date_modification.
|
||||
|
||||
* All CLI tools (into /scripts) return a positive value to the shell if error (0 remains success) for a better
|
||||
cross platform compatibility. On linux the exit(-1) was caught as 255, it may be now exit(1) so will be caught as 1.
|
||||
|
||||
|
||||
***** ChangeLog for 19.0.1 compared to 19.0.0 *****
|
||||
|
|
|
|||
|
|
@ -1,4 +1,28 @@
|
|||
<?php
|
||||
/* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/tools/rector/rector.php
|
||||
* \ingroup core
|
||||
* \brief Toolt to run rector
|
||||
*
|
||||
* cd dev/tools/rector
|
||||
* ./vendor/bin/rector process [--dry-run] [--clear-cache] ../../../htdocs/core/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
|
@ -56,6 +80,7 @@ return static function (RectorConfig $rectorConfig): void {
|
|||
$rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyUserRightsToFunction::class);
|
||||
$rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class);
|
||||
$rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class);
|
||||
//$rectorConfig->rule(Dolibarr\Rector\Renaming\UsePositiveExit::class);
|
||||
|
||||
// Add all predefined rules to migrate to up to php 71.
|
||||
// Warning this break tab spacing of arrays on several lines
|
||||
|
|
|
|||
114
dev/tools/rector/src/Renaming/UsePositiveExit.php
Normal file
114
dev/tools/rector/src/Renaming/UsePositiveExit.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* This rule to replace exit does not work because "exit" is not a function
|
||||
*/
|
||||
|
||||
namespace Dolibarr\Rector\Renaming;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Expr\BinaryOp\Equal;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\Empty_;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Isset_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Core\NodeManipulator\BinaryOpManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Php71\ValueObject\TwoNodeMatch;
|
||||
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
|
||||
|
||||
/**
|
||||
* Class with Rector custom rule to fix code
|
||||
*/
|
||||
class UsePositiveExit extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\NodeManipulator\BinaryOpManipulator
|
||||
*/
|
||||
private $binaryOpManipulator;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param BinaryOpManipulator $binaryOpManipulator The $binaryOpManipulator
|
||||
*/
|
||||
public function __construct(BinaryOpManipulator $binaryOpManipulator)
|
||||
{
|
||||
$this->binaryOpManipulator = $binaryOpManipulator;
|
||||
}
|
||||
|
||||
/**
|
||||
* getRuleDefinition
|
||||
*
|
||||
* @return RuleDefinition
|
||||
* @throws PoorDocumentationException
|
||||
*/
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
{
|
||||
return new RuleDefinition(
|
||||
'Change exit(-x) int exit(x)',
|
||||
[new CodeSample(
|
||||
'exit(-2)',
|
||||
'exit(2)'
|
||||
)]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a node type from https://github.com/rectorphp/php-parser-nodes-docs/
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* refactor
|
||||
*
|
||||
* @param Node $node A node
|
||||
* @return FuncCall|BooleanNot
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if ($node instanceof FuncCall) {
|
||||
$tmpfunctionname = $this->getName($node);
|
||||
// If function is ok. We must avoid a lot of cases like isset(), empty()
|
||||
if (in_array($tmpfunctionname, array('exit'))) {
|
||||
//print "tmpfunctionname=".$tmpfunctionname."\n";
|
||||
$args = $node->getArgs();
|
||||
$nbofparam = count($args);
|
||||
|
||||
if ($nbofparam >= 1) {
|
||||
$tmpargs = $args;
|
||||
foreach ($args as $key => $arg) { // only 1 element in this array
|
||||
//var_dump($key);
|
||||
//var_dump($arg->value);exit;
|
||||
if (empty($arg->value)) {
|
||||
return;
|
||||
}
|
||||
$a = new FuncCall(new Name('exit'), [new Arg(abs($arg->value))]);
|
||||
//$tmpargs[$key] = new Arg($a);
|
||||
return $a;
|
||||
|
||||
//$r = new FuncCall(new Name($tmpfunctionname), $tmpargs);
|
||||
//return $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1764,25 +1764,25 @@ if (empty($reshook)) {
|
|||
|
||||
// Date start
|
||||
$date_start = false;
|
||||
if ($lines[$i]->date_debut_prevue) {
|
||||
if (isset($lines[$i]->date_debut_prevue)) {
|
||||
$date_start = $lines[$i]->date_debut_prevue;
|
||||
}
|
||||
if ($lines[$i]->date_debut_reel) {
|
||||
if (isset($lines[$i]->date_debut_reel)) {
|
||||
$date_start = $lines[$i]->date_debut_reel;
|
||||
}
|
||||
if ($lines[$i]->date_start) {
|
||||
if (isset($lines[$i]->date_start)) {
|
||||
$date_start = $lines[$i]->date_start;
|
||||
}
|
||||
|
||||
// Date end
|
||||
$date_end = false;
|
||||
if ($lines[$i]->date_fin_prevue) {
|
||||
if (isset($lines[$i]->date_fin_prevue)) {
|
||||
$date_end = $lines[$i]->date_fin_prevue;
|
||||
}
|
||||
if ($lines[$i]->date_fin_reel) {
|
||||
if (isset($lines[$i]->date_fin_reel)) {
|
||||
$date_end = $lines[$i]->date_fin_reel;
|
||||
}
|
||||
if ($lines[$i]->date_end) {
|
||||
if (isset($lines[$i]->date_end)) {
|
||||
$date_end = $lines[$i]->date_end;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ function societe_admin_prepare_head()
|
|||
* @param int $searchlabel Label of country to search (warning: searching on label is not reliable)
|
||||
* @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined'
|
||||
*/
|
||||
function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '')
|
||||
function getCountry($searchkey, $withcode = '', $dbtouse = null, $outputlangs = null, $entconv = 1, $searchlabel = '')
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
|
|
@ -608,7 +608,7 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
|
|||
* @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
|
||||
* @return string|array String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region')
|
||||
*/
|
||||
function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1)
|
||||
function getState($id, $withcode = '', $dbtouse = null, $withregion = 0, $outputlangs = null, $entconv = 1)
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
|
|
@ -1560,7 +1560,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
|
|||
* @param string|string[] $actioncode Filter on actioncode
|
||||
* @return string|void Return html part or void if noprint is 1
|
||||
*/
|
||||
function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '')
|
||||
function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '')
|
||||
{
|
||||
global $user, $conf;
|
||||
|
||||
|
|
@ -1591,7 +1591,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
|||
* @param string $module You can add module name here if elementtype in table llx_actioncomm is objectkey@module
|
||||
* @return string|void Return html part or void if noprint is 1
|
||||
*/
|
||||
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
|
||||
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
|
||||
{
|
||||
global $user, $conf, $hookmanager;
|
||||
global $form;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017 Florian HENRY <florian.henry@atm-consulting.fr>
|
||||
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -47,10 +47,14 @@ class LoanSchedule extends CommonObject
|
|||
|
||||
public $bank_account;
|
||||
public $bank_line;
|
||||
|
||||
/**
|
||||
* @var int|string Creation date
|
||||
*/
|
||||
public $datec;
|
||||
|
||||
/**
|
||||
* @var string Payment date
|
||||
* @var int|string Payment date
|
||||
*/
|
||||
public $datep;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -69,7 +69,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
|
||||
if (!isset($argv[3]) || !$argv[3]) {
|
||||
print "Usage: ".$script_file." bank_ref [bank_receipt_number|all] (csv|tsv|excel|excel2007) [lang=xx_XX]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$bankref = $argv[1];
|
||||
$num = $argv[2];
|
||||
|
|
@ -115,7 +115,7 @@ $acct = new Account($db);
|
|||
$result = $acct->fetch('', $bankref);
|
||||
if ($result <= 0) {
|
||||
print "Failed to find bank account with ref ".$bankref.".\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
} else {
|
||||
print "Export for bank account ".$acct->ref." (".$acct->label.").\n";
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ $file = "export_".$model.".modules.php";
|
|||
$classname = "Export".$model;
|
||||
if (!dol_is_file($dir.$file)) {
|
||||
print "No driver to export with format ".$model."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
require_once $dir.$file;
|
||||
$objmodel = new $classname($db);
|
||||
|
|
@ -232,7 +232,7 @@ if ($resql) {
|
|||
$db->free($resql2);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$total = $balancebefore[$objp->num_releve];
|
||||
|
|
@ -414,7 +414,7 @@ if ($resql) {
|
|||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
$ret = -1;
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -61,7 +61,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: $script_file now [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($argv as $key => $val) {
|
||||
|
|
@ -74,7 +74,7 @@ $now = $argv[1];
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-only mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print "Mails sending disabled (useless in batch mode)\n";
|
||||
|
|
@ -108,7 +108,7 @@ if (!$confirmed) {
|
|||
/*
|
||||
* if (!getDolGlobalString('LDAP_CONTACT_ACTIVE')) {
|
||||
* print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||
* exit(-1);
|
||||
* exit(1);
|
||||
* }
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ $path = __DIR__.'/';
|
|||
$sapi_type = php_sapi_name();
|
||||
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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm')) || !in_array($argv[2], array('thirdparties', 'contacts'))) {
|
||||
|
|
@ -47,7 +47,7 @@ if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm'
|
|||
print "If you choose 'test' mode, no emails are sent.\n";
|
||||
print "If you add param delay (nb of days), only services with expired date < today + delay are included.\n";
|
||||
print "If you add param after (nb of days), only services with expired date >= today + delay are included.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$mode = $argv[1];
|
||||
$targettype = $argv[2];
|
||||
|
|
@ -227,7 +227,7 @@ if ($resql) {
|
|||
dol_print_error($db);
|
||||
dol_syslog("email_expire_services_to_customers.php: Error");
|
||||
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ $path = __DIR__.'/';
|
|||
$sapi_type = php_sapi_name();
|
||||
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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm'))) {
|
||||
|
|
@ -46,7 +46,7 @@ if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm'
|
|||
print "Send an email to remind all contracts services to expire, to users that are sale representative for.\n";
|
||||
print "If you choose 'test' mode, no emails are sent.\n";
|
||||
print "If you add a delay (nb of days), only services with expired date < today + delay are included.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$mode = $argv[1];
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ if ($resql) {
|
|||
dol_print_error($db);
|
||||
dol_syslog("email_expire_services_to_representatives.php: Error");
|
||||
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ $path = __DIR__.'/';
|
|||
// Error if Web 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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -66,13 +66,13 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
|||
// Check parameters
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
usage($path, $script_file);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$key = $argv[1];
|
||||
|
||||
if (!isset($argv[2]) || !$argv[2]) {
|
||||
usage($path, $script_file);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$userlogin = $argv[2];
|
||||
|
|
@ -97,18 +97,18 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=
|
|||
// Check module cron is activated
|
||||
if (!isModEnabled('cron')) {
|
||||
print "Error: module Scheduled jobs (cron) not activated\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Check security key
|
||||
if ($key != getDolGlobalString('CRON_KEY')) {
|
||||
print "Error: securitykey is wrong\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-only mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// If param userlogin is reserved word 'firstadmin'
|
||||
|
|
@ -132,12 +132,12 @@ $result = $user->fetch('', $userlogin, '', 1);
|
|||
if ($result < 0) {
|
||||
echo "User Error: ".$user->error;
|
||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
} else {
|
||||
if (empty($user->id)) {
|
||||
echo "User login: ".$userlogin." does not exists\n";
|
||||
dol_syslog("User login:".$userlogin." does not exists", LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ if (!empty($id)) {
|
|||
if (!is_numeric($id)) {
|
||||
echo "Error: Bad value for parameter job id\n";
|
||||
dol_syslog("cron_run_jobs.php Bad value for parameter job id", LOG_WARNING);
|
||||
exit();
|
||||
exit(2);
|
||||
}
|
||||
$filter['t.rowid'] = $id;
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ $result = $object->fetchAll('ASC,ASC,ASC', 't.priority,t.entity,t.rowid', 0, 0,
|
|||
if ($result < 0) {
|
||||
echo "Error: ".$object->error;
|
||||
dol_syslog("cron_run_jobs.php fetch Error ".$object->error, LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// TODO Duplicate code. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
|
||||
|
|
@ -212,12 +212,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 exist for entity ".$conf->entity."\n";
|
||||
dol_syslog("cron_run_jobs.php: User login: ".$userlogin." does not exist", LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$user->getrights();
|
||||
|
|
@ -251,7 +251,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
|
|||
echo " - Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n";
|
||||
echo "Failed to fetch job ".$line->id."\n";
|
||||
dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
// Execute job
|
||||
$result = $cronjob->run_jobs($userlogin);
|
||||
|
|
@ -275,7 +275,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
|
|||
echo " - Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n";
|
||||
echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n";
|
||||
dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo " - reprogrammed\n";
|
||||
|
|
|
|||
|
|
@ -34,7 +34,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -69,7 +69,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
if (empty($argv[1])) {
|
||||
print "Usage: $script_file subdirtoscan (test|confirm)\n";
|
||||
print "Example: $script_file propale test\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print '--- start'."\n";
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ $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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: ".$script_file." (ID_MAILING|all) [userloginforsignature] [maxnbofemails]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$id = $argv[1];
|
||||
|
|
@ -76,7 +76,7 @@ $langs->loadLangs(array("main", "mails"));
|
|||
|
||||
if (!isModEnabled('mailing')) {
|
||||
print 'Module Emailing not enabled';
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('cli'));
|
||||
|
|
@ -98,7 +98,7 @@ if (getDolGlobalString('MAILING_LIMIT_SENDBYCLI') == '-1') {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-only mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$user = new User($db);
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ $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);
|
||||
}
|
||||
|
||||
if (!isset($argv[3]) || !$argv[3]) {
|
||||
print "Usage: ".$script_file." inputfile-with-invalid-emails type [test|confirm]\n";
|
||||
print "- inputfile-with-invalid-emails is a file with list of invalid email\n";
|
||||
print "- type can be 'all' or 'thirdparties', 'contacts', 'members', 'users'\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$fileofinvalidemail = $argv[1];
|
||||
$type = $argv[2];
|
||||
|
|
@ -59,7 +59,7 @@ $error = 0;
|
|||
|
||||
if (!isModEnabled('mailing')) {
|
||||
print 'Module Emailing not enabled';
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('cli'));
|
||||
|
|
@ -76,12 +76,12 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
|||
|
||||
if (!in_array($type, array('all', 'thirdparties', 'contacts', 'users', 'members'))) {
|
||||
print "Bad value for parameter type.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
|
|
@ -90,7 +90,7 @@ $db->begin();
|
|||
$myfile = fopen($fileofinvalidemail, "r");
|
||||
if (!$myfile) {
|
||||
echo "Failed to open file";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$tmp = 1;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ $path = __DIR__.'/';
|
|||
$sapi_type = php_sapi_name();
|
||||
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);
|
||||
}
|
||||
|
||||
if (!isset($argv[2]) || !$argv[2] || !in_array($argv[1], array('test', 'confirm')) || !in_array($argv[2], array('thirdparties', 'contacts'))) {
|
||||
|
|
@ -47,7 +47,7 @@ if (!isset($argv[2]) || !$argv[2] || !in_array($argv[1], array('test', 'confirm'
|
|||
print "If you choose 'test' mode, no emails are sent.\n";
|
||||
print "If you add param delay (nb of days), only invoice with due date < today + delay are included.\n";
|
||||
print "If you add param after (nb of days), only invoice with due date >= today + delay are included.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$mode = $argv[1];
|
||||
$targettype = $argv[2];
|
||||
|
|
@ -85,7 +85,7 @@ if ($mode != 'confirm') {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,";
|
||||
|
|
@ -230,7 +230,7 @@ if ($resql) {
|
|||
dol_print_error($db);
|
||||
dol_syslog("email_unpaid_invoices_to_customers.php: Error");
|
||||
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ $path = __DIR__.'/';
|
|||
$sapi_type = php_sapi_name();
|
||||
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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm'))) {
|
||||
|
|
@ -46,7 +46,7 @@ if (!isset($argv[1]) || !$argv[1] || !in_array($argv[1], array('test', 'confirm'
|
|||
print "Send an email to users to remind all unpaid customer invoices user is sale representative for.\n";
|
||||
print "If you choose 'test' mode, no emails are sent.\n";
|
||||
print "If you add a delay (nb of days), only invoice with due date < today + delay are included.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$mode = $argv[1];
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ if ($mode != 'confirm') {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,";
|
||||
|
|
@ -186,7 +186,7 @@ if ($resql) {
|
|||
dol_print_error($db);
|
||||
dol_syslog("email_unpaid_invoices_to_representatives.php: Error");
|
||||
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,7 +34,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);
|
||||
}
|
||||
|
||||
// Include Dolibarr environment
|
||||
|
|
@ -66,12 +66,12 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
// Check parameters
|
||||
if (!isset($argv[1])) {
|
||||
rebuild_merge_pdf_usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$diroutputpdf = $conf->facture->dir_output.'/temp';
|
||||
|
|
@ -139,7 +139,7 @@ foreach ($argv as $key => $value) {
|
|||
$paymentdatebefore = dol_stringtotime($argv[$key + 2].'235959');
|
||||
if (empty($paymentdateafter) || empty($paymentdatebefore)) {
|
||||
print 'Error: Bad date format or value'."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
print 'Rebuild PDF for invoices with at least one payment between '.dol_print_date($paymentdateafter, 'day', 'gmt')." and ".dol_print_date($paymentdatebefore, 'day', 'gmt').".\n";
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ foreach ($argv as $key => $value) {
|
|||
$result = $bankaccount->fetch(0, $paymentonbankref);
|
||||
if ($result <= 0) {
|
||||
print 'Error: Bank account with ref "'.$paymentonbankref.'" not found'."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$paymentonbankid = $bankaccount->id;
|
||||
print 'Rebuild PDF for invoices with at least one payment on financial account '.$bankaccount->ref."\n";
|
||||
|
|
@ -211,23 +211,23 @@ foreach ($argv as $key => $value) {
|
|||
|
||||
if (!$found && preg_match('/filter=/i', $value)) {
|
||||
rebuild_merge_pdf_usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if an option and a filter has been provided
|
||||
if (empty($option) && count($filter) <= 0) {
|
||||
rebuild_merge_pdf_usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
// Check if there is no incompatible choice
|
||||
if (in_array('payments', $filter) && in_array('nopayment', $filter)) {
|
||||
rebuild_merge_pdf_usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if (in_array('bank', $filter) && in_array('nopayment', $filter)) {
|
||||
rebuild_merge_pdf_usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Define SQL and SQL request to select invoices
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -62,7 +62,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: $script_file now [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($argv as $key => $val) {
|
||||
|
|
@ -73,7 +73,7 @@ foreach ($argv as $key => $val) {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$now = $argv[1];
|
||||
|
|
@ -109,7 +109,7 @@ if (!$confirmed) {
|
|||
/*
|
||||
* if (getDolGlobalString('LDAP_MEMBER_ACTIVE') {
|
||||
* print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||
* exit(-1);
|
||||
* exit(1);
|
||||
* }
|
||||
*/
|
||||
|
||||
|
|
@ -133,12 +133,12 @@ if ($resql) {
|
|||
$result = $member->fetch($obj->rowid);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $member->error);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$result = $member->fetch_subscriptions();
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $member->error);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->getFullName($langs);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -98,7 +98,7 @@ $required_fields = array_unique(array_values(array_filter($required_fields, "dol
|
|||
|
||||
if (!isset($argv[2]) || !is_numeric($argv[2])) {
|
||||
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost] [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$typeid = (int) $argv[2];
|
||||
|
|
@ -142,7 +142,7 @@ print "\n";
|
|||
// Check parameters
|
||||
if (!getDolGlobalString('LDAP_MEMBER_DN')) {
|
||||
print $langs->trans("Error").': '.$langs->trans("LDAP setup for members not defined inside Dolibarr")."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if ($typeid <= 0) {
|
||||
print $langs->trans("Error").': Parameter id_member_type is not a valid ref of an existing member type'."\n";
|
||||
|
|
@ -151,7 +151,7 @@ if ($typeid <= 0) {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!$confirmed) {
|
||||
|
|
@ -183,7 +183,7 @@ if ($resql) {
|
|||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ldap = new Ldap();
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ $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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: ".$script_file." now\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$now = $argv[1];
|
||||
|
|
@ -68,13 +68,13 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
/*
|
||||
* if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {
|
||||
* print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||
* exit(-1);
|
||||
* exit(1);
|
||||
* }
|
||||
*/
|
||||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -73,7 +73,7 @@ $required_fields = array_unique(array_values(array_filter($required_fields, "dol
|
|||
if (!isset($argv[1])) {
|
||||
// print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
|
||||
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($argv as $key => $val) {
|
||||
|
|
@ -93,7 +93,7 @@ foreach ($argv as $key => $val) {
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print "Mails sending disabled (useless in batch mode)\n";
|
||||
|
|
@ -124,7 +124,7 @@ if (!$confirmed) {
|
|||
|
||||
if (!getDolGlobalString('LDAP_MEMBER_TYPE_DN')) {
|
||||
print $langs->trans("Error").': '.$langs->trans("LDAP setup for members types not defined inside Dolibarr");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ldap = new Ldap();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -68,7 +68,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
|
||||
if (!isset($argv[1]) || $argv[1] != 'product') {
|
||||
print "Usage: $script_file product\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print '--- start'."\n";
|
||||
|
|
|
|||
|
|
@ -34,7 +34,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -68,7 +68,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
if (empty($argv[1])) {
|
||||
print "Usage: $script_file subdirtoscan\n";
|
||||
print "Example: $script_file produit\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print '--- start'."\n";
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -68,7 +68,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
|
||||
if (!isset($argv[1]) || $argv[1] != 'user') {
|
||||
print "Usage: $script_file user\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print '--- start'."\n";
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ $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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: ".$script_file." now\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$now = $argv[1];
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
/*
|
||||
* if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {
|
||||
* print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||
* exit(-1);
|
||||
* exit(1);
|
||||
* }
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -73,7 +73,7 @@ $required_fields = array_unique(array_values(array_filter($required_fields, "dol
|
|||
if (!isset($argv[1])) {
|
||||
// print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
|
||||
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($argv as $key => $val) {
|
||||
|
|
@ -123,7 +123,7 @@ if (!$confirmed) {
|
|||
|
||||
if (!getDolGlobalString('LDAP_GROUP_DN')) {
|
||||
print $langs->trans("Error").': '.$langs->trans("LDAP setup for groups not defined inside Dolibarr");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ldap = new Ldap();
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ $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);
|
||||
}
|
||||
|
||||
if (!isset($argv[1]) || !$argv[1]) {
|
||||
print "Usage: $script_file now\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$now = $argv[1];
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||
/*
|
||||
* if (! getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {
|
||||
* print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||
* exit(-1);
|
||||
* exit(1);
|
||||
* }
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -91,7 +91,7 @@ $required_fields = array_unique(array_values(array_filter($required_fields, "dol
|
|||
|
||||
if (!isset($argv[1])) {
|
||||
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($argv as $key => $val) {
|
||||
|
|
@ -142,7 +142,7 @@ if (!$confirmed) {
|
|||
|
||||
if (!getDolGlobalString('LDAP_USER_DN')) {
|
||||
print $langs->trans("Error").': '.$langs->trans("LDAP setup for users not defined inside Dolibarr");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Load table of correspondence of countries
|
||||
|
|
@ -169,7 +169,7 @@ if ($resql) {
|
|||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ldap = new Ldap();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -55,7 +55,7 @@ if (empty($argv[3]) || !in_array($argv[1], array('test', 'confirm')) || empty($w
|
|||
print "Usage: $script_file (test|confirm) website login:pass@serverjoomla/tableprefix/databasejoomla [nbmaxrecord]\n";
|
||||
print "\n";
|
||||
print "Load joomla news and create them into Dolibarr database (if they don't already exist).\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -74,7 +74,7 @@ $langs->load('main');
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$joomlaserverinfoarray = preg_split('/(:|@|\/)/', $joomlaserverinfo);
|
||||
|
|
@ -90,7 +90,7 @@ $website = new Website($db);
|
|||
$result = $website->fetch(0, $websiteref);
|
||||
if ($result <= 0) {
|
||||
print 'Error, web site '.$websiteref.' not found'."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$websiteid = $website->id;
|
||||
$importid = dol_print_date(dol_now(), 'dayhourlog');
|
||||
|
|
@ -98,7 +98,7 @@ $importid = dol_print_date(dol_now(), 'dayhourlog');
|
|||
$dbjoomla = getDoliDBInstance('mysqli', $joomlahost, $joomlalogin, $joomlapass, $joomladatabase, $joomlaport);
|
||||
if ($dbjoomla->error) {
|
||||
dol_print_error($dbjoomla, "host=".$joomlahost.", port=".$joomlaport.", user=".$joomlalogin.", databasename=".$joomladatabase.", ".$dbjoomla->error);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$sql = 'SELECT c.id, c.title, c.alias, c.created, c.introtext, `fulltext`, c.metadesc, c.metakey, c.language, c.created, c.publish_up, u.username FROM '.$joomlaprefix.'_content as c';
|
||||
|
|
@ -116,12 +116,12 @@ if (!$resql) {
|
|||
$blogpostheader = file_get_contents($path.'blogpost-header.txt');
|
||||
if ($blogpostheader === false) {
|
||||
print "Error: Failed to load file content of 'blogpost-header.txt'\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
$blogpostfooter = file_get_contents($path.'blogpost-footer.txt');
|
||||
if ($blogpostfooter === false) {
|
||||
print "Error: Failed to load file content of 'blogpost-footer.txt'\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,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);
|
||||
}
|
||||
|
||||
@set_time_limit(0); // No timeout for this script
|
||||
|
|
@ -50,7 +50,7 @@ if (empty($argv[2]) || !in_array($argv[1], array('test', 'confirm')) || empty($w
|
|||
print "Usage: $script_file (test|confirm) website [nbmaxrecord]\n";
|
||||
print "\n";
|
||||
print "Regenerate all pages of a web site.\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -69,14 +69,14 @@ $langs->load('main');
|
|||
|
||||
if (!empty($dolibarr_main_db_readonly)) {
|
||||
print "Error: instance in read-onyl mode\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$website = new Website($db);
|
||||
$result = $website->fetch(0, $websiteref);
|
||||
if ($result <= 0) {
|
||||
print 'Error, web site '.$websiteref.' not found'."\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$websitepagestatic = new WebsitePage($db);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,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);
|
||||
}
|
||||
|
||||
require_once $path."../../htdocs/master.inc.php";
|
||||
|
|
@ -70,7 +70,7 @@ if (!isset($argv[1])) { // Check parameters
|
|||
print "This script check invoices with a withdrawal request and\n";
|
||||
print "then create payment and build a withdraw file.\n";
|
||||
print "Usage: ".$script_file." simu|real\n";
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$withdrawreceipt = new BonPrelevement($db);
|
||||
|
|
|
|||
|
|
@ -379,6 +379,30 @@ abstract class CommonClassTest extends TestCase
|
|||
'zapier' => 'Zapier',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Run php script (file) using the php binary used for running phpunit.
|
||||
*
|
||||
* The PHP executable may not be in the path, or refer to an uncontrolled
|
||||
* version.
|
||||
* This ensures that the php script is properly run on multiple platforms.
|
||||
*
|
||||
* @param string $phpScriptCommand The command and arguments are run by the php binary.
|
||||
* @param array $output The output returned by the command
|
||||
* @param int $exitCode The exit code returned for the execution.
|
||||
* @return false|string False on failure, else last line if the output from the command
|
||||
*/
|
||||
protected function runPhpScript($phpScriptCommand, &$output, &$exitCode)
|
||||
{
|
||||
$phpExecutable = PHP_BINARY;
|
||||
|
||||
// Build the command to execute the PHP script
|
||||
$command = "$phpExecutable $phpScriptCommand";
|
||||
|
||||
// Execute the command
|
||||
return exec($command, $output, $exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a directory does not exist without triggering deprecation
|
||||
*
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ class ScriptsTest extends CommonClassTest
|
|||
$returnvar = 0;
|
||||
$output = array();
|
||||
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($result, 'Failed to find bank account with ref BANKDUMMY.');
|
||||
$this->assertEquals($returnvar, 255);
|
||||
$this->assertEquals($returnvar, 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class ScriptsTest extends CommonClassTest
|
|||
print __METHOD__." output=".join("\n",$output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.');
|
||||
$this->assertEquals($returnvar,255);
|
||||
$this->assertEquals($returnvar, 1);
|
||||
*/
|
||||
$this->assertEquals(0, 0);
|
||||
|
||||
|
|
@ -156,21 +156,21 @@ class ScriptsTest extends CommonClassTest
|
|||
$output = array();
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php thirdparties');
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php contacts');
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
|
|
@ -197,21 +197,21 @@ class ScriptsTest extends CommonClassTest
|
|||
$output = array();
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties');
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php contacts');
|
||||
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
$result = $this->runPhpScript($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue