Fatal error when taxonomy_options_list() tries to call an undefined callback function

Created on 16 September 2011, over 13 years ago
Updated 16 May 2023, over 1 year ago

This refers to changes made in #730418: Allow modules to bypass taxonomy_get_tree() for term reference select lists β†’ .

Modules can define a custom callback function for taxonomy_options_list() which gets saved as field data in {field_config}. However, taxonomy_options_list() doesn't make a function_exists() check before trying to call it, causing a PHP fatal error if it the custom module is disabled or uninstalled.

This just came up for me trying to uninstall taxonomy_access.module on a site. After disabling it, taxonmy_options_list still tries to call _taxonomy_access_term_options() because the callback is still stored in the field data.

πŸ› Bug report
Status

Closed: won't fix

Version

7.0 ⚰️

Component
TaxonomyΒ  β†’

Last updated 41 minutes ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @xjm
  • πŸ‡¬πŸ‡§United Kingdom @catch
Created by

πŸ‡ΊπŸ‡ΈUnited States les lim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • last update over 1 year ago
    2,146 pass
  • Status changed to Closed: won't fix over 1 year ago
  • πŸ‡ΈπŸ‡°Slovakia poker10

    Reading this again after a year, I prefer to close this as Won't fix, because of this reason (see #20):

    A fatal error is the proper response here. There is no guarantee that the result of this function is going to be correct if the callback function does not exist. As a consequence, the consumers of this function might proceed and you will end up with inconsistent data.

    If we commit this patch, we will change the expected output, because instead of custom callback, the default taxonomy_allowed_values function will be used even if the custom callback function is set:

    -  $function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';
    +  if (!empty($field['settings']['options_list_callback']) && function_exists($field['settings']['options_list_callback'])) {
    +    $function = $field['settings']['options_list_callback'];
    +  }
    +  else {
    +    $function = 'taxonomy_allowed_values';
    +  }
    

    This is not ideal and it could lead to unexpected behavior. If anybody needs the patch, feel free to use it to prevent the error.

    Thanks all for your effort here.

Production build 0.71.5 2024