Fix various PHP code bugs found using static analysis (#1489086)

Conflicts:

	plugins/enigma/enigma.php
	plugins/enigma/lib/enigma_engine.php