From 2ac3b914cb8fec83b3cb8c7edb6b391dac5730b7 Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Sat, 20 Jan 2024 13:42:39 +0100 Subject: [PATCH 1/7] CRON: fetchAll->lines will return list of Cronjob object instead of Cronjobline object --- htdocs/cron/class/cronjob.class.php | 153 ++++++++-------------------- 1 file changed, 43 insertions(+), 110 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 833d0068e14..3db5fec5a65 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -559,6 +559,7 @@ class Cronjob extends CommonObject $sql .= " t.fk_user_mod,"; $sql .= " t.note as note_private,"; $sql .= " t.nbrun,"; + $sql .= " t.maxrun,"; $sql .= " t.libname,"; $sql .= " t.test"; $sql .= " FROM ".MAIN_DB_PREFIX."cronjob as t"; @@ -595,45 +596,46 @@ class Cronjob extends CommonObject if ($num) { while ($i < $num) { - $line = new Cronjobline(); - $obj = $this->db->fetch_object($resql); + $cronjob_obj = new Cronjob($this->db); - $line->id = $obj->rowid; - $line->ref = $obj->rowid; - $line->entity = $obj->entity; - $line->tms = $this->db->jdate($obj->tms); - $line->datec = $this->db->jdate($obj->datec); - $line->label = $obj->label; - $line->jobtype = $obj->jobtype; - $line->command = $obj->command; - $line->classesname = $obj->classesname; - $line->objectname = $obj->objectname; - $line->methodename = $obj->methodename; - $line->params = $obj->params; - $line->md5params = $obj->md5params; - $line->module_name = $obj->module_name; - $line->priority = $obj->priority; - $line->datelastrun = $this->db->jdate($obj->datelastrun); - $line->datenextrun = $this->db->jdate($obj->datenextrun); - $line->dateend = $this->db->jdate($obj->dateend); - $line->datestart = $this->db->jdate($obj->datestart); - $line->lastresult = $obj->lastresult; - $line->datelastresult = $this->db->jdate($obj->datelastresult); - $line->lastoutput = $obj->lastoutput; - $line->unitfrequency = $obj->unitfrequency; - $line->frequency = $obj->frequency; - $line->status = $obj->status; - $line->processing = $obj->processing; - $line->pid = $obj->pid; - $line->email_alert = $obj->email_alert; - $line->fk_user_author = $obj->fk_user_author; - $line->fk_user_mod = $obj->fk_user_mod; - $line->note_private = $obj->note_private; - $line->nbrun = $obj->nbrun; - $line->libname = $obj->libname; - $line->test = $obj->test; - $this->lines[] = $line; + $cronjob_obj->id = $obj->rowid; + $cronjob_obj->ref = $obj->rowid; + $cronjob_obj->entity = $obj->entity; + $cronjob_obj->tms = $this->db->jdate($obj->tms); + $cronjob_obj->datec = $this->db->jdate($obj->datec); + $cronjob_obj->label = $obj->label; + $cronjob_obj->jobtype = $obj->jobtype; + $cronjob_obj->command = $obj->command; + $cronjob_obj->classesname = $obj->classesname; + $cronjob_obj->objectname = $obj->objectname; + $cronjob_obj->methodename = $obj->methodename; + $cronjob_obj->params = $obj->params; + $cronjob_obj->md5params = $obj->md5params; + $cronjob_obj->module_name = $obj->module_name; + $cronjob_obj->priority = $obj->priority; + $cronjob_obj->datelastrun = $this->db->jdate($obj->datelastrun); + $cronjob_obj->datenextrun = $this->db->jdate($obj->datenextrun); + $cronjob_obj->dateend = $this->db->jdate($obj->dateend); + $cronjob_obj->datestart = $this->db->jdate($obj->datestart); + $cronjob_obj->lastresult = $obj->lastresult; + $cronjob_obj->lastoutput = $obj->lastoutput; + $cronjob_obj->datelastresult = $this->db->jdate($obj->datelastresult); + $cronjob_obj->unitfrequency = $obj->unitfrequency; + $cronjob_obj->frequency = $obj->frequency; + $cronjob_obj->status = $obj->status; + $cronjob_obj->processing = $obj->processing; + $cronjob_obj->pid = $obj->pid; + $cronjob_obj->email_alert = $obj->email_alert; + $cronjob_obj->fk_user_author = $obj->fk_user_author; + $cronjob_obj->fk_user_mod = $obj->fk_user_mod; + $cronjob_obj->note_private = $obj->note_private; + $cronjob_obj->nbrun = $obj->nbrun; + $cronjob_obj->maxrun = $obj->maxrun; + $cronjob_obj->libname = $obj->libname; + $cronjob_obj->test = $obj->test; + + $this->lines[] = $cronjob_obj; $i++; } @@ -1324,7 +1326,7 @@ class Cronjob extends CommonObject $error++; } else { dol_syslog(get_class($this)."::run_jobs END"); - $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n").$errmsg, 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); + $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n"), 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); $this->lastresult = var_export($result, true); $retval = $this->lastresult; } @@ -1572,76 +1574,7 @@ class Cronjob extends CommonObject /** - * Crob Job line class + * Crob Job line class + * @TODO Deprecated, to delete very soon */ -class Cronjobline -{ - /** - * @var int ID - */ - public $id; - - public $entity; - - /** - * @var string Ref - */ - public $ref; - - public $tms = ''; - public $datec = ''; - - /** - * @var string Cron Job Line label - */ - public $label; - - public $jobtype; - public $command; - public $classesname; - public $objectname; - public $methodename; - public $params; - public $md5params; - public $module_name; - public $priority; - public $datelastrun = ''; - public $datenextrun = ''; - public $dateend = ''; - public $datestart = ''; - public $datelastresult = ''; - public $lastresult = ''; - public $lastoutput; - public $unitfrequency; - public $frequency; - public $processing; - - /** - * @var int Status - */ - public $status; - - /** - * @var int ID - */ - public $fk_user_author; - - /** - * @var int ID - */ - public $fk_user_mod; - - public $note; - public $note_private; - public $nbrun; - public $libname; - public $test; - - /** - * Constructor - * - */ - public function __construct() - { - } -} +class Cronjobline extends Cronjob {} From 0701d31325cc5bb393034ead90b4238df972fc66 Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Sat, 20 Jan 2024 14:03:56 +0100 Subject: [PATCH 2/7] Someone did a typo mistake --- htdocs/resource/class/dolresource.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index b835aefb480..e13889971df 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -374,7 +374,7 @@ class Dolresource extends CommonObject $error++; } } - }diction + } } if (!$error) { From 2f32ac6fe366ddf44859138f8a30051c4d531a74 Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Sat, 20 Jan 2024 14:16:14 +0100 Subject: [PATCH 3/7] Debug --- htdocs/cron/class/cronjob.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 3db5fec5a65..366ea4ee9f2 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1577,4 +1577,5 @@ class Cronjob extends CommonObject * Crob Job line class * @TODO Deprecated, to delete very soon */ -class Cronjobline extends Cronjob {} +class Cronjobline extends Cronjob +{} From c1c45a171a87d8a133f934f8b8851464b82ace17 Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Sat, 20 Jan 2024 14:23:17 +0100 Subject: [PATCH 4/7] Debug --- htdocs/cron/class/cronjob.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 366ea4ee9f2..ff917cc2634 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1578,4 +1578,5 @@ class Cronjob extends CommonObject * @TODO Deprecated, to delete very soon */ class Cronjobline extends Cronjob -{} +{ +} From 02da32736eb374b4d2693d0bd2647d4efce31701 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 20 Jan 2024 21:27:24 +0100 Subject: [PATCH 5/7] qual: phpstan htdocs/fourn/facture/card.php 763 Property CommonInvoice::$socid (int) does not accept array|string. --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 72f4b19f4f2..b0fd9dfe7d6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -760,7 +760,7 @@ if (empty($reshook)) { } elseif ($action == 'add' && $usercancreate) { // Insert new invoice in database if ($socid > 0) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); } $selectedLines = GETPOST('toselect', 'array'); From ef95c56ecd6eff8928dec9f1270864df4305f4fc Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 21 Jan 2024 13:37:53 +0100 Subject: [PATCH 6/7] Qual: Fix spelling. # Qual: Fix some spelling --- dev/setup/codesniffer/README | 5 ++--- htdocs/langs/en_US/mails.lang | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dev/setup/codesniffer/README b/dev/setup/codesniffer/README index 2fdc66b9d1f..940b8db182a 100644 --- a/dev/setup/codesniffer/README +++ b/dev/setup/codesniffer/README @@ -1,7 +1,7 @@ README (English) -------------------------------- -This directory contains ruleset files to use to develop Dolibarr EPR & CRM. +This directory contains ruleset files to use to develop Dolibarr ERP & CRM. To install/upgrade phpcs: > sudo pear upgrade PHP_CodeSniffer @@ -17,5 +17,4 @@ To fix with phpcbf: Note with Eclipse: You must setup the PTI plugin of Eclipse into PHPCodeSniffer menu with: * tab value to 4 -* path of code sniffer standard to dev/codesniffer - +* path of code sniffer standard to dev/codesniffer diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 1fd9a75f1b3..2de7dbbbdc3 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -185,4 +185,4 @@ EvenUnsubscribe=Include opt-out emails EvenUnsubscribeDesc=Include opt-out emails when you select emails as targets. Useful for mandatory service emails for example. XEmailsDoneYActionsDone=%s emails pre-qualified, %s emails successfully processed (for %s record/actions done) helpWithAi=Add instructions -YouCanMakeSomeInstructionForEmail=You Can Make Some Instruction For your Email (Exemple: generate image in email template...) \ No newline at end of file +YouCanMakeSomeInstructionForEmail=You can add some instructions for your email (Example: generate image in email template...) From 19ac1e4b02ca1f9471cc1c3158c348d3ff0d17c5 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 21 Jan 2024 15:04:33 +0100 Subject: [PATCH 7/7] Qual: Store phpstan cache only if not loaded or successful run The PHPStan steps run a long time for the latest runs and I suspect that this may be because of a bad cache, possibly includeing: ``` Result cache was not saved because of non-ignorable exception: Syntax error, unexpected } on line 378 ``` . This change should only save the cache if the run was successful or if no cache was loaded. The possibly preserves a cache that still reduces the run time. For instance, the following got an empty cache, saved at 2024-01-19T21:28:22.18Z. - https://github.com/Dolibarr/dolibarr/actions/runs/7589384926 That was an aborted run: - https://github.com/Dolibarr/dolibarr/actions/runs/7589372703/job/20673878193 So I added `cancelled()` to avoid overwriting valid cache and phpstan cache will only be written if the outcome was success or if the cache could not be loaded before. I also updated the version for the cache action. --- .github/workflows/phpstan.yml | 8 +++++--- .github/workflows/pre-commit.yml | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 8046f932357..117b91b9565 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -44,7 +44,8 @@ jobs: # Restore old cache - name: Restore phpstan cache - uses: actions/cache/restore@v3 + id: cache + uses: actions/cache/restore@v4 with: path: ./.github/tmp key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}" @@ -55,13 +56,14 @@ jobs: # Run PHPStan - name: Run PHPStan + id: phpstan run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -a build/phpstan/bootstrap_action.php -c phpstan.neon | cs2pr --graceful-warnings # continue-on-error: true # Save cache - name: "Save phpstan cache" - uses: actions/cache/save@v3 - if: always() + uses: actions/cache/save@v4 + if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }} with: path: ./.github/tmp key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index cffcb6ffcd9..7836dd5a487 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -27,7 +27,7 @@ jobs: python-version: '3.11' - run: python -m pip install pre-commit regex # Restore previous cache of precommit - - uses: actions/cache/restore@v3 + - uses: actions/cache/restore@v4 with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} @@ -54,8 +54,8 @@ jobs: notices-as-warnings: true # optional prepend-filename: true # optional # Save the precommit cache - - uses: actions/cache/save@v3 - if: ${{ always() }} + - uses: actions/cache/save@v4 + if: ${{ ! cancelled() }} with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') @@ -63,7 +63,7 @@ jobs: # Upload result log files of precommit into the Artifact shared store - name: Provide log as artifact uses: actions/upload-artifact@v4 - if: ${{ always() }} + if: ${{ ! cancelled() }} with: name: precommit-logs path: |