ColoredCow / ColoredCow/campaigns

Tool is letting us delete a list without checking associated campaigns - Throwing 500 error.

Open
#170 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The user can delete a list from the campaign UI including the campaigns which are associated with an existing(past campaign). Due to this, the system is throwing 500 error as the list associated with the campaigns are not anymore in the database after deletion.

**To Reproduce**
Steps to reproduce the behaviour:
1. Login to the campaign tool
2. Go to the List tab
3. Delete one list which is associated with any campaign in the past - The list should be deleted without any issue/warning.
4. Come back to the campaign page - The campaign page should be throwing fatal error `Trying to get property 'name' of non-object` due to this code snippet `$campaign->subscriptionList->name` - [Reference link to codebase](https://github.com/ColoredCow/campaigns/blob/6bed99b538673e043d3e60a093330123d24e13a4/resources/views/campaign/index.blade.php#L43)

**Expected behaviour**
- If the list is associated with an old campaign, the system should not let it deleted.
- There should be a warning/alert while deleting such a list from the campaign tool.

**Additional context**
1. Ideally, there should be a reference between the `campaigns` table and the `lists` table. However, it is being referenced in the codebase - [Codebase Reference](https://github.com/ColoredCow/campaigns/blob/6bed99b538673e043d3e60a093330123d24e13a4/app/Models/Campaign.php#L15)
2. The column name could have been simply `list_id` in `campaigns` table rather than `subscription_list_id`, which may create confusion.
image

**Acceptance Criteria**
- Add the foreign key constraint in the `campaigns` table for the `subscription_list_id` and add the `lists` table as a reference table for that.
- The system should not let us delete the list if it is associated with an old campaign.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with app/Models/Campaign.php and resources/views/campaign/index.blade.php, then inspect the migrations defining campaigns and lists and the list deletion entry point. Reproduce deletion of a list referenced by an old campaign, add the stated relationship protection and warning behavior, and verify the campaign page no longer throws the missing-name error.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.