contao/core — pull request #5721 by wollviech (2013-05-03 13:50:08+00:00)
Title: During SMH Installation the Installer issues a call to Files::getInstance before $GLOBALS['TL_CONFIG']['useFTP'] can be set

Because we're doing a safe-mode installation, we want that the Installer instantiates the Files\Ftp-Implementation by setting before $GLOBALS['TL_CONFIG']['useFTP'] to true prior to the call to Files::getInstance() being made.

Only this doesn't work because InstallTool->loadLanguageFile() is called by InstallTool's constructor, and it in turn again will result in a call to Files::getInstance and an instantiation of Files\Php; this all happens before $GLOBALS['TL_CONFIG']['useFTP'] is set. The user-facing consequences of this is that entering the correct FTP-credentials will lead to no error message and the FTP Credentials Input mask being displayed again. And again. And again ...

The correct fix would be to fix the call-flow, but I don't have the time nor the inclination to for this, so instead of this you get a quick hack. ;)
It somewhat relaxes the singleton-semantics of Files; it now differentiates between three different handler types and treats each of those handlers as a singleton.
Objects that have called Files::getInstance before the change to $GLOBALS['TL_CONFIG']['useFTP'] was made retain their old implementation, but can "update" it by another call to $this->import('Files')