** Description changed:

  Version of Mahara: 20.04
  Step to reproduce:
  - User create group and then add a public page.
  - Other user add this page to watchlist
  - User create some new blocks
  - User delete a block
  User/administration cannot delete group/page/portfolio and show error:
  
  Mahara: Site unavailable
  A nonrecoverable error occurred. This probably means you have encountered a 
bug in the system
+ 
+ In this following function, I see that when group/page/portfolio is
+ deleted, the records in watchlist_queue table are deleted by comparing
+ block id. It means the null records never be deleted and causing error.
+ 
+ function watchlist_block_deleted(BlockInstance $block) {
+     global $USER;
+ 
+     // don't catch root's changes, especially not when installing...
+     if ($USER->get('id') <= 0) {
+         return;
+     }
+ 
+     delete_records('watchlist_queue', 'block', $block->get('id'));
+ 
+     if (record_exists('usr_watchlist_view', 'view', $block->get('view'))) {
+         $whereobj = new stdClass();
+         $whereobj->view = $block->get('view');
+         $whereobj->block = null;
+         $whereobj->usr = $USER->get('id');
+         $dataobj = clone $whereobj;
+         $dataobj->changed_on = date('Y-m-d H:i:s');
+         ensure_record_exists('watchlist_queue', $whereobj, $dataobj);
+     }
+ }

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: mahara-contributors
https://bugs.launchpad.net/bugs/1931879

Title:
  Null block records in watchlist_queue causing cannot delete group

Status in Mahara:
  New

Bug description:
  Version of Mahara: 20.04
  Step to reproduce:
  - User create group and then add a public page.
  - Other user add this page to watchlist
  - User create some new blocks
  - User delete a block
  User/administration cannot delete group/page/portfolio and show error:

  Mahara: Site unavailable
  A nonrecoverable error occurred. This probably means you have encountered a 
bug in the system

  In this following function, I see that when group/page/portfolio is
  deleted, the records in watchlist_queue table are deleted by comparing
  block id. It means the null records never be deleted and causing
  error.

  function watchlist_block_deleted(BlockInstance $block) {
      global $USER;

      // don't catch root's changes, especially not when installing...
      if ($USER->get('id') <= 0) {
          return;
      }

      delete_records('watchlist_queue', 'block', $block->get('id'));

      if (record_exists('usr_watchlist_view', 'view', $block->get('view'))) {
          $whereobj = new stdClass();
          $whereobj->view = $block->get('view');
          $whereobj->block = null;
          $whereobj->usr = $USER->get('id');
          $dataobj = clone $whereobj;
          $dataobj->changed_on = date('Y-m-d H:i:s');
          ensure_record_exists('watchlist_queue', $whereobj, $dataobj);
      }
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1931879/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to