When trying to delete a taxonomy, the source code do not enter in the conditional of xmlsitemap_taxonomy_form_taxonomy_form_term_alter function.

In case of deletion, the $form['delete']['#type'] is not equals to 'value' but of 'hidden'.

After analysis, in case of deletion, the $form['delete']['#type'] exist and his value is done to 'value'

I propose to change

 if ($form['name']['#type'] == 'value') {
    // If this is the delete form, do not add our form elements.
    return;
  }

to

 if ($form['delete']['#type'] == 'value') {
    // If this is the delete form, do not add our form elements.
    return;
  }

Comments

perraudeau created an issue. See original summary.

pifagor’s picture

Status: Patch (to be ported) » Needs work
jyraya’s picture

Status: Needs work » Needs review
StatusFileSize
new649 bytes

Hello

I did not reproduce the issue with a clean install of platform. The value of $form['name']['#type'] is still 'value'.
Do you have a custom or contrib module that would change this value before passing in the xmlsitemap_taxonomy code?

In any case, I think the more secure way is follow the logic implemented in the taxonomy module because if we change the value of $form['name']['#type'], there is nothing preventing to do so for $form['delete']['#type']; after all, only the '#value' is important for the process.

In 'taxonomy.admin.inc', line 674 of taxonomy_form_term(), to detect that we are in the delete confirm form case, the test is:

  // Check for confirmation forms.
  if (isset($form_state['confirm_delete'])) {
    return array_merge($form, taxonomy_term_confirm_delete($form, $form_state, $term->tid));
  }

Then, we should have the same logic in xmlsitemap_taxonomy_form_taxonomy_form_term_alter():

  if (isset($form_state['confirm_delete']) {
    // If this is the delete form, do not add our form elements.
    return;
  }

Other parameters can be changed but this one cannot without breaking the taxonomy term form.

I push here a patch in this direction.

avpaderno’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Issue tags: -taxonomy