Undefined index in Under Construction plugin when updated

I updated the Under Construction plugin to 2.1.0. and afterwards I got a php error.

Undefined index: tco_under_construction_status_header in wp-content/plugins/tco-under-construction/functions/options.php on line 87

Going into the plugin settings page and saving the plugin settings resolved the error.

I can’t say conclusively but It seems if you:

  1. Have sufficiently old version of the plugin
  2. Save the settings
  3. and then Update the plugin

that $tco_under_construction_options = apply_filters( ‘tco_under_construction_options’, get_option( ‘tco_under_construction’ ) ); returns an array with some of the missing indexes because they aren’t defined because those settings didn’t exist in the old version of the plugin settings page.

Line 82 assumes that because $tco_under_construction_options != ‘’ that all the indexes are defined but I think if this sequence of events transpires, that assumption is incorrect.

I think you either need to set defaults in the tco_under_construction_options(); or use a ternary operators when defining the variables on lines 86-102 to check whether the index exists before assigning the value.

I want to be clear that I no longer have a problem that needs any resolution. I fixed this by saving the plugin settings. I am just reporting a bug.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.