From d2f9d7634bb58cb0b8cd27a11ba35a137ce20554 Mon Sep 17 00:00:00 2001 From: Boris Hermans Date: Tue, 25 Jul 2023 23:24:11 +0200 Subject: [PATCH 1/7] Handle projects for the api documents listing route (#25465) --- htdocs/api/class/api_documents.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 6d89c8a01d0..cab81b80124 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -502,6 +502,17 @@ class Documents extends DolibarrApi // $upload_dir = $conf->ecm->dir_output; // $type = 'all'; // $recursive = 0; + } elseif ($modulepart == 'projet' || $modulepart == 'project') { + $modulepart = 'project'; + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + + $object = new Project($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Project not found'); + } + + $upload_dir = $conf->projet->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'project'); } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } @@ -628,7 +639,7 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $object = new CommandeFournisseur($this->db); - } elseif ($modulepart == 'project') { + } elseif ($modulepart == 'projet' || $modulepart == 'project') { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object = new Project($this->db); } elseif ($modulepart == 'task' || $modulepart == 'project_task') { From af8f6e32780ceb836e9d144640da4a268d30641d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jul 2023 23:31:46 +0200 Subject: [PATCH 2/7] Fix travis --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce5cba6c8be..a122627d094 100644 --- a/.travis.yml +++ b/.travis.yml @@ -374,8 +374,8 @@ script: - | echo "Upgrading Dolibarr" - # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. - set +e + # Ensure we catch errors with -e. Set this to +e if you want to go to the end to see log files. + set -e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log @@ -460,8 +460,8 @@ script: - | echo "Unit testing" - # Ensure we catch errors. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file. - set +e + # Ensure we catch errors with -e. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file. + set -e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php phpunitresult=$? echo "Phpunit return code = $phpunitresult" From 8e94ea05048086618989c999410e169e9056a5c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jul 2023 00:01:45 +0200 Subject: [PATCH 3/7] Fix warning --- htdocs/core/db/mysqli.class.php | 2 +- htdocs/core/db/pgsql.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index a05dbf46e4b..1eef38591b1 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -336,7 +336,7 @@ class DoliDBMysqli extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); - if ($conf->global->SYSLOG_LEVEL < LOG_DEBUG) { + if (empty($conf->global->SYSLOG_LEVEL) || $conf->global->SYSLOG_LEVEL < LOG_DEBUG) { dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); // Log of request was not yet done previously } dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterrno." ".$this->lasterror, LOG_ERR); diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index f4df72ceb26..e672cc833a3 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -559,7 +559,7 @@ class DoliDBPgsql extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); - if ($conf->global->SYSLOG_LEVEL < LOG_DEBUG) { + if (empty($conf->global->SYSLOG_LEVEL) || $conf->global->SYSLOG_LEVEL < LOG_DEBUG) { dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); // Log of request was not yet done previously } dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); From a536fbbc04b42f34bfac4ca3227e4ad21f4615ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jul 2023 00:15:59 +0200 Subject: [PATCH 4/7] Fix travis --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a122627d094..33403c11df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -129,7 +129,15 @@ install: - | echo "Update Composer version and Install tools - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" echo "(composer version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ]; then + sudo composer self-update 2.2.18 + composer -n require phpunit/phpunit ^6.0 \ + php-parallel-lint/php-parallel-lint ^1 \ + php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ + squizlabs/php_codesniffer ^3 + fi + if [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then sudo composer self-update 2.2.18 composer -n require phpunit/phpunit ^7.5 \ php-parallel-lint/php-parallel-lint ^1 \ From fd49ee919772011644e92325d8d8efd5941340d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jul 2023 00:56:08 +0200 Subject: [PATCH 5/7] Test travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 33403c11df2..d51887f5457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ services: addons: - mariadb: '10.4' + mariadb: '10.5' env: From 5b298ebf4a13c6834ff5db23565409f78304a773 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jul 2023 01:12:57 +0200 Subject: [PATCH 6/7] Test travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d51887f5457..6a2358dbfd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -383,7 +383,7 @@ script: - | echo "Upgrading Dolibarr" # Ensure we catch errors with -e. Set this to +e if you want to go to the end to see log files. - set -e + set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log From 981f803ad01f0d6e3d97571f4cf964db0c07eacf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jul 2023 01:26:02 +0200 Subject: [PATCH 7/7] Doc --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a2358dbfd4..eac04b41ab4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -383,6 +383,8 @@ script: - | echo "Upgrading Dolibarr" # Ensure we catch errors with -e. Set this to +e if you want to go to the end to see log files. + # Note: We keep +e because with pgsql, one of upgrade process fails even if migration seems ok, so + # I disable stop on error to be able to continue. set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log @@ -470,11 +472,13 @@ script: echo "Unit testing" # Ensure we catch errors with -e. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file. set -e - phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php - phpunitresult=$? - echo "Phpunit return code = $phpunitresult" + if [ "$TRAVIS_PHP_VERSION" != '7.0' ]; then + phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" + fi set +e - + after_script: - | echo "After script - Output last lines of dolibarr.log"