Taxonomy Delete Batch module allows you to delete large vocabularies and orphaned terms. This module aims to help you if you want to delete thousands of terms at once.
If you try to delete a Vocabulary what contains a huge amount of terms, you will probably face memory or execution time limitations.
Taxonomy Delete Batch aims to solve that problem using the Batch API of Drupal core.
You may find this module helpful, if you are building or administering a site what generates a huge amount of data, and you need to do a clean-up sometimes.

Comparison

I've tried other modules before writing Taxonomy Delete Batch, but none of them was able to handle thousands of terms, or the intended usage is drush, what is not available on shared hosts. This module can be used on shared hosts.

Installation

As usual.

Usage

The User who has the administer taxonomy permission is able to use Taxonomy Delete Batch.
It integrates into the edit page of vocabularies, and deletes all vocabularies using the Batch API if the user deletes a vocabulary using the admin UI.

Start

How to Batch delete orphaned terms and large vocabularies

  1. Navigate to admin/structure/taxonomy/delete-batch
  2. Select vocabularies what have orphaned terms
  3. Select vocabularies you would like to delete altogether
  4. Click the Start button

How to Delete a vocabulary

  1. Navigate to admin/structure/taxonomy
  2. Click edit of any of the vocabularies you want to delete
  3. Click delete on the edit page of the vocabulary
  4. Confirm the deletion

Continue

  1. Navigate to admin/structure/taxonomy/delete-batch
  2. Click the Continue button

Terminate

  1. Navigate to admin/structure/taxonomy/delete-batch
  2. Click the Terminate button

Remarks

  • Term-Node relations are handled only. Other entities and field relations are not supported.
  • Drupal 7 only.

Link to project page

http://drupal.org/sandbox/imre.horjan/1831062

Version Control

Git instructions

http://drupal.org/node/1831062/git-instructions/7.x-1.x/nonmaintainer

Direct link to git repository

http://git.drupal.org/sandbox/imre.horjan/1831062.git

Git clone

git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/imre.horjan/1831062.git taxonomy_delete_batch

Comments

imre.horjan’s picture

Issue summary: View changes

Termination usage information added

imre.horjan’s picture

Issue summary: View changes

Termination information updated

aritra.ghosh’s picture

Hii,
Looks like this is going to be a nice module.

Quick manual Review:

1. Please remove license.txt. It will be automatically added by Drupal while packaging.
2. Some of the function headers are missing and some comment structures are not according to Drupal standard.

Please make sure to run your module and correct the errors through drupal automatic code sniffer. Currently is shows a large number of them: http://ventral.org/pareview/httpgitdrupalorgsandboximrehorjan1831062git

Thanks,
Aritra

aritra.ghosh’s picture

Status: Needs review » Needs work

Changing the status to needs work.

imre.horjan’s picture

Status: Needs work » Needs review

Hi,
Thanks for your advise.
I've polished the code to meet Drupal standards.
There is no recognized errors on the page, except acccording to the git repository.

imre.horjan’s picture

Status: Needs review » Needs work

Still have some coding-standard errors, currently working on fixing them...

udaksh’s picture

Status: Needs work » Needs review
StatusFileSize
new58.78 KB

Hi Imre.horjan,

I tried to run your module but it is giving following error when i clicked on start button:

An AJAX HTTP request terminated abnormally. Debugging information follows. Path: /drupal/batch?id=65&op=do StatusText: ResponseText: ReadyState: 4

Also as a security point you must use check_plain() or other filters for getting the vocabulary names.
Your 108 line in file taxonomy_delete_batch_form.inc should be $options[$vocabulary->vid] = check_plain($vocabulary->name); because here you getting the value from some other module.

Regards,

imre.horjan’s picture

Everything is fixed, no errors, no warnings.
http://ventral.org/pareview/httpgitdrupalorgsandboximrehorjan1831062git

The git repository also seems to be correct.

imre.horjan’s picture

Status: Needs review » Needs work

Hi udaksh,
I will correct those.

imre.horjan’s picture

Hi udaksh,
You are right, that filtering data is important.
However your suggested modifications are not important here, because data must be filtered in theme layer.
If you take a look at drupal core's include/form.inc you will find those filtering codes in theme_ functions, in this case the following:

<?php
function theme_form_element_label($variables) {
...
$title = filter_xss_admin($element['#title']);
...
?>

I've tested the module again, and works fine on a clean install. Generated 10000 terms with devel generate, and the process finished without any errors.

I see you are running drupal in a subdirectory, not sure whether it can be the cause or not, but I think you may encounter other AJAX / batch related issues. My other idea is that non-ASCII characters can cause errors somehow.

I suggest you to checkout the source code from the 7.x-1.x branch again. I think the git repository was messed up that time, when you tested the module.
Could you please take a look again, and if you get error messages, could you provide me more details?

imre.horjan’s picture

Status: Needs work » Needs review
udaksh’s picture

Hi Imre.horjan,

I tried with the updated source code of 7.x-1.x, and now it is running fine. I have not seen your code in depth but i will review it soon. Thanks i can see that check_plain() is not required there.

Also,I can see that the functionalities provided by your module is also being provided by Taxonomy Manager http://drupal.org/project/taxonomy_manager. We prefer collaboration over competition. Please be ensure that your project is providing unique functionalities than any other existing project on drupal.org.

imre.horjan’s picture

Actually, I'm using Taxonomy Manager, but it's functionality differs.
I will take a look whether I can collaborate with the maintainers, however my plans are a bit different, I plan to rewrite the code and replace core's delete functionality.
I would be more happy if I could merge it into D8 core if it can be done before the code freeze.

imre.horjan’s picture

That's what I've found:
http://drupal.org/node/189192
Francewhoa suggests to use http://drupal.org/project/delete_orphaned_terms , admitting that it can not handle large vocabularies.

However, even if I've used taxonomy manager, I prefer Views with VBO for that use case.

I've been thinking about your suggestion, but my opinion is that Taxonomy Manager and Taxonomy Delete Batch are for different use cases. In Taxonomy Manager you work with terms, meanwhile in Taxonomy Delete Batch you work with vocabularies.

I admit that there are two other similar modules out there:

Both of them have similarities to Taxonomy Delete Batch, but have fundamental differences.

The reason I wrote this module is that I couldn't find any module what was able to handle such amount of data. I was building a site, what has more that 15000 nodes, connected to more than 15000 terms, and there were no module what was able to delete unnecessary terms.

imre.horjan’s picture

Committed the above mentioned changes to 7.x-1.x.
Vocabulary delete functionality is replaced to use Taxonomy Delete Batch.
When the user navigates to admin/structure/taxonomy, clicks edit next to a vocabulary, and selects delete > Confirm delete, it uses the batch processing for the deletion.

imre.horjan’s picture

Issue summary: View changes

Git information changed to use the 7.x-1.x branch

imre.horjan’s picture

Issue summary: View changes

The newly commited version integrates into the admin UI, and uses Taxonomy Delete Batch on Vocabulary Deletion.

imre.horjan’s picture

Issue summary: View changes

* Start button
* Headers
* Links
* Codes

imre.horjan’s picture

Issue summary: View changes

Git clone => H3

imre.horjan’s picture

Issue summary: View changes

-The

imre.horjan’s picture

Status: Needs review » Closed (fixed)

The module is under a total rewrite (implementing new features, being more stable and user-friendly).
Closing this thread until I can publish the newer version.

imre.horjan’s picture

Issue summary: View changes

Entity info