From ce06c12da61d778e8004c98748cb6be0e137f51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Wed, 18 Dec 2024 11:19:56 +0100 Subject: [PATCH 1/6] FIX: GETPOST('private_message') --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 265a661448d..3ae08149626 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -458,7 +458,7 @@ if (empty($reshook)) { // Action to add a message (private or not, with email or not). // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { - $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); + $ret = $object->newMessage($user, $action, GETPOSTINT('private_message'), 0); if ($ret > 0) { if (!empty($backtopage)) { From b7cb799af0245ae3c5737a6bdd9589f9fc5eea7f Mon Sep 17 00:00:00 2001 From: Alexis Thietard Date: Mon, 6 Jan 2025 14:23:13 +0100 Subject: [PATCH 2/6] FIX #21294 Stock import sql query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To respect the PostgreSQL update statement syntax, cf. https://www.postgresql.org/docs/17/sql-update.html ``` column_name The name of a column in the table named by table_name. The column name can be qualified with a subfield name or array subscript, if needed. Do not include the table's name in the specification of a target column — for example, UPDATE table_name SET table_name.col = 1 is invalid. ``` Signed-off-by: Alexis Thietard --- htdocs/core/modules/modStock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e9e9ccc79a6..f7def03808c 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -429,7 +429,7 @@ class modStock extends DolibarrModules ); $this->import_updatekeys_array[$r] = array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse"); $this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE '.MAIN_DB_PREFIX.'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } From 0912b3b04f026f668a527cc99cbbc9ccf341752e Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Thu, 9 Jan 2025 15:04:37 +0100 Subject: [PATCH 3/6] fix selectcontacts param --- htdocs/comm/action/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 99d330b745a..0310ac0b225 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1181,8 +1181,14 @@ if ($action == 'create') { $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); } if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); + // select "all" or "none" contact by default + if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) { + $select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts + } else { + $select_contact_default = -1; // select "none" by default + } print img_picto('', 'contact', 'class="paddingrightonly"'); - print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; } From 9af7eaf08ccae30b58c010754db5f5b89e9ea3f0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:32:08 +0100 Subject: [PATCH 4/6] Use PHP version from check.php --- .github/workflows/pre-commit.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1ae4d3387f8..973b2ddbc13 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -62,6 +62,12 @@ jobs: # files: | # **.php + - name: Extract PHP version + id: extract-php-version + run: | + PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php) + echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV + - name: Setup PHPCS uses: shivammathur/setup-php@v2 # Install when we're going to run phpcs @@ -76,7 +82,7 @@ jobs: ) ) with: - php-version: 8.1 + php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov tools: phpcs From 7869e45954684977b0104d3ac6ade8293c52e919 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:39:05 +0100 Subject: [PATCH 5/6] Move installation of php before pre-commit run --- .github/workflows/pre-commit.yml | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 973b2ddbc13..d83f237e09c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -42,25 +42,6 @@ jobs: with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - # Run all the precommit tools (defined into pre-commit-config.yaml). - # We can force exclusion of some of them here. - - name: Run pre-commit hooks - env: - # SKIP is used by pre-commit to not execute certain hooks - SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck - run: | - set -o pipefail - pre-commit gc - pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} - - # The next uses git, which is slow for a bit repo. - # - name: Get all changed php files (if PR) - # id: changed-php - # uses: tj-actions/changed-files@v42 - # if: github.event_name == 'pull_request' - # with: - # files: | - # **.php - name: Extract PHP version id: extract-php-version @@ -86,6 +67,26 @@ jobs: coverage: none # disable xdebug, pcov tools: phpcs + # Run all the precommit tools (defined into pre-commit-config.yaml). + # We can force exclusion of some of them here. + - name: Run pre-commit hooks + env: + # SKIP is used by pre-commit to not execute certain hooks + SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer,check-json,check-executables-have-shebangs,check-shebang-scripts-are-executable,beautysh,yamllint,shellcheck + run: | + set -o pipefail + pre-commit gc + pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + + # The next uses git, which is slow for a bit repo. + # - name: Get all changed php files (if PR) + # id: changed-php + # uses: tj-actions/changed-files@v42 + # if: github.event_name == 'pull_request' + # with: + # files: | + # **.php + - name: Run some pre-commit hooks on selected changed files only if: steps.changed-php.outputs.any_changed == 'true' env: From 20f2293c013f27c29f557364148135e9ad0528ab Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 14 Jan 2025 15:43:55 +0100 Subject: [PATCH 6/6] Always install expected php version --- .github/workflows/pre-commit.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index d83f237e09c..ddf13c8a070 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -51,17 +51,7 @@ jobs: - name: Setup PHPCS uses: shivammathur/setup-php@v2 - # Install when we're going to run phpcs - if: | - steps.changed-php.outputs.any_changed == 'true' - || - ( - github.event_name == 'push' - && ( - github.event.ref == 'refs/heads/develop' - || endsWith(github.event.ref, '.0') - ) - ) + # Install proper php version, and also install phpcs which may be needed with: php-version: ${{ env.PHP_VERSION }} # Version from check.php coverage: none # disable xdebug, pcov