diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
new file mode 100644
index 00000000000..a98cf177eca
--- /dev/null
+++ b/.phpcs.xml.dist
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/COPYRIGHT b/COPYRIGHT
index fb2d6159e06..fc50ab2093e 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -28,7 +28,7 @@ Escpos-php 3.0 MIT License Yes
GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert
MathPHP 2.8.1 MIT License Yes Modern math library for PHP (only few files)
Mobiledetect 2.8.41 MIT License Yes Detect mobile devices browsers
-NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
+NuSoap 0.9.16 LGPL 2.1+ Yes Library to develop SOAP Web services. From https://github.com/f00b4r/nusoap/tree/v0.9.16
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.7.4 MIT License Yes Markdown parser
PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files
@@ -38,6 +38,7 @@ PHP-Iban 4.1.1 LGPL-3+ Yes
PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth
PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
+PrestaShop-WS-Lib 94feb5f OSL-3.0 No Library providing API client for Prestashop.
PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar)
PSR/simple-cache ? MIT License Yes Library for cache (used by PHPSpreadSheet)
Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
diff --git a/ChangeLog b/ChangeLog
index a5d8b7c967e..0458780eeab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -254,6 +254,44 @@ The following changes may create regressions for some external modules, but were
* A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english.
+***** ChangeLog for 18.0.4 compared to 18.0.3 *****
+FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming
+FIX: 16.0 only, backport fix for SQL error on global search product
+FIX: #25399 (#26694)
+FIX: #25458 intervention localizations (backport v17) (#26757)
+FIX: #26518
+FIX: #26536 Accountancy - Balance - Not divided lines by label & account, only by account (#26547)
+FIX: #26553 Supplier invoice - Do not display the delete button for reconciled payment (#26554)
+FIX: #26735
+FIX: #26994
+FIX: Accountancy - Possibility to write in bookkeeping expense report operation with some line not bound (#26545)
+FIX: add display of an error when attempting to delete a committed transaction (#26573)
+FIX: avoid warning : Cannot use a scalar value as an array (#26437)
+FIX: backport SQL error on global search product
+FIX: # Bug Estimated Stock at date value in V14 (#26479)
+FIX: commande context (#26497)
+FIX: delivery note disappear after generation
+FIX: double hook and paging search param in product list (#26767)
+FIX: Email reminder template must not be visible when option is off
+FIX: escape HTML tags in return value of getFullName() (#26735)
+FIX: Fix set private note (#26610)
+FIX: Fix when options FAC_FORCE_DATE_VALIDATION and INVOICE_CHECK_POSTERIOR_DATE enabled. The date is forced after the test and not before
+FIX: menu auguria
+FIX: pagination parameters on save and cancel buttons (#26605)
+FIX: pdf cornas page head multicell width (backport v17)
+FIX: php8 fatal on edit supplier order when multicurrency is activated (#26758)
+FIX: possible inconsistency between llx_ecm_files and file system when BILL_SUPPLIER_VALIDATES changes ref
+FIX: regression on planned bank entries (#26556)
+FIX: Social contribution - Payment list - Wrong information in type column (#26561)
+FIX: special_code update line keep old value. (#26819)
+FIX: substitute project variables in invoice documents (#26445)
+FIX: Test on permission for holiday tooltips
+FIX: v17: Param $notrigger in $societe->create() causes method to return true regardless of actual result of database functions (#26499)
+FIX: v18 SQL error in llx_c_forme_juridique.sql when installing
+FIX: Warehouse Global Amounts not displayed (#26478)
+FIX: warning param $lineID getSpecialCode is negatif (#26826)
+FIX: warning php8.2 undefined_array_key (#26830)
+
***** ChangeLog for 18.0.3 compared to 18.0.2 *****
FIX: #25793 Cannot add time spent (#26405)
FIX: #26100 Ticket - On edit, list of closed project must be excluded (#26223)
diff --git a/build/exe/doliwamp/UsedPort.cpp b/build/exe/doliwamp/UsedPort.cpp
index e2724b831a1..a63938c5038 100644
--- a/build/exe/doliwamp/UsedPort.cpp
+++ b/build/exe/doliwamp/UsedPort.cpp
@@ -253,6 +253,7 @@ int main(int argc, char **argv)
//----------------
int noarg,curseurarg,help=0,invalide=0;
char option;
+char *endptr;
for (noarg=1;noarg INT_MAX) {
+ // Handle error: Port number out of range
+ printf("Port number out of range\n");
+ exit(-1);
+}
+
help=!(Port > 0);
// Show usage
diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt
index 8305dbefbd9..a2a99bdfd5a 100644
--- a/dev/dolibarr_changes.txt
+++ b/dev/dolibarr_changes.txt
@@ -44,37 +44,34 @@ With
NUSOAP:
-------
-* In file nusoap.php, to avoid a warning,
-Replace
- if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
-By
- if (! is_array($this->methodreturn) && isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
+* Line 1257 of file nusoap.php. Add:
-* In file nusoap.php, to avoid a warning,
-Replace call to serialize_val with no bugged value
+ libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only for libxml < 2.
+
+
+* Line 4346 of file nusoap.php
-* In all files, replace constructor names into __construct. Replace also parent::constructor_name with parent::__construct
+ $rev = array();
+ preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
+ $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
-* Line 4222 of file nusoap.php
-
- $rev = array();
- preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
- $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
+* Line 6566 of file nusoap.php, replace
+ if (count($attrs) > 0) {
+ with
+ if (is_array($attrs) && count($attrs) > 0) {
TCPDF:
------
* Replace in tcpdf.php:
-
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
unlink($file);
}
}
with
-
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
// DOL CHANGE If we keep this, source image files are physically destroyed
@@ -82,8 +79,7 @@ with
}
}
-* Replace in tcpdf.php
-
+* Replace in tcpdf.php:
$preserve = array(
'file_id',
'internal_encoding',
@@ -91,9 +87,7 @@ with
'bufferlen',
'buffer',
'cached_files',
-
with
-
$preserve = array(
'file_id',
'internal_encoding',
@@ -104,14 +98,11 @@ with
// @CHANGE DOL
'imagekeys',
-* Replace in tcpdf.php
-
+* Replace in tcpdf.php:
if (!@TCPDF_STATIC::file_exists($file)) {
- return false;
+ return false;
}
-
with
-
if (!@TCPDF_STATIC::file_exists($file)) {
// DOL CHANGE If we keep this, the image is not visible on pages after the first one.
//var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file)));
@@ -122,12 +113,9 @@ with
}
}
-* Replace in tcpdf.php
-
+* Replace in tcpdf.php:
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
-
with
-
// @CHANGE LDR Add support for src="file://..." links
if (strpos($imgsrc, 'file://') === 0) {
$imgsrc = str_replace('file://', '/', $imgsrc);
@@ -144,12 +132,9 @@ with
elseif (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
-* In tecnickcom/tcpdf/include/tcpdf_static.php, in function fopenLocal, replace
-
+* In tecnickcom/tcpdf/include/tcpdf_static.php, in function fopenLocal, replace:
if (strpos($filename, '://') === false) {
-
with
-
if (strpos($filename, '//') === 0) {
// Share folder on a (windows) server
// e.g.: "//[MyServerName]/[MySharedFolder]/"
@@ -158,17 +143,22 @@ with
}
elseif (strpos($filename, '://') === false)
-* To avoid to have QRcode changed because generated with a random mask, replace
-define('QR_FIND_FROM_RANDOM', 2);
+* To avoid to have QRcode changed because generated with a random mask, replace:
+ define('QR_FIND_FROM_RANDOM', 2);
with
-define('QR_FIND_FROM_RANDOM', false);
+ define('QR_FIND_FROM_RANDOM', false);
+* Change line:
+ imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
+into
+ imagesetpixel($imgalpha, $xpx, $ypx, (int) $alpha);
+
* Removed useless directories ("examples", "tools")
-* Optionnaly, removed all fonts except
- dejavusans* (used by greek, arab, persan, romanian, turkish),
- freemono* (russian),
- cid*+msungstdlight+stsongstdlight+uni2cid* (chinese),
+* Optionnaly, removed all fonts except
+ dejavusans* (used by greek, arab, persan, romanian, turkish),
+ freemono* (russian),
+ cid*+msungstdlight+stsongstdlight+uni2cid* (chinese),
helvetica* (all other languages),
zapfdingbats.php (for special chars like form checkboxes)
@@ -180,15 +170,15 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
* In tecnickcom/tcpdf/include/tcpdf_static, in function intToRoman, right at the beginning
of the function, replace:
- $roman = '';
+ $roman = '';
-with:
+ with:
- $roman = '';
- if ($number >= 4000) {
- // do not represent numbers above 4000 in Roman numerals
- return strval($number);
- }
+ $roman = '';
+ if ($number >= 4000) {
+ // do not represent numbers above 4000 in Roman numerals
+ return strval($number);
+ }
* Add this at begin of tcpdf_autoconfig.php
@@ -223,7 +213,7 @@ with:
* Fix syntax error by replacing
} elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1] >= 2))) {
-with
+ with
} elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1]) >= 2)) {
* Fix php fatal error on php 8.0 on tcpdi.php
@@ -314,6 +304,24 @@ RESTLER:
empty($value[0]) ? null :
empty($value[1]) ? null :
+* Add a test into AutoLoader.php to complete function loadThisLoader and test if property exists before calling it. For this replace code
+
+ if (false !== $file = $b::$loader[1]($className) && $this->exists($className, $b::$loader[1])) {
+ return $file;
+ }
+
+ with:
+
+ //avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader
+ //in case of multiple autoloader systems
+ if(property_exists($b, $loader[1])) {
+ if (false !== $file = $b::$loader[1]($className)
+ && $this->exists($className, $b::$loader[1])) {
+ return $file;
+ }
+ }
+
+
+With swagger 2 provided into /explorer:
----------------------------------------
@@ -327,16 +335,15 @@ PARSEDOWN
* Add support of css by adding in Parsedown.php:
// @CHANGE LDR
- 'class' => $Link['element']['attributes']['class']
+ 'class' => $Link['element']['attributes']['class']
...
-
+
// @CHANGE LDR
- if (preg_match('/{([^}]+)}/', $remainder, $matches2))
- {
- $Element['attributes']['class'] = $matches2[1];
- $remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder);
- }
+ if (preg_match('/{([^}]+)}/', $remainder, $matches2)) {
+ $Element['attributes']['class'] = $matches2[1];
+ $remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder);
+ }
// @CHANGE LDR
@@ -369,7 +376,7 @@ Add into Class Google of file OAuth2/Service/Google:
}
$this->approvalPrompt = $prompt;
}
-
+
JEDITABLE.JS
diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php
index cf9a708de9e..3c357949e28 100755
--- a/dev/initdata/generate-proposal.php
+++ b/dev/initdata/generate-proposal.php
@@ -152,7 +152,7 @@ $user->rights->propal->creer=1;
$user->rights->propal->propal_advance->validate=1;
-if (!empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php")) {
+if (getDolGlobalString('PROPALE_ADDON') && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php")) {
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/" . getDolGlobalString('PROPALE_ADDON').".php";
}
diff --git a/dev/initdata/import-thirdparties.php b/dev/initdata/import-thirdparties.php
index 5a5bde31905..a0e40d7b883 100755
--- a/dev/initdata/import-thirdparties.php
+++ b/dev/initdata/import-thirdparties.php
@@ -129,7 +129,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$object->fournisseur = $fields[8];
$object->name = $fields[13] ? trim($fields[13]) : $fields[0];
- $object->name_alias = $fields[0]!=$fields[13] ? trim($fields[0]) : '';
+ $object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : '';
$object->address = trim($fields[14]);
$object->zip = trim($fields[15]);
diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php
index d75c9fae8b2..442d991a453 100755
--- a/dev/initdata/purge-data.php
+++ b/dev/initdata/purge-data.php
@@ -148,8 +148,8 @@ $sqls=array(
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
),
'project'=>array(
- // TODO set fk_project to null on object that refer to project
- "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
+ // TODO set fk_project to null on all objects/tables that refer to project
+ "DELETE FROM ".MAIN_DB_PREFIX."element_time WHERE elementtype = 'task' AND fk_element IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
),
diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh
index bdba2a2a6ed..9b6d299601e 100755
--- a/dev/tools/github_authors_and_commits_peryear.sh
+++ b/dev/tools/github_authors_and_commits_peryear.sh
@@ -1,10 +1,11 @@
#!/bin/sh
#
# Count number of different contributors and number of commits for a given year.
+# Can be used for statistics (for example to generate the inforgraphy of the year)
#
if [ "x$1" = "x" ]; then
- echo "Usage: $0 YEAR"
+ echo "Usage: $0 YEARSTART [YEAREND]"
exit
fi
@@ -12,10 +13,15 @@ fi
FROM=$1-01-01
TO=$1-12-31
-echo "Number of contributors for the year"
-echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l"
-git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l
+if [ "x$2" != "x" ]; then
+ TO=$2-12-31
+fi
+
+echo "--- Number of contributors for the year"
+echo "git log --since $FROM --before $TO | grep ^Author | awk -F'<' '{ print $1 }' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort -u -f -i -b | wc -l"
+git log --since $FROM --before $TO | grep '^Author' | awk -F"<" '{ print $1 }' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort -u -f -i -b | wc -l
-echo "Number of commit for the year"
-git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{print "Year: "$2", commits: "$1}' | grep "Year: $1"
+echo "--- Number of commit for the year"
+echo "git log --pretty='format:%cd' --date=format:'%Y' | sort | uniq -c | awk '{ if (\$2 >= '"$1"') { print \"Year: \"\$2\", commits: \"\$1 } }'"
+git log --pretty='format:%cd' --date=format:'%Y' | sort | uniq -c | awk '{ if ($2 >= '$1') { print "Year: "$2", commits: "$1 } }'
diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php
index 6b13c2fbf0b..5b07d1da6cc 100644
--- a/dev/tools/rector/rector.php
+++ b/dev/tools/rector/rector.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
+use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->phpVersion(PhpVersion::PHP_71);
@@ -26,6 +27,8 @@ return static function (RectorConfig $rectorConfig): void {
$rectorConfig->skip([
'**/includes/**',
'**/custom/**',
+ '**/vendor/**',
+ '**/rector/**', // Disable this line to test the "test.php" file.
__DIR__ . '/../../../htdocs/custom/',
__DIR__ . '/../../../htdocs/install/doctemplates/*'
]);
@@ -39,15 +42,33 @@ return static function (RectorConfig $rectorConfig): void {
//$rectorConfig->rule(Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
//$rectorConfig->rule(Rector\Php72\Rector\Assign\ListEachRector::class);
//$rectorConfig->rule(Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
- //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
//$rectorConfig->rule(Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
+ //$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
+
+ $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class);
+ $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class);
+ $rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
+ //$rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class);
+ $rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
+
$rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class);
$rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class);
$rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class);
- // Add all predefined rules to migrate to up to php 71
- // $rectorConfig->sets([
- // LevelSetList::UP_TO_PHP_71
- // ]);
+ // Add all predefined rules to migrate to up to php 71.
+ // Warning this break tab spacing of arrays on several lines
+ /*$rectorConfig->sets([
+ LevelSetList::UP_TO_PHP_70
+ ]);*/
+ // Add predefined rules for a given version only
+ //$rectorConfig->import(SetList::PHP_70);
+ //$rectorConfig->import(SetList::PHP_71);
+ //$rectorConfig->import(SetList::PHP_72);
+ //$rectorConfig->import(SetList::PHP_73);
+ //$rectorConfig->import(SetList::PHP_74);
+ //$rectorConfig->import(SetList::PHP_80);
+ //$rectorConfig->import(SetList::PHP_81);
+ //$rectorConfig->import(SetList::PHP_82);
+ //$rectorConfig->import(SetList::PHP_83);
};
diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php
index 656a7d4ff59..ea5b2718f8c 100644
--- a/dev/tools/rector/src/Renaming/GlobalToFunction.php
+++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php
@@ -4,6 +4,7 @@ namespace Dolibarr\Rector\Renaming;
use PhpParser\Node;
use PhpParser\Node\Arg;
+use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Expr\BinaryOp\Concat;
@@ -12,6 +13,7 @@ use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\Empty_;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Isset_;
+use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
@@ -72,7 +74,7 @@ class GlobalToFunction extends AbstractRector
*/
public function getNodeTypes(): array
{
- return [FuncCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class];
+ return [FuncCall::class, MethodCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayItem::class, ArrayDimFetch::class];
}
/**
@@ -84,6 +86,23 @@ class GlobalToFunction extends AbstractRector
*/
public function refactor(Node $node)
{
+ if ($node instanceof Node\Expr\ArrayItem) {
+ if (!isset($node->key)) {
+ return;
+ }
+ if ($this->isGlobalVar($node->value)) {
+ $constName = $this->getConstName($node->value);
+ if (empty($constName)) {
+ return;
+ }
+ $node->value = new FuncCall(
+ new Name('getDolGlobalString'),
+ [new Arg($constName)]
+ );
+ }
+ return $node;
+ }
+
if ($node instanceof Node\Expr\ArrayDimFetch) {
if (!isset($node->dim)) {
return;
@@ -103,7 +122,9 @@ class GlobalToFunction extends AbstractRector
if ($node instanceof FuncCall) {
$tmpfunctionname = $this->getName($node);
- if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) {
+ // If function is ok. We must avoid a lot of cases like isset(), empty()
+ if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'dol_hash', 'make_substitutions', 'min', 'max', 'explode'))) {
+ //print "tmpfunctionname=".$tmpfunctionname."\n";
$args = $node->getArgs();
$nbofparam = count($args);
@@ -129,6 +150,37 @@ class GlobalToFunction extends AbstractRector
return $node;
}
+ if ($node instanceof MethodCall) {
+ $tmpmethodname = $this->getName($node->name);
+ // If function is ok. We must avoid a lot of cases
+ if (in_array($tmpmethodname, array('idate'))) {
+ //print "tmpmethodname=".$tmpmethodname."\n";
+ $expr = $node->var;
+ $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 ($this->isGlobalVar($arg->value)) {
+ $constName = $this->getConstName($arg->value);
+ if (empty($constName)) {
+ return;
+ }
+ $a = new FuncCall(new Name('getDolGlobalString'), [new Arg($constName)]);
+ $tmpargs[$key] = new Arg($a);
+
+ $r = new MethodCall($expr, $tmpmethodname, $tmpargs);
+ return $r;
+ }
+ }
+ }
+ }
+ return $node;
+ }
+
if ($node instanceof Concat) {
if ($this->isGlobalVar($node->left)) {
$constName = $this->getConstName($node->left);
diff --git a/dev/tools/spider.php b/dev/tools/spider.php
deleted file mode 100644
index 28871122e2c..00000000000
--- a/dev/tools/spider.php
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/env php
-.
- */
-
-/**
- * \file dev/tools/spider.php
- * \brief Script to spider Dolibarr app.
- *
- * To use it:
- * - Disable module "bookmark"
- * - Exclude param optioncss, token, sortfield, sortorder
- */
-
-$crawledLinks = array();
-const MAX_DEPTH = 2;
-
-
-/**
- * @param string $url URL
- * @param string $depth Depth
- * @return string String
- */
-function followLink($url, $depth = 0)
-{
- global $crawledLinks;
- $crawling = array();
- if ($depth > MAX_DEPTH) {
- echo "
';
}
} else {
dol_print_error($db);
@@ -738,11 +740,10 @@ $db->close();
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
* @return void
*/
-function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context = '')
+function fieldListAccountModel($fieldlist, $obj = null, $tabname = '', $context = '')
{
- global $conf, $langs, $db;
+ global $langs, $db;
global $form;
- global $region_id;
global $elementList, $sourceList;
$formadmin = new FormAdmin($db);
@@ -784,21 +785,14 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
print '
';
+ }
}
/**
* Return version
*
- * @return string Version
+ * @return string Version
*/
public function getVersion()
{
@@ -222,9 +279,9 @@ class PrestaShopWebservice
/**
* Load XML from string. Can throw exception
*
- * @param string $response String from a CURL response
- * @return SimpleXMLElement|boolean status_code, response
+ * @param string $response String from a CURL response
*
+ * @return SimpleXMLElement status_code, response
* @throws PrestaShopWebserviceException
*/
protected function parseXML($response)
@@ -232,14 +289,17 @@ class PrestaShopWebservice
if ($response != '') {
libxml_clear_errors();
libxml_use_internal_errors(true);
- if (!function_exists('simplexml_load_string')) {
- throw new PrestaShopWebserviceException('Method simplexml_load_string not available. Your PHP does not support xml.');
+ if (LIBXML_VERSION < 20900) {
+ // Avoid load of external entities (security problem).
+ // Required only if LIBXML_VERSION < 20900
+ libxml_disable_entity_loader(true);
}
- $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
+
+ $xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
if (libxml_get_errors()) {
$msg = var_export(libxml_get_errors(), true);
libxml_clear_errors();
- throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg);
+ throw new PrestaShopWebserviceException('HTTP XML response is not parsable: ' . $msg);
}
return $xml;
} else {
@@ -254,62 +314,62 @@ class PrestaShopWebservice
* 'postXml' => Full XML string to add resource
- * 'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)
+ * 'url' => Full URL for a GET request of Webservice (ex: https://mystore.com/api/customers/1/)
* OR
* 'resource' => Resource name,
* 'id' => ID of a resource you want to get
+ * 'resource' => Resource name
+ * 'id' => ID or array which contains IDs of a resource(s) you want to delete
+ *
+ * delete(array('resource' => 'orders', 'id' => 1));
+ * // Following code will not be executed if an exception is thrown.
+ * echo 'Successfully deleted.';
+ * }
+ * catch (PrestaShopWebserviceException $ex)
+ * {
+ * echo 'Error : '.$ex->getMessage();
+ * }
+ * ?>
+ *
+ *
+ * @param array $options Array representing resource to delete.
+ *
+ * @return bool
+ * @throws PrestaShopWebserviceException
+ */
+ public function delete($options)
+ {
+ if (isset($options['url'])) {
+ $url = $options['url'];
+ } elseif (isset($options['resource']) && isset($options['id'])) {
+ $url = (is_array($options['id']))
+ ? $this->url . '/api/' . $options['resource'] . '/?id=[' . implode(',', $options['id']) . ']'
+ : $this->url . '/api/' . $options['resource'] . '/' . $options['id'];
+ } else {
+ throw new PrestaShopWebserviceException('Bad parameters given');
+ }
+
+ if (isset($options['id_shop'])) {
+ $url .= '&id_shop=' . $options['id_shop'];
+ }
+ if (isset($options['id_group_shop'])) {
+ $url .= '&id_group_shop=' . $options['id_group_shop'];
+ }
+
+ $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
+ $this->checkStatusCode($request);// check the response validity
+ return true;
+ }
}
/**
diff --git a/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md b/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md
new file mode 100644
index 00000000000..0dbd9d23112
--- /dev/null
+++ b/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md
@@ -0,0 +1,53 @@
+# Open Software License v. 3.0 (OSL-3.0)
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+1) **Grant of Copyright License.** Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+a) to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+c) to distribute or communicate copies of the Original Work and Derivative Works to the public, _with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License_;
+
+d) to perform the Original Work publicly; and
+
+e) to display the Original Work publicly.
+
+2) **Grant** of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+3) **Grant** of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+4) **Exclusions From License Grant.** Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2\. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+5) **External Deployment.** The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+6) **Attribution Rights.** You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+7) **Warranty of Provenance and Disclaimer of Warranty.** Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+8) **Limitation of Liability.** Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+9) **Acceptance and Termination.** If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+10) **Termination for Patent Action.** This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+11) **Jurisdiction, Venue and Governing Law.** Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+12) **Attorneys' Fees.** In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+13) **Miscellaneous.** If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+14) **Definition of "You" in This License.** "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+15) **Right to Use.** You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+16) **Modification of This License.** This License is Copyright (c) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
+
+[A brief explanation of this license is available][0].
+
+
+[0]: http://rosenlaw.com/OSL3.0-explained.htm
+
diff --git a/htdocs/admin/dolistore/class/README.md b/htdocs/admin/dolistore/class/README.md
new file mode 100644
index 00000000000..b0f57af00e7
--- /dev/null
+++ b/htdocs/admin/dolistore/class/README.md
@@ -0,0 +1,12 @@
+# PrestaShop-webservice-lib
+
+Source updated from:
+
+https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/PSWebServiceLibrary.php
+
+## Compatibility analysis
+
+https://www.gnu.org/licenses/license-list.html#OSL
+
+
+
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index c9991c07a38..7e1b74e336e 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -154,7 +154,7 @@ if ($action == 'updateMask') {
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
- if ($conf->global->$constforval == "$value") {
+ if (getDolGlobalString($constforval) == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
@@ -279,7 +279,7 @@ if ($action == 'edit') {
print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
} elseif ($val['type'] == 'product') {
if (isModEnabled("product") || isModEnabled("service")) {
- $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+ $selected = getDolGlobalString($constname);
$form->select_produits($selected, $constname, '', 0);
}
} else {
diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php
index fef00036cc2..afdeca4b7b2 100644
--- a/htdocs/admin/events.php
+++ b/htdocs/admin/events.php
@@ -122,7 +122,7 @@ foreach ($eventstolog as $key => $arr) {
print '