Problem with deleting a plan task

Bug #1850559 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned
19.10
Fix Released
Medium
Unassigned

Bug Description

Error message when I wanted to delete a group plan that had 1 task

[WAR] 98 (artefact/plans/tools/PlansTools.php:691) Trying to get property 'plugin' of non-object
Call stack (most recent first):

    log_message("Trying to get property 'plugin' of non-object", 8, true, true, "/home/kristina/code/1910stable/htdocs/artefact/pla...", 691) at /home/kristina/code/1910stable/htdocs/lib/errors.php:521
    error(8, "Trying to get property 'plugin' of non-object", "/home/kristina/code/1910stable/htdocs/artefact/pla...", 691, array(size 8)) at /home/kristina/code/1910stable/htdocs/artefact/plans/tools/PlansTools.php:691
    artefact\plans\tools\PlansTools::deleteViewAndAssignedArtefacts(object(View)) at /home/kristina/code/1910stable/htdocs/artefact/plans/lib.php:1009
    ArtefactTypeTask->delete() at /home/kristina/code/1910stable/htdocs/artefact/lib.php:722
    ArtefactType->delete() at /home/kristina/code/1910stable/htdocs/artefact/plans/lib.php:319
    ArtefactTypePlan->delete() at /home/kristina/code/1910stable/htdocs/artefact/plans/plan/delete.php:94
    deleteplanform_submit(object(Pieform), array(size 2)) at /home/kristina/code/1910stable/htdocs/lib/pieforms/pieform.php:546
    Pieform->__construct(array(size 6)) at /home/kristina/code/1910stable/htdocs/lib/pieforms/pieform.php:168
    Pieform::process(array(size 6)) at /home/kristina/code/1910stable/htdocs/lib/mahara.php:5432
    pieform(array(size 6)) at /home/kristina/code/1910stable/htdocs/artefact/plans/plan/delete.php:80

[WAR] 98 (artefact/plans/tools/PlansTools.php:692) Trying to get property 'artefacttype' of non-object
Call stack (most recent first):

    log_message("Trying to get property 'artefacttype' of non-objec...", 8, true, true, "/home/kristina/code/1910stable/htdocs/artefact/pla...", 692) at /home/kristina/code/1910stable/htdocs/lib/errors.php:521
    error(8, "Trying to get property 'artefacttype' of non-objec...", "/home/kristina/code/1910stable/htdocs/artefact/pla...", 692, array(size 8)) at /home/kristina/code/1910stable/htdocs/artefact/plans/tools/PlansTools.php:692
    artefact\plans\tools\PlansTools::deleteViewAndAssignedArtefacts(object(View)) at /home/kristina/code/1910stable/htdocs/artefact/plans/lib.php:1009
    ArtefactTypeTask->delete() at /home/kristina/code/1910stable/htdocs/artefact/lib.php:722
    ArtefactType->delete() at /home/kristina/code/1910stable/htdocs/artefact/plans/lib.php:319
    ArtefactTypePlan->delete() at /home/kristina/code/1910stable/htdocs/artefact/plans/plan/delete.php:94
    deleteplanform_submit(object(Pieform), array(size 2)) at /home/kristina/code/1910stable/htdocs/lib/pieforms/pieform.php:546
    Pieform->__construct(array(size 6)) at /home/kristina/code/1910stable/htdocs/lib/pieforms/pieform.php:168
    Pieform::process(array(size 6)) at /home/kristina/code/1910stable/htdocs/lib/mahara.php:5432
    pieform(array(size 6)) at /home/kristina/code/1910stable/htdocs/artefact/plans/plan/delete.php:80

[WAR] 98 (lib/errors.php:536) [Error]: Cannot instantiate abstract class ArtefactType
Call stack (most recent first):

    exception(object(Error)) at Unknown:0

Robert Lyon (robertl-9)
Changed in mahara:
status: New → In Progress
importance: Undecided → Medium
milestone: none → 19.10.0
Changed in mahara:
milestone: 19.10.0 → 19.10.1
Revision history for this message
Robert Lyon (robertl-9) wrote :
Revision history for this message
Robert Lyon (robertl-9) wrote :

Steps to reproduce:

1) new install then log in as admin user
2) Go to create -> files and create a folder called "Animals"
3) go into this folder and create a folder called "Cats"
4) go into that folder and add some images of cats (find some in the Internet)
5) Go to create -> pages and collections and create a page called "Test outcome"
6) Edit the page and add:
- a 'folder' block to the page and select the folder "Cats" to display
- an 'image' block to the page and select one of the images in the "cats" folder
7) Go to create -> Plans and create a plan called 'Test outcome plan' and have 'Template' and 'Assignment tasks' turned on (set to 'Yes')
8) Create a task called "Test outcome plan task" and under 'Assign portfolio' choose the page you created in step 5
9) Create a group called "Test group"
10) Choose 'Plans' in group's menu bar and click 'new plan'
11) Click the 'From template' button and choose the plan created in step 7 and save
12) You should see a page with title: Plan 'Test outcome plan' tasks | Test group
13) Delete the task - see the error

Revision history for this message
Robert Lyon (robertl-9) wrote :

I believe this is happening because in htdocs/artefact/plans/tools/PlansTools.php the function deleteViewAndAssignedArtefacts() sets up an array of artefacts to delete then loops thru them to see if they have a parent. If they have a parent then they go into a parentIdChildInstancesArray array and are deleted there. But if the artefacts parent also has a parent then we can end up in this situation:

Home
|_ Animals
   |_ Cats
      |_ tiger.jpg

Where the loop deletes the 'Cats' folder before trying to delete the 'tiger.jpg' but can't as the folder is gone already.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/10501
Committed: https://git.mahara.org/mahara/mahara/commit/b2a216f260468bf9c55778eb4943633f98c7daa2
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit b2a216f260468bf9c55778eb4943633f98c7daa2
Author: Robert Lyon <email address hidden>
Date: Wed Oct 30 08:28:01 2019 +1300

Bug 1850559: Error deleting plan with task

Error message when I wanted to delete a group plan that had 1 task

[WAR] 98 (artefact/plans/tools/PlansTools.php:691) Trying to get
property 'plugin' of non-object

behatnotneeded

Change-Id: I18b573762466bb7e7dd0dcf1e99f11a910acdacd
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "19.10_STABLE" branch: https://reviews.mahara.org/10788

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/10788
Committed: https://git.mahara.org/mahara/mahara/commit/cd3303db37d581e51d544546bffe70a1f1e54aca
Submitter: Robert Lyon (<email address hidden>)
Branch: 19.10_STABLE

commit cd3303db37d581e51d544546bffe70a1f1e54aca
Author: Robert Lyon <email address hidden>
Date: Wed Oct 30 08:28:01 2019 +1300

Bug 1850559: Error deleting plan with task

Error message when I wanted to delete a group plan that had 1 task

[WAR] 98 (artefact/plans/tools/PlansTools.php:691) Trying to get
property 'plugin' of non-object

behatnotneeded

Change-Id: I18b573762466bb7e7dd0dcf1e99f11a910acdacd
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit b2a216f260468bf9c55778eb4943633f98c7daa2)

Revision history for this message
Rangi Daymond (rangid) wrote :

- Code/Gerrit: https://reviews.mahara.org/#/c/10501/ Patch set 7
- Browser: Chrome; browser testing not required.
- Theme: Raw; theme testing not required.

Pre-conditions:
a. Log in as site admin.
b. Go to 'Create' > 'Files' and
   - create a folder called 'animals'
   - in 'animals' create a folder called 'cats'
   - in 'cats' add some images files.
c. Go to 'Create' > 'Pages and collections' and create a page called 'Test page' with
   - a 'folder' block and select the folder 'cats' to display
   - an 'image' block and select one of the images in the 'cats' folder.
d. Go to 'Create' > 'Plans' and create a plan called 'Base plan', set 'template' and 'Assignment tasks' to 'Yes'.
e. In 'Base plan' create a task called 'Base plan - task 1' and under 'Assignment portfolio' choose 'Test page'.

Test scenario 1: Delete a task without making changes to the associated portfolio page.
Test steps:
1) Create a group called 'Group1'.
2) Choose 'Plans' in the group's menu bar and click 'New plan'.
3) Click the 'From template' button and choose 'Base plan' then save.
4) Click the 'Delete' button to delete 'Base plan - task 1' and click 'Delete plan' to confirm the delete action.
Expected results:
    - ✔ the error message no longer displays,
    - ✔ the first and only task 'Base plan - task 1' is removed.
5) Choose 'Files' in the group's menu bar then choose the 'viewfiles' folder.
Expected result: ✔ You should see a sub-folder that contains only a 'Parent folder' link.

Test scenario 2: Delete a task after having made changes to the associated portfolio page.
Test steps:
1) Create a group called 'Group2'.
2) Choose 'Plans' in the group's menu bar and click 'New plan'.
3) Click the 'From template' button
   - choose 'Base plan',
   - update the 'Title' to 'Group2 Test Plan'
   - save.
4) Click the displayed task's 'Open portfolio' icon
   - click 'Display page'
   - click 'Edit' and add a text block to the page, display the change.
5) Select 'Main menu' > 'Engage' > 'Groups
   - select Group2
   - click on the 'Plans' menu option
   - click on 'Group2 Test Plan'.
6) Click the 'Delete' button to delete 'Base plan - task 1' then click the 'Delete plan' button to confirm the delete action.
Expected results:
    - ✔ the error message no longer displays,
    - ✔ the first and only task 'Base plan - task 1' is removed.
7) Choose 'Files' in the group's menu bar then choose the 'viewfiles' folder.
Expected result: You should see
    - ✔ a 'Parent folder' link
    - ✔ a numbered folder with description 'Files copied from Test Page' containing the files & structure of pre-condition c.

Changed in mahara:
status: Fix Committed → Fix Released
no longer affects: mahara/20.04
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.