Skip to content

Bugfix Issue 518 PlanAddTC UndefinedArrayKey testprojectName

CI Agent edited this page Aug 25, 2026 · 1 revision

Bugfix — Issue #518: E_WARNING Undefined array key "testprojectName" in planAddTC.php:421

Summary

PHP 8.x emits E_WARNING: Undefined array key "testprojectName" when planAddTC.php accesses $_SESSION['testprojectName'] without checking if the key exists.

Root Cause

  • File: lib/plan/planAddTC.php:421 (pre-fix line)
  • Code (before fix): $args->tproject_name = $_SESSION['testprojectName'];
  • Cause: $_SESSION['testprojectName'] is only set on certain navigation paths (after selecting a project in the navbar). When the page is loaded directly or via a refresh where the session key is missing, PHP 8 emits E_WARNING.
  • Regression source: PHP 8 changed undefined array key access from E_NOTICE (suppressible) to E_WARNING (always logged).

Fix

Method: Added isset() ternary guard.

// Before (line 421):
$args->tproject_name = $_SESSION['testprojectName'];

// After (line 421):
$args->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : '';

Commit: f4456736b — "fix: 43 unique PHP 8 warnings across print.inc.php, buildEdit, planAddTC, printDocOptions, resultsNavigator, and 15+ templates"

Verification

  • HTTP 200 OK from planAddTC.php with valid session
  • Zero browser console warnings/errors
  • Zero PHP E_WARNING output with error_reporting=E_ALL
  • No syntax errors (php -l lib/plan/planAddTC.php)

Related

  • Other files with same unguarded pattern (tracked in separate issues): tc_exec_unassign_all.php:79, planUpdateTC.php:135, tc_exec_assignment.php:254

Clone this wiki locally