When uninstalling the Catalog module, the vocabulary set in catalog settings is completly removed.

That shouldn't be the case since this vocabulary can exist before the installation of Ubercart.

I've experienced it today on a demo site (lucky that it was not a bigger site) and now I've to recreate the vocabulary and re-affect nodes to it.

Comments

lphm’s picture

Issue tags: +taxonomy, +vocabulary, +uc_catalog

Hello,
Maybe it is not a bug report but a feature request.

lphm.

tahiticlic’s picture

If this was made on purpose, well you're right. But this is a strange behavior to erase something pre-existing.

Regards,
cfab

torgospizza’s picture

Title: Uninstall : too complete... » uc_catalog should not delete Vocabulary
Status: Active » Needs review
StatusFileSize
new585 bytes

Yep, this is part of the hook_uninstall process of uc_catalog. You're right, it really shouldn't do this. We still use the Catalog vocabulary for categorizing our content, despite the fact that we've disabled the UC Catalog module (we're using Views for our catalog pages, so we don't need it).

Attached is a patch which removes this part of the process.

tahiticlic’s picture

Well, I've developed another catalog module, not involving UC which was to heavy for only a simple catalog : http://drupal.org/project/taxonomy_grid

torgospizza’s picture

Yes, and if someone using your module has selected their catalog taxonomy, and they decide to uninstall the uc_catalog module, there goes one whole vocabulary. The patch I posted prevents that from happening.

tahiticlic’s picture

Of course, your patch is necessary also : I would have had it before! :-)

longwave’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

RTBC, and bumping priority as this can cause data loss - I have seen this first hand when upgrading an old D5/UC1 site to D6. Catalog had previously been installed and unbeknownst to me the vocabulary was in use as the main taxonomy on the site. I uninstalled catalog as I had no use for it on the new site, only to find all the categories had been unexpectedly deleted.

tr’s picture

Here's my concern: I think the majority of sites are just using the catalog vocabulary created by uc_catalog, not replacing it with their own. In those cases, if you don't remove the vocabulary when you uninstall uc_catalog, it will remain to clutter up the database. So I think the patch needs to be a little smarter about deciding what to not delete.

torgospizza’s picture

TR: Understood; but in our case, I want to keep the uc_catalog vocab (which was the default from Ubercart). Looking back I wish I had never installed the uc_catalog module; that would let me avoid this problem.

What if we drupal_set_message() after the uninstall process a link that points to the taxonomy admin area, with a message stating that if they want to delete the vocab they have to do it manually? I think there's really no way to be 'smart' about it because as it is now, this is a data loss issue that someone could stumble into accidentally.

(Edited for some typos)

longwave’s picture

Exactly my point, most sites will use the vocab set up by uc_catalog to categorise their products - but my uninstall case was that I was replacing uc_catalog with Views, and I didn't expect the vocab and its terms to be deleted when I uninstalled uc_catalog after I no longer needed it; it's not obvious that the vocab is "owned" by uc_catalog as such.

I don't see how we can determine from code whether the admin intends for the vocab to be deleted at uninstall time, so I think it best to err on the side of caution - the vocab can easily be deleted manually, but recreating it after an unintended deletion is much more difficult.

torgospizza’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new675 bytes

Here's a revised patch that looks to see if a uc_catalog vocab exists, and if so, instead of deleting it provides the user with a message notifying them that it has not been deleted. Provides them instead with a link to the actual vocabulary's admin page.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Patch works as expected.

Island Usurper’s picture

Status: Reviewed & tested by the community » Fixed

Oh, good. This change should have been made years ago.

One thing I changed before committing the patch: the link text wasn't translatable. When displaying links within copy text, the best practice is to replace only the URL in the href attribute.

    drupal_set_message(t('The Ubercart Catalog vocabulary has not been deleted. If you need to delete it, <a href="!url">please do so manually</a>.',
      array('!url' => url('admin/content/taxonomy/edit/vocabulary/'. $vid))), 'notice');

This lets translators work on the sentence as a whole and gives them the freedom to change word order, or even the link's position as necessary.

torgospizza’s picture

Good catch. Thanks, Lyle!

longwave’s picture

Status: Fixed » Patch (to be ported)

Needs porting to 7.x.

sean-gnu’s picture

Don't forget to give control of this vocab back to taxonomy module. I.e. set the module field in the vocab table.

db_query("UPDATE {vocabulary} set module='taxonomy' where module like 'uc_catalog'");

longwave’s picture

@sean-gnu: What is that field even used for, except hook_term_path, which Ubercart doesn't implement anyway? Perhaps "taxonomy" should always be the owner? #425984: Employ a hook_term_path() for catalog is relevant though I see you already posted there!

longwave’s picture

In fact, looking at the source for taxonomy_term_path(), it looks like we don't need to worry about setting the owner back to "taxonomy" as it will fall back to the correct value anyway?

sean-gnu’s picture

@longwave - yes - it's used for hook_term_path. uc_catalog alters the term_path to no longer be 'taxonomy/term/%', and replaces it with 'catalog/%'. Thereby giving control to uc_catalog's menu system, and hence bypassing the standard taxonomy menu's system.

Perhaps module_invoke will not call a module that is uninstalled (haven't checked) - but the line of code I suggested is part of proper cleanup of uc_catalog uninstall.

Just a suggestion :) It has its place in my patches and thought I'd share !

sean-gnu’s picture

@longwave - my patch here : http://drupal.org/node/425984 includes an attempt to get the issue mentioned here sorted as well. Sort of a bonus ! It did not include any message though.

My reasoning was - back then - that deleting uc_catalog should remove the catalog "handler", not the data itself and since uc_catalog can attach itself to an existing vocab, it should most definetly not delete it on uninstall.

So, thumbs up for this patch.

Island Usurper’s picture

Version: 6.x-2.4 » 7.x-3.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new824 bytes

Since uc_catalog stopped using hook_term_path(), the only reason I can think of for that module field is just to have a record that uc_catalog did indeed create that vocabulary. If an existing vocabulary becomes the catalog, I don't think it's module is changed to uc_catalog. In fact, that may have been the reason hook_term_path() was dropped. At any rate, I don't see a need to change that field when uc_catalog is uninstalled.

Patch for 3.x.

longwave’s picture

Status: Needs review » Fixed

Committed, with a fix to the vocabulary edit path.

Status: Fixed » Closed (fixed)
Issue tags: -taxonomy, -vocabulary, -uc_catalog

Automatically closed -- issue fixed for 2 weeks with no activity.