From 0912b3b04f026f668a527cc99cbbc9ccf341752e Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Thu, 9 Jan 2025 15:04:37 +0100 Subject: [PATCH 1/4] 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 99d330b745aaf..0310ac0b22559 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1181,8 +1181,14 @@ function init_repeat() $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 2/4] 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 1ae4d3387f8fe..973b2ddbc1309 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 3/4] 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 973b2ddbc1309..d83f237e09c9f 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 4/4] 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 d83f237e09c9f..ddf13c8a0706c 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