You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2019-07-10 09:41:21

grajek
Member
Registered: 2015-03-16
Posts: 72

9.4.3 recurrent ticket is not created when periodicity is hours/days

Hello!
After upgrade from 9.1.6 and MySql to MariaDB I had a problem with recurrent tickets that weren't created when periodicity was set to hour or days. It didn't come up in tests, because first occurence did show up, problem was with next occurrences. After investigation I found out that in database glpi_ticketrecurrents.next_creation_date field was not being set. Updating this field manually triggered ticket creation, but only once. After inserting some debug lines in inc/ticketrecurrent.class.php I found out that method computeNextCreationDate() was failing periodicity check:

      
343      if (!is_int($periodicity) && !preg_match($periodicity_pattern, $periodicity)) {
344         // Invalid periodicity.
345         return 'NULL';
346      }

The culprit is is_int() function, that checks if variable is of type int, which is not - it's a string containing valid int.
After replacing it with is_number() everything went back to normal smile


GLPI 9.5.1 CentOS

Offline

#2 2019-07-13 14:58:53

Langundo
Member
Registered: 2016-07-21
Posts: 71

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Hello grajek,
thank for your work to find the bug.
Have trouble with my recurrent tickets too. So I decide to use your solution but then I edit recurrent tickets or start automatic action ticketcurrent the web IF hangs (shows a blank page)
After a little try and error I found that the (!is_string($periodicity) seems to work for me.
But I'm not fit in php so maybe you (or someone else) can have a look at this.

Thanks. wink


Debian 11.7 - PHP 7.4.33 - MariaDB 10.5.19 - 10.0.8-dev

Offline

#3 2019-07-13 22:28:12

grajek
Member
Registered: 2015-03-16
Posts: 72

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Oh, you're right, I made a mistake in function name writing this post. Correct function name is: is_numeric() . Sorry.


GLPI 9.5.1 CentOS

Offline

#4 2019-07-15 13:28:48

Langundo
Member
Registered: 2016-07-21
Posts: 71

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Have edit the function.

After update to 9.4.3 the ticketrecurrent works (as you wrote) one time. So i didn't think there is a problem with glpi and was loocking for some mismatch configs in my settings.
Never I had the idea to look in database.

So I have to say well done and thank you again ;-)


Debian 11.7 - PHP 7.4.33 - MariaDB 10.5.19 - 10.0.8-dev

Offline

#5 2019-11-19 08:32:44

alientm
Member
Registered: 2014-07-07
Posts: 50

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

I also have problems with the recurrent ticket version 9.4.4.

I have several recurrent tickets that should be repeated every 1 month, since version 9.4.3 it will not work correctly for me.


GLPI 9.4.4 + FusionInventory 9.4+1.1 on Ubuntu 18.04

Offline

#6 2019-11-19 21:31:39

Langundo
Member
Registered: 2016-07-21
Posts: 71

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Hello alientm,

because some changes in my work actually I don't work with glpi ;-(
Only "play" a little with the 9.5 at home. As I can see this little bug is still present in 9.5.

Did you have made the little changes in inc/ticketrecurrent.class.php?
Pls edit the line 343 as described.


Debian 11.7 - PHP 7.4.33 - MariaDB 10.5.19 - 10.0.8-dev

Offline

#7 2019-11-21 08:47:34

alientm
Member
Registered: 2014-07-07
Posts: 50

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Should be:
is_number()
or
is_numeric()
in place of is_int() ?


GLPI 9.4.4 + FusionInventory 9.4+1.1 on Ubuntu 18.04

Offline

#8 2019-12-05 13:34:32

alientm
Member
Registered: 2014-07-07
Posts: 50

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Any help ?


GLPI 9.4.4 + FusionInventory 9.4+1.1 on Ubuntu 18.04

Offline

#9 2020-01-15 17:02:52

Phorta
Member
Registered: 2018-08-02
Posts: 16

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

Langundo wrote:

Hello alientm,

because some changes in my work actually I don't work with glpi ;-(
Only "play" a little with the 9.5 at home. As I can see this little bug is still present in 9.5.

Did you have made the little changes in inc/ticketrecurrent.class.php?
Pls edit the line 343 as described.

hello guys,
I'm using GLPI 9.4.4 with MariaDB.
and I am exactly with the same problem, during testing the recurring tickets worked, but in production the date is not respected ...

I tried to fix the problem as described above, but in my version it is a little different and I am not php programmer, could they help me ?
@Lagundo and @grajek



below I copied the contents of line 343 to 365 of the file inc/ticketrecurrent.class.php

if ($periodicity <> 0) {
         // Standard time computation
         $timestart  = strtotime($begin_date) - $create_before;
         $now        = time();
         if ($now > $timestart) {
            $value = $periodicity;
            $step  = "second";
            if (preg_match('/([0-9]+)MONTH/', $periodicity, $matches)) {
               $value = $matches[1];
               $step  = 'MONTH';
            } else if (preg_match('/([0-9]+)YEAR/', $periodicity, $matches)) {
               $value = $matches[1];
               $step  = 'YEAR';
            } else {
               if (($value%DAY_TIMESTAMP)==0) {
                  $value = $value/DAY_TIMESTAMP;
                  $step  = "DAY";
               } else {
                  $value = $value/HOUR_TIMESTAMP;
                  $step  = "HOUR";

Offline

#10 2020-01-16 13:44:11

alientm
Member
Registered: 2014-07-07
Posts: 50

Re: 9.4.3 recurrent ticket is not created when periodicity is hours/days

343 to 347 but code is from glpi

if (!is_string($periodicity) && !preg_match('/^\d+$/', $periodicity)
          && !preg_match($periodicity_pattern, $periodicity)) {
         // Invalid periodicity.
         return 'NULL';
      }

and work for me


GLPI 9.4.4 + FusionInventory 9.4+1.1 on Ubuntu 18.04

Offline

Board footer

Powered by FluxBB