Skip to content

Instantly share code, notes, and snippets.

@m4tthumphrey
Created April 23, 2013 13:37
Show Gist options
  • Save m4tthumphrey/5443603 to your computer and use it in GitHub Desktop.
Save m4tthumphrey/5443603 to your computer and use it in GitHub Desktop.
One of the worst parts of Magento. Truly hilarious. It checks that a URL returns the string 'MAGENTO' and nothing else as a way to check that it has been installed to the correct place. Impossible to test.
<?php
protected function _checkUrl($url, $secure = false)
{
$prefix = $secure ? 'install/wizard/checkSecureHost/' : 'install/wizard/checkHost/';
try {
$client = new Varien_Http_Client($url . 'index.php/' . $prefix);
$response = $client->request('GET');
/* @var $responce Zend_Http_Response */
$body = $response->getBody();
}
catch (Exception $e){
$this->_getInstaller()->getDataModel()
->addError(Mage::helper('install')->__('The URL "%s" is not accessible.', $url));
throw $e;
}
if ($body != Mage_Install_Model_Installer::INSTALLER_HOST_RESPONSE) {
$this->_getInstaller()->getDataModel()
->addError(Mage::helper('install')->__('The URL "%s" is invalid.', $url));
Mage::throwException(Mage::helper('install')->__('Response from server isn\'t valid.'));
}
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment