Here is the script I've written to remove the require_once and loadClass
calls from ZF. This does not fix the HelperBroker issue, that change
will need applying manually.
--
Jack
current(), PATHINFO_EXTENSION) === 'php');
}
}
$directory = 'zend-framework/library/';
$iterator = new RecursiveDirectoryIterator($directory);
$iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::LEAVES_ONLY);
$iterator = new OptimiserFilterIterator($iterator);
/* Global Replacements */
foreach($iterator as $i => $file) {
$path = $file->getRealPath();
$content = file_get_contents($path);
// Remove all Zend library require|include(_once) statements
$content = preg_replace('/((?:require|include)(_once)?\s?\(?[\'"]Zend\/.*?[\'"]\)?;)/', '//$1', $content);
// Replace all calls to Zend_Loader::loadClass() with spl_autoload_call()
// This will break any calls that use the 2nd $paths parameter, there are currently (1.5.3) none
$content = preg_replace('/Zend_Loader::loadClass\((.*?)\);/', 'spl_autoload_call($1);', $content);
file_put_contents($path, $content);
}
/* Specific Changes */
// Zend/Cache.php
$content = file_get_contents($directory . 'Zend/Cache.php');
$content = str_replace(
'require_once str_replace(\'_\', DIRECTORY_SEPARATOR, $frontendClass) . \'.php\';',
'spl_autoload_call($frontendClass);',
$content
);
$content = str_replace(
'require_once str_replace(\'_\', DIRECTORY_SEPARATOR, $backendClass) . \'.php\';',
'spl_autoload_call($backendClass);',
$content
);
file_put_contents($directory . 'Zend/Cache.php', $content);
// Zend/Memory.php
$content = file_get_contents($directory . 'Zend/Memory.php');
$content = str_replace(
'require_once str_replace(\'_\', DIRECTORY_SEPARATOR, $backendClass) . \'.php\';',
'spl_autoload_call($backendClass);',
$content
);
file_put_contents($directory . 'Zend/Memory.php', $content);