Skip to content

Add null check for $project in the template/starred-projects.php#19

Open
techu wants to merge 1 commit intobiblibre:masterfrom
techu:master
Open

Add null check for $project in the template/starred-projects.php#19
techu wants to merge 1 commit intobiblibre:masterfrom
techu:master

Conversation

@techu
Copy link
Copy Markdown

@techu techu commented Jul 29, 2024

This fixes an issue where if a starred project is deleted the dashboard "starred projects" listings shows error on the frontend.

This fixes an issue where if a starred project is deleted the dashboard "starred projects" listings shows error on the frontend.
@jajm
Copy link
Copy Markdown
Member

jajm commented Sep 23, 2024

Can you describe the steps needed to reproduce the issue ?
When a project is deleted the corresponding row in starred_projects table should be deleted thanks to the foreign key constraint so having null there should never happen.

@szjozsef
Copy link
Copy Markdown

szjozsef commented Apr 10, 2025

Can you describe the steps needed to reproduce the issue ? When a project is deleted the corresponding row in starred_projects table should be deleted thanks to the foreign key constraint so having null there should never happen.

Apparently this does not happening.

If a project is deleted the table entries in "starred_projects" table still remains and the users whom had the deleted project as favorite will receive errors like:
"Warning: trying to access array offset on null in .../starred-projects.php on line 11"
"Warning: trying to access array offset on null in .../starred-projects.php on line 14"
"Warning: trying to access array offset on null in .../starred-projects.php on line 18"
"Warning: trying to access array offset on null in .../starred-projects.php on line 26"
"Warning: trying to access array offset on null in .../starred-projects.php on line 29"

@jajm
Copy link
Copy Markdown
Member

jajm commented Jun 10, 2025

Which database engine are you using ? Can you show the CREATE TABLE statement for table starred_projects ?

@szjozsef
Copy link
Copy Markdown

szjozsef commented Jun 10, 2025

This is the case at least with DB postgresql:

CREATE TABLE IF NOT EXISTS public.starred_projects
(
    id integer NOT NULL DEFAULT nextval('starred_projects_id_seq'::regclass),
    user_id integer NOT NULL,
    project_id integer NOT NULL,
    CONSTRAINT starred_projects_pkey PRIMARY KEY (id),
    CONSTRAINT starred_projects_user_id_project_id_key UNIQUE (user_id, project_id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.starred_projects
    OWNER to kanboard;

To reproduce the issue, create a project, set it a starred project then delete the project

@jajm
Copy link
Copy Markdown
Member

jajm commented Jun 10, 2025

The foreign key constraints are not there. They should be.

Looking at the repository history, the first versions of the plugin did not have these foreign key constraints. They were added later but without an "upgrade path". So, assuming you are using the latest version of the plugin, I guess you started using an early version that did not have these constraints and upgraded from there.
You can try uninstalling the module (deleting the table starred_projects and removing the appropriate row from table plugin_schema_versions) and re-install it, or you can try adding manually the foreign key constraints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants