This message is generated by the PHP runtime environment. It is identified as a "Notice" which means that something less than ideal is happening but it shouldn't stop your pages from loading.
However, it does deserve attention because this type of message indicates that you are at higher risk of suffering from logic errors. This means that the data you are presenting to your users might not be the data you are intending to display to your users.
The message "undefined index" tends to suggest that in your PHP code you have a variable that is an array. You have attempted to access a value in that array, but the array index you used is non-existent.
We frequently see this where developers are iterating over an array with a for loop and they iterate once too often, moving past the end of the array.
The error message in your watchdog log gives you nearly all of the information required to stop this error message showing up. Open the file that has been referenced and go to the line number given.
You should be able to see the code that is attempting to reference the array that is being accessed with an undefined index. Most of the time the solution will leap out of the page at you but if your code is more complex you may find it easier to track down the error condition by firing up an interactive debugging session and stepping through the code until you can see exactly why the invalid index is being used.
You should take care to ensure that any fixes are applied in the right place. For example is the problem with the code that references the array, or did an invalid value get passed into the enclosing function earlier on in the code execution.
It is also worth noting that if you find this error message refers to a core Drupal script then care must be taken not to break your upgrade path. As a golden rule, core scripts should not be edited. So if the source of the problem really is in the core script a patch should be created that can be submitted to Drupal so that the issue can be fixed in source.
- Log in to post comments