NO BUG: Class Relationships to Elements not Deleted when actual Class is Deleted in Bricks

Not a huge issue but just looking at it from the point of keeping the database clean and thinking of the up coming Global Class Manager.

I imported a template that had a group of elements (social icons) that I didn’t need so I deleted them along with the classes in the Bricks UI.

What I had forgotten is I had used this part of the template on another page so when I deleted the classes those elements lost their styling (which is what should have happened).

I soon discovered my mistake though so I imported the template again and the classes was restored.

I also discovered that the classes automatically appeared back onto the social icons from the other page that where missing them because of me deleting the classes.

While this worked out in my current situation I would think that when a class is deleted in the Bricks Interface all elements that also use that class would have their relationships to that class deleted. This does not appear to be the case as once the class was imported back in it magically appeared back on all the elements that used it.

Hi Tom,
Somehow we have to establish a connection between the classes and the elements. Accordingly, the connection is saved in the database and not deleted when the class itself is deleted, because it is definitely more advantageous for the styles to be reapplied, as in your case, than if you had to add them manually xx times.

Best regards,
timmse

1 Like

Yup I understand your reasoning. No reason to reply back unless you want to as I understand its not going to change (and is not really a big issue in the long run).

When I code I always like keeping the database clean and remove records that point to other items that have been deleted as most likely those relationships will never be added back and just adds bloat and confusion if you ever have to debug something (not that most people would). It’s proper maintenance of the database.

This seems to be how most WordPress plugins deal with these type of situations. I remember being shocked when I first came to WordPress and found out when you uninstall a plugin it usually leaves everything in the Database and WordPress doesn’t force the plugin to offer a choice to the user (of keeping the db tables/records or delete) when uninstalling the plugin.

Same with plugins that deal with custom fields. With most of them if you change the field ids or delete fields the actual content of those fields remains in the database (and are not either moved over deleted outright).

Anyways… sorry for my mini rant :wink: I would have never gotten away with that when I worked with financial reporting software.