BUG in install

Re: BUG in install

by Motoyuki OHMORI -
Number of replies: 0

Hi,

It happened to me as well.
I changed the code because other problems seem to be there like:

 - When group table is empty, upgrading fails.
 - When group table is deleted, I cannot continue upgrading process.

I am not sure that my change is O.K. or not (mayby I should not have deleted the record) .
Anyway, here is patch I made:

Index: group/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/group/db/upgrade.php,v
retrieving revision 1.11
diff -c -r1.11 upgrade.php
*** group/db/upgrade.php        30 Jan 2007 05:09:49 -0000      1.11
--- group/db/upgrade.php        26 Feb 2007 18:37:33 -0000
***************
*** 157,163 ****
          $status = $status &&(bool)$members_r= get_records('groups_members_temp');

          if (! $groups_r) {
!             return $status;
          }
          foreach ($groups_r as $group) {
              if (debugging()) {
--- 157,171 ----
          $status = $status &&(bool)$members_r= get_records('groups_members_temp');

          if (! $groups_r) {
!             if (! $members_r) {
!                 /*
!                  * I think that this might occur when group table
!                  * is empty -- ohmori.
!                  */
!                 return true;
!             } else {
!                 return $status;
!             }
          }
          foreach ($groups_r as $group) {
              if (debugging()) {
***************
*** 276,281 ****
--- 284,291 ----
          foreach ($tables as $t_name) {
              $status = $status && drop_table(new XMLDBTable('groups'.$t_name));
          }
+         $status = $status &&
+             (bool)delete_records('log_display', 'module', 'group');

          if ($renametemp) {
              $status = $status && rename_table(new XMLDBTable('groups_temp'), 'groups');
***************
*** 410,415 ****
--- 420,431 ----
              $groupupgrade = optional_param('confirmgroupupgrade', 0, PARAM_BOOL);
              if (empty($groupupgrade)) {
                  notice_yesno(get_string('upgradeconfirm', 'group'), 'index.php?confirmgroupupgrade=yes', 'index.php');
+                 /*
+                  * This hack might be necessary when notice_yesno() is used.
+                  * I thinks that notice_yesno() should be changed to
+                  * take account for upgrading process. -- ohmori
+                  */
+                 $_SESSION['upgraderunning'] = 0;
                  //$feedback = false;
                  print_footer();
                  exit;