#1 2016-05-27 10:20:36

epescol
Member
Registered: 2012-05-27
Posts: 86

Pages and articles of deleted menu are still in the DB

If I delete a entire menu, related pages and articles are not deleted in the database :-(

Offline

#2 2016-05-27 21:24:48

adaliszk
Ionize Friend
From: Germany
Registered: 2010-09-20
Posts: 397
Website

Re: Pages and articles of deleted menu are still in the DB

Is that a real problem? Because you could accidentally delete a menu too. In the code in this case the system will delete the menu connections but not the content, so I guess the system was directley made that way.

On the Administration dashboard you should see an aditional tab in the content panel where you can find the unattached pages and articles, so you can reattach to a new layout.


Webdeveloper, Programmer, Application developer, Ionize friend
@adaliszk

Offline

#3 2016-05-28 09:01:21

epescol
Member
Registered: 2012-05-27
Posts: 86

Re: Pages and articles of deleted menu are still in the DB

Thank you adamos42 for reply,
It is not a big problem but only to maintain the database clean.

In the "Orphan articles" tab in the dashbord are only listed articles of pages of availables menus.

Pages and articles of deleted menus ar still in the database table and listed nowhere in the admin interface.

Also the "System Diagnosis Tool" dont clean the database.

To remove (menu table) orphan data I have executed this SQL

DELETE from page WHERE id_menu NOT IN (SELECT id_menu FROM menu);
DELETE from page_tag WHERE id_page NOT IN (SELECT id_page FROM page);
DELETE from page_media WHERE id_page NOT IN (SELECT id_page FROM page);
DELETE from page_lang WHERE id_page NOT IN (SELECT id_page FROM page);
DELETE from page_category WHERE id_page NOT IN (SELECT id_page FROM page);
DELETE from page_article WHERE id_page NOT IN (SELECT id_page FROM page);

To avoid in the future to have (menu table) orphan data I have alter the database:

1. Alter the table `menu` to allow to enter a constraint for the `page` table

ALTER TABLE `menu` CHANGE `id_menu` `id_menu` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;

2.Add some constraints to delete orphans records in case of menu deletion

ALTER TABLE `page` ADD CONSTRAINT `page_ibfk_1` FOREIGN KEY (`id_menu`) REFERENCES `databasename`.`menu` (`id_menu`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `page_tag` ADD CONSTRAINT `page_tag_ibfk_1` FOREIGN KEY (`id_page`) REFERENCES `databasename`.`page` (`id_page`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `page_media` ADD CONSTRAINT `page_media_ibfk_1` FOREIGN KEY (`id_page`) REFERENCES `databasename`.`page` (`id_page`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `page_lang` ADD CONSTRAINT `page_lang_ibfk_1` FOREIGN KEY (`id_page`) REFERENCES `databasename`.`page` (`id_page`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `page_category` ADD CONSTRAINT `page_category_ibfk_1` FOREIGN KEY (`id_page`) REFERENCES `databasename`.`page` (`id_page`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `page_article` ADD CONSTRAINT `page_article_ibfk_1` FOREIGN KEY (`id_page`) REFERENCES `databasename`.`page` (`id_page`) ON DELETE CASCADE ON UPDATE NO ACTION;

After the SQL execution, articles of deleted menus/pages are still available as orphan articles in the database

Last edited by epescol (2016-05-28 12:12:20)

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations