Skip to content

PHP Warning: Undefined array key in Bootstrap.php and UiTab.php when using tab helpers #46769

@jjnxpct

Description

@jjnxpct

Steps to reproduce the issue

  1. Install Joomla 5.4.2
  2. Install an extension that uses the legacy Bootstrap tab helpers (e.g., ConvertForms, DPCalendar, Edocman, or JCE Editor)
  3. Access a page that renders tabs using these helpers
  4. Check PHP error logs

Expected result

No PHP warnings should be generated when using the Bootstrap or UiTab helpers.

Actual result

PHP Warning is generated:
PHP Warning: Undefined array key "Joomla\CMS\HTML\Helpers\Bootstrap::startTabSet" in Bootstrap.php on line 884

Similar issue exists in /libraries/src/HTML/Helpers/UiTab.php on line 92.

System information (as much as possible)

  • Joomla Version: 5.4.2
  • PHP Version: 8.1+ (warning appears with PHP 8+ strict error checking)
  • Extensions triggering the issue: ConvertForms, DPCalendar, Edocman, JCE Editor

Additional comments

Root Cause:
Both Bootstrap.php (line 884) and UiTab.php (line 92) access array keys without checking if they exist:

$active = (static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : '';

Proposed Fix:
Add isset() check before accessing the array:

$active = (isset(static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active']) && static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : '';

This defensive programming approach prevents warnings when extensions call addTab() but the initialization in startTabSet() didn't complete properly or the array key doesn't exist.

Files affected:

  • Bootstrap.ph line 884
  • UiTab.php line 92

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions