Asset Deletion When Component is Uninstalled

16 views
Skip to first unread message

orware

unread,
Jan 20, 2011, 2:58:55 PM1/20/11
to Joomla! General Development
So I noticed right now with the extension I'm developing for Joomla
1.6 that performing an upgrade installation didn't re-run the install
SQL file (so the new table I had just added to the file wasn't getting
created). I went ahead and deleted the extension, thinking that maybe
the reason the table wasn't being added was because I was doing an
upgrade, rather than a new install.

Upon installing the extension again, the new table was added properly,
which is what I wanted, but as I continued on with development I
noticed that all of the assets in the assets table that had been
created previously were all gone, even though the records themselves
(in my extension's tables) were all still there...which ended up
creating an issue because they weren't associated with any existing
assets anymore. I could go one by one and reopen/save the records to
have the assets recreated, but I had created a couple of hundred
records already so that didn't sound like a good idea :-).

I'm just wondering now...do the asset records have to be deleted
automatically, or is there something I can do from my end to prevent
it from occurring?

Omar Ramos

unread,
Jan 20, 2011, 3:34:02 PM1/20/11
to Joomla! General Development
Doing a little further investigation into the JInstallerComponent class it appears as if you really do not have a choice in the matter (from a developer's perspective) about whether or not assets get removed upon installation or not since JInstallerComponent has this piece of code in it starting on line 1113:
// Remove the component container in the assets table.
$asset = JTable::getInstance('Asset');
if ($asset->loadByName($element)) {
$asset->delete();
}

The above call deletes the record for the component, as well as any other related children records for other assets within that component.

On a related note to the above, I noticed that the entire media folder for the extension was deleted automatically as well, which I suppose would be wanted in most cases, however in mine I'm goin to be storing additional files (uploaded by users) in that folder so it doesn't make a lot of sense to delete it automatically if I can avoid it.

Any ideas on either of these two topics?


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


orware

unread,
Feb 3, 2011, 5:28:23 PM2/3/11
to Joomla! General Development
I didn't get any replies on this, but I just wanted to see if anybody
else thought it was weird that we do not have a choice whether or not
the asset records are delete when our component is uninstalled in
Joomla 1.6?

So many times in Joomla 1.5 a user could uninstall their component and
keep the underlying data within the database, and I would think this
would be allowed in Joomla 1.6, however when your records are making
use of the new ACL system (and have an asset_id field in their table)
it really does not make any sense to delete all of their asset records
without also deleting the associated records (but again, this isn't
what most people want...they want to be able to uninstall their
component and keep the data...and asset records unless they specify
for the system to remove them explicitly).

From what I saw in JInstallerComponent the asset records removal
process is hardcoded in...it would be really nice if some options were
provided to developers as to how they wanted their records deleted
from the assets table.

Just as an example, in the component I'm working on, uninstalling the
component causes all of the records from two different tables to
become orphaned from the assets table. Upon reinstalling the component
I am able to see the records listed in the two list views I have for
each table, but the frontend wouldn't work correctly (because of the
missing asset_id's) as well as deleting the records (I can trash them,
but not delete them, due to the missing asset_id's). The only fix is
to open up and re-save each record which would recreate the asset IDs,
so I created a little automatic method that could do this for the
entire list for one of the views, but I don't see this as a true fix
because it would still require any permissions that had been assigned
to those records to be recreated manually (since all of the old
permissions are completely gone).

I could try and create a copy of all of the asset records before the
uninstallation and then restoring them post installation, but that
seems like a workaround for something that feels very much like a bug.

Is there anybody else developing Joomla 1.6 components at the moment
using the ACL that have run into similar experiences upon uninstalling
their extensions? I can see this being an issue for com_content/
com_categories is they were uninstallable, but since they're core
extensions you can't really test that (and I don't know if the
uninstallation side of things was thought of much while we were bug
squashing the 1.6 betas, I know I never thought about it).

-Omar
> > joomla-dev-gene...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
> > .

Sam Moffatt

unread,
Feb 3, 2011, 9:27:49 PM2/3/11
to joomla-de...@googlegroups.com
I'm not fussed either way, it was introduced by Christophe in this patch:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=23559

There is also a request to delete categories on uninstall as well:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=24451

Perhaps Christophe can share his reasoning behind removing the assets
automatically.

Sam Moffatt
http://pasamio.id.au

> To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages