Skip to content

Commit c7f2128

Browse files
committed
FIX: Undefined array key "addHandler" in issueTrackerInterface.class.php
- Line 403 and Line 385
1 parent 44411a5 commit c7f2128

1 file changed

Lines changed: 67 additions & 72 deletions

File tree

lib/issuetrackerintegration/issueTrackerInterface.class.php

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Base class for connection to issue tracking interfaces
88
* For supporting a bug/issue tracking system this class has to be extended,
9-
* and all customization should be done in the subclass.
9+
* and all customization should be done in the subclass.
1010
*
1111
* ============= Issue Entity properties on TestLink Context ===================
1212
*
@@ -37,36 +37,36 @@ abstract class issueTrackerInterface
3737

3838
// private vars don't touch
3939
// usable only if interface is done via direct DB access.
40-
var $dbConnection = null;
40+
var $dbConnection = null;
4141
var $dbMsg = '';
4242
// useful for connect/disconnect methods
43-
var $interfaceViaDB = false;
43+
var $interfaceViaDB = false;
4444
var $connected = false;
4545
var $resolvedStatus;
4646

47-
var $methodOpt = array('buildViewBugLink' =>
48-
array('addSummary' => false,
47+
var $methodOpt = array('buildViewBugLink' =>
48+
array('addSummary' => false,
4949
'colorByStatus' => false,
5050
'addReporter' => false,
5151
'addHandler' => false));
5252

5353
var $guiCfg = array();
54-
var $summaryLengthLimit = 120; // Mantis max is 128.
54+
var $summaryLengthLimit = 120; // Mantis max is 128.
5555
var $forbidden_chars = '/[!|�%&()\/=?]/';
5656

5757
/**
5858
* Construct and connect to BTS.
5959
* Can be overloaded in specialized class
6060
*
61-
* @param str $type (see tlIssueTracker.class.php $systems property)
61+
* @param string $type (see tlIssueTracker.class.php $systems property)
6262
**/
6363
function __construct($type,$config,$name) {
6464

6565
$this->tlCharSet = config_get('charset');
6666
$this->guiCfg = array('use_decoration' => true); // add [] on summary and statusHTMLString
6767
$this->name = $name;
6868

69-
if( $this->setCfg($config) ) {
69+
if( $this->setCfg($config) ) {
7070
// useful only for integration via DB
7171
if( !property_exists($this->cfg,'dbcharset') ) {
7272
$this->cfg->dbcharset = $this->tlCharSet;
@@ -106,7 +106,7 @@ function getCfg()
106106

107107
/**
108108
*
109-
*
109+
*
110110
**/
111111
function setCfg($xmlString) {
112112
$msg = null;
@@ -116,7 +116,7 @@ function setCfg($xmlString) {
116116
if(strlen(trim($xmlString)) == 0) {
117117
// Bye,Bye
118118
$msg = " - Issue tracker:$this->name - XML Configuration seems to be empty - please check";
119-
tLog(__METHOD__ . $msg, 'ERROR');
119+
tLog(__METHOD__ . $msg, 'ERROR');
120120
return false;
121121
}
122122

@@ -126,7 +126,7 @@ function setCfg($xmlString) {
126126
$this->cfg = simplexml_load_string($this->xmlCfg);
127127
if (!$this->cfg) {
128128
$msg = $signature . " - Failure loading XML STRING\n";
129-
foreach(libxml_get_errors() as $error)
129+
foreach(libxml_get_errors() as $error)
130130
{
131131
$msg .= "\t" . $error->message;
132132
}
@@ -140,30 +140,29 @@ function setCfg($xmlString) {
140140

141141
if( !($retval = is_null($msg)) )
142142
{
143-
tLog(__METHOD__ . $msg, 'ERROR');
144-
}
143+
tLog(__METHOD__ . $msg, 'ERROR');
144+
}
145145

146-
//
147146
if( !property_exists($this->cfg,'userinteraction') )
148147
{
149-
$this->cfg->userinteraction = 0;
150-
}
148+
$this->cfg->userinteraction = 0;
149+
}
151150
$this->cfg->userinteraction = intval($this->cfg->userinteraction) > 0 ? 1 : 0;
152151

153-
// From
152+
// From
154153
// http://php.net/manual/it/function.unserialize.php#112823
155154
//
156-
// After PHP 5.3 an object made by
157-
// SimpleXML_Load_String() cannot be serialized.
158-
// An attempt to do so will result in a run-time
159-
// failure, throwing an exception.
155+
// After PHP 5.3 an object made by
156+
// SimpleXML_Load_String() cannot be serialized.
157+
// An attempt to do so will result in a run-time
158+
// failure, throwing an exception.
160159
//
161-
// If you store such an object in $_SESSION,
160+
// If you store such an object in $_SESSION,
162161
// you will get a post-execution error that says this:
163-
// Fatal error: Uncaught exception 'Exception'
164-
// with message 'Serialization of 'SimpleXMLElement'
165-
// is not allowed' in [no active file]:0
166-
// Stack trace: #0 {main} thrown in [no active file]
162+
// Fatal error: Uncaught exception 'Exception'
163+
// with message 'Serialization of 'SimpleXMLElement'
164+
// is not allowed' in [no active file]:0
165+
// Stack trace: #0 {main} thrown in [no active file]
167166
// on line 0
168167
//
169168
// !!!!! The entire contents of the session will be lost.
@@ -188,11 +187,10 @@ function getMyInterface()
188187
*/
189188
function getBugIDMaxLength()
190189
{
191-
// CRITIC:
190+
// CRITIC:
192191
// related to execution_bugs table, you can not make it
193-
// greater WITHOUT changing table structure.
194-
//
195-
return 64;
192+
// greater WITHOUT changing table structure.
193+
return 64;
196194
}
197195

198196

@@ -211,26 +209,26 @@ function connect()
211209
}
212210

213211
// cast everything to string in order to avoid issues
214-
// @20140604 someone has been issues trying to connect
215-
// to JIRA on MSSQL
212+
// @20140604 someone has been issues trying to connect
213+
// to JIRA on MSSQL
216214
$this->cfg->dbtype = strtolower((string)$this->cfg->dbtype);
217215
$this->cfg->dbhost = (string)$this->cfg->dbhost;
218216
$this->cfg->dbuser = (string)$this->cfg->dbuser;
219217
$this->cfg->dbpassword = (string)$this->cfg->dbpassword;
220218
$this->cfg->dbname = (string)$this->cfg->dbname;
221219

222220
$this->dbConnection = new database($this->cfg->dbtype);
223-
$result = $this->dbConnection->connect(false,
221+
$result = $this->dbConnection->connect(false,
224222
$this->cfg->dbhost,
225223
$this->cfg->dbuser,
226-
$this->cfg->dbpassword,
224+
$this->cfg->dbpassword,
227225
$this->cfg->dbname);
228226

229227
if (!$result['status']) {
230228
$this->dbConnection = null;
231-
$cnn = "(interface: - Host:{$this->cfg->dbhost} - " .
232-
"DBName: {$this->cfg->dbname}
233-
- User: {$this->cfg->dbuser}) ";
229+
$cnn = "(interface: - Host:{$this->cfg->dbhost} - " .
230+
"DBName: {$this->cfg->dbname}
231+
- User: {$this->cfg->dbuser}) ";
234232
$msg = sprintf(lang_get('BTS_connect_to_database_fails'),
235233
$cnn);
236234
tLog($msg . $result['dbms_msg'], 'ERROR');
@@ -287,12 +285,12 @@ function disconnect()
287285
**/
288286
function checkBugIDSyntaxNumeric($issueID)
289287
{
290-
$valid = true;
291-
$blackList = '/\D/i';
288+
$valid = true;
289+
$blackList = '/\D/i';
292290
if (preg_match($blackList, $issueID)) {
293-
$valid = false;
291+
$valid = false;
294292
} else {
295-
$valid = (intval($issueID) > 0);
293+
$valid = (intval($issueID) > 0);
296294
}
297295
return $valid;
298296
}
@@ -370,7 +368,7 @@ function buildViewBugLink($issueID, $opt=null) {
370368
$link .= $issueID;
371369
}
372370

373-
if($my['opt']['addSummary']) {
371+
if(isset($my['opt']['addSummary'])) {
374372
if (!is_null($issue->summaryHTMLString)) {
375373
$link .= " : ";
376374
if($useIconv) {
@@ -382,47 +380,44 @@ function buildViewBugLink($issueID, $opt=null) {
382380
}
383381
}
384382

385-
if ($my['opt']['addReporter']) {
383+
if (isset($my['opt']['addReporter'])) {
386384
if( property_exists($issue, 'reportedBy') ) {
387385
$link .= "";
388386
$who = trim((string)$issue->reportedBy);
389387
if( '' != $who ) {
390388

391-
$link .= '<br>' . $l10n['issueReporter'] . ':&nbsp;';
389+
$link .= '<br>' . $l10n['issueReporter'] . ':&nbsp;';
392390
if($useIconv) {
393-
$link .=
394-
iconv((string)$this->cfg->dbcharset,$this->tlCharSet,$who);
391+
$link .= iconv((string)$this->cfg->dbcharset,$this->tlCharSet,$who);
395392
}
396393
else {
397394
$link .= $who;
398-
}
395+
}
399396
}
400397
}
401398
}
402399

403-
if($my['opt']['addHandler']) {
400+
if(isset($my['opt']['addHandler'])) {
404401
if( property_exists($issue, 'handledBy') ) {
405402
$link .= "";
406403
$who = trim((string)$issue->handledBy);
407404
if( '' != $who ) {
408405

409-
$link .= '<br>' . $l10n['issueHandler'] . ':&nbsp;';
406+
$link .= '<br>' . $l10n['issueHandler'] . ':&nbsp;';
410407
if($useIconv) {
411-
$link .=
412-
iconv((string)$this->cfg->dbcharset,$this->tlCharSet,$who);
408+
$link .= iconv((string)$this->cfg->dbcharset,$this->tlCharSet,$who);
413409
}
414410
else {
415411
$link .= $who;
416-
}
412+
}
417413
}
418414
}
419415
}
420416

421417
$link .= "</a>";
422418

423-
if ($my['opt']['colorByStatus']
424-
&& property_exists($issue,'statusColor') ) {
425-
$title = lang_get('access_to_bts');
419+
if ($my['opt']['colorByStatus'] && property_exists($issue,'statusColor') ) {
420+
$title = lang_get('access_to_bts');
426421
$link = "<div title=\"{$title}\" style=\"display: inline; background: $issue->statusColor;\">$link</div>";
427422
}
428423

@@ -431,13 +426,13 @@ function buildViewBugLink($issueID, $opt=null) {
431426
$ret->isResolved = $issue->isResolved;
432427
$ret->op = true;
433428

434-
if (isset($my['opt']['raw'])
429+
if (isset($my['opt']['raw'])
435430
&& !is_null(isset($my['opt']['raw'])) ) {
436431
foreach ($my['opt']['raw'] as $attr) {
437432
if (property_exists($issue, $attr)) {
438433
$ret->$attr = $issue->$attr;
439434
}
440-
}
435+
}
441436
}
442437
return $ret;
443438
}
@@ -456,23 +451,23 @@ function getEnterBugURL() {
456451
/**
457452
* Returns URL to the bugtracking page for viewing ticket
458453
*
459-
* @param mixed issueID
454+
* @param mixed issueID
460455
* depending of BTS issueID can be a number (e.g. Mantis)
461456
* or a string (e.g. JIRA)
462-
*
463-
* @return string
457+
*
458+
* @return string
464459
**/
465460
function buildViewBugURL($issueID) {
466461
return $this->cfg->uriview . urlencode($issueID);
467462
}
468463

469464

470465
/**
471-
* status code (always integer??) for issueID
466+
* status code (always integer??) for issueID
472467
*
473468
* @param issueID according to BTS can be number or string
474469
*
475-
* @return
470+
* @return
476471
**/
477472
public function getIssueStatusCode($issueID)
478473
{
@@ -485,8 +480,8 @@ public function getIssueStatusCode($issueID)
485480
* Returns status in a readable form (HTML context) for the bug with the given id
486481
*
487482
* @param issueID according to BTS can be number or string
488-
*
489-
* @return string
483+
*
484+
* @return string
490485
*
491486
**/
492487
function getIssueStatusVerbose($issueID)
@@ -500,7 +495,7 @@ function getIssueStatusVerbose($issueID)
500495
/**
501496
*
502497
* @param issueID according to BTS can be number or string
503-
*
498+
*
504499
* @return string returns the bug summary if bug is found, else null
505500
**/
506501
function getIssueSummary($issueID)
@@ -512,7 +507,7 @@ function getIssueSummary($issueID)
512507

513508
// How to Force Extending class to define this STATIC method ?
514509
// KO abstract public static function getCfgTemplate();
515-
public static function getCfgTemplate()
510+
public static function getCfgTemplate()
516511
{
517512
throw new RuntimeException("Unimplemented - YOU must implement it in YOUR interface Class");
518513
}
@@ -547,7 +542,7 @@ public function setResolvedStatusCfg()
547542
$e = (array)$cfx;
548543
$this->resolvedStatus->byCode[$e['code']] = $e['verbose'];
549544
}
550-
$this->resolvedStatus->byName = array_flip($this->resolvedStatus->byCode);
545+
$this->resolvedStatus->byName = array_flip($this->resolvedStatus->byCode);
551546
}
552547

553548
/**
@@ -560,7 +555,7 @@ public function getResolvedStatusCfg()
560555

561556
/**
562557
* Returns the status of the bug with the given id
563-
* this function is not directly called by TestLink.
558+
* this function is not directly called by TestLink.
564559
*
565560
* @return string returns the status of the given bug (if found in the db), or false else
566561
**/
@@ -597,7 +592,7 @@ function buildStatusHTMLString($statusCode)
597592
$str = $statusCode;
598593
if($this->guiCfg['use_decoration'])
599594
{
600-
$str = "[" . $str . "] ";
595+
$str = "[" . $str . "] ";
601596
}
602597
return $str;
603598
}
@@ -606,18 +601,18 @@ function buildStatusHTMLString($statusCode)
606601
* return the maximum length in chars of a issue summary
607602
* used on TestLink GUI
608603
*
609-
* @return int
604+
* @return int
610605
*/
611606
function getBugSummaryMaxLength() {
612607
return $this->summaryLengthLimit;
613608
}
614609

615610
/**
616-
*
611+
*
617612
**/
618613
function normalizeBugID($issueID)
619614
{
620615
return $issueID;
621616
}
622617

623-
}
618+
}

0 commit comments

Comments
 (0)