Fix PHP Undefined notices

Fix several places where a PHP "Undefined variable" or "Undefined index"
notice can be generated.

Change-Id: Ib558ba0d2a16a0ef881e832cb7f697a65fc68568