Indefero

Issue 520: Error 500 when showing GIT source tree

Reported by Nikolaus Schaller, Aug 15, 2010

On some specific GIT tree I repeatedly got e-mails with this error:

PlufErrorHandlerException making GET request to 
/p/project/source/tree/master/include/linux
8 : Undefined offset: 2

PHP: ........./indefero/src/IDF/Scm/Cache/Git.php, line 92
URI: GET /p/project/source/tree/master/include/linux

** Stacktrace **

* PlufErrorHandler
       
[/Library/WebServer/Sites/projects.goldelico.com/indefero/src/IDF/Scm
/Cache/Git.php, line 92] *
* Src *
87:             $tmp = explode(chr(31), $blob->content, 3);
88: 
89:             $res[$blob->githash] = (object) array(
90:                                                   'hash' => 
$blob->githash,
91:                                                   'date' => 
$tmp[0],
92:                                                   'title' => 
$tmp[2],
93:                                                   'author' => 
$tmp[1],
94:                                                   );
95:         }
96:         return $res;
97:     }


Some analysis did show that the $blob->content sometimes has only 
two fields, i.e. $tmp[2] (the title) is completely empty. On my PHP 
(5.3.1) this results in an exception. This code did fix the issue:


            $tmp = explode(chr(31), $blob->content, 3);

	    if(!isset($tmp[2]))
	       $tmp[2]="";

            $res[$blob->githash] = (object) array(
                                                  'hash' => 
$blob->githash,
                                                  'date' => 
$tmp[0],
                                                  'title' => 
$tmp[2],
                                                  'author' => 
$tmp[1],
                                                  );

Comment 1 by Thomas Keller, Sep 1, 2010

Hi Nikolaus!

Could you test if my slightly simplified version also works for you? 
If yes, I'd commit it right away.

Thanks,
Thomas.

Comment 2 by Thomas Keller, Nov 25, 2010

You're original fix was more correct than mine - fixed in commit 
1548d41. Thank you!
Status: Fixed

Comment 3 by Thomas Keller, Nov 25, 2010

Labels: Milestone:Release1.1

Created: 2 years 9 months ago by Nikolaus Schaller

Updated: 2 years 6 months ago

Status: Fixed

Followed by: 1 person

Labels:
Type:Defect
Priority:Medium
Milestone:Release1.1