Automatic upgrade removal of old Smarty2 files (2.0-alpha2)
This commit is contained in:
parent
609515a4d8
commit
0b1aeddc31
@ -4,6 +4,9 @@ Version 2.0 ()
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
* Automatic upgrade removal of old Smarty2 files (2.0-alpha2)
|
||||
function uses SPL
|
||||
|
||||
* Implemented patch https://github.com/s9y/Serendipity/pull/15
|
||||
|
||||
* When switching templates, both the backend and the frontend
|
||||
|
@ -198,6 +198,12 @@ $tasks = array(array('version' => '0.5.1',
|
||||
'title' => 'Remove obsolete plugin',
|
||||
'desc' => 'The "browsercompatibility" plugin is no longer supported (and no longer required with recent browsers), so it will be automatically uninstalled.'),
|
||||
|
||||
array('version' => '2.0-alpha2',
|
||||
'function' => 'serendipity_removeDeadFiles_SPL',
|
||||
'title' => 'Removal of obsolete and dead Smarty 2.6.x files',
|
||||
'arguments' => array($serendipity['serendipityPath'] . 'bundled-libs/Smarty', $dead_smarty_files, array('internals'), true),
|
||||
'desc' => 'Smarty 3.x brought a new file structure. The following dead files will be removed from "bundled-libs/Smarty/libs".<br /><div style="font-size: x-small; margin: 15px">' . implode(', ', $dead_smarty_files) . '</div>'),
|
||||
|
||||
);
|
||||
|
||||
/* Fetch SQL files which needs to be run */
|
||||
|
@ -66,6 +66,63 @@ $obsolete_files = array(
|
||||
'templates/default/layout.php'
|
||||
);
|
||||
|
||||
/* A list of smarty 2.6.x lib files which got obsoleted in >= 1.7 */
|
||||
$dead_smarty_files = array(
|
||||
'BUGS',
|
||||
'ChangeLog',
|
||||
'FAQ',
|
||||
'INSTALL',
|
||||
'libs/config_file.class.php',
|
||||
'libs/smarty_compiler.class.php',
|
||||
'libs/internals/core.assemble_plugin_filepath.php',
|
||||
'libs/internals/core.assign_smarty_interface.php',
|
||||
'libs/internals/core.create_dir_structure.php',
|
||||
'libs/internals/core.display_debug_console.php',
|
||||
'libs/internals/core.get_include_path.php',
|
||||
'libs/internals/core.get_microtime.php',
|
||||
'libs/internals/core.get_php_resource.php',
|
||||
'libs/internals/core.is_secure.php',
|
||||
'libs/internals/core.is_trusted.php',
|
||||
'libs/internals/core.load_plugins.php',
|
||||
'libs/internals/core.load_resource_plugin.php',
|
||||
'libs/internals/core.process_cached_inserts.php',
|
||||
'libs/internals/core.process_compiled_include.php',
|
||||
'libs/internals/core.read_cache_file.php',
|
||||
'libs/internals/core.rm_auto.php',
|
||||
'libs/internals/core.rmdir.php',
|
||||
'libs/internals/core.run_insert_handler.php',
|
||||
'libs/internals/core.smarty_include_php.php',
|
||||
'libs/internals/core.write_cache_file.php',
|
||||
'libs/internals/core.write_compiled_include.php',
|
||||
'libs/internals/core.write_compiled_resource.php',
|
||||
'libs/internals/core.write_file.php',
|
||||
'libs/plugins/compiler.assign.php',
|
||||
'libs/plugins/function.assign_debug_info.php',
|
||||
'libs/plugins/function.config_load.php',
|
||||
'libs/plugins/function.debug.php',
|
||||
'libs/plugins/function.eval.php',
|
||||
'libs/plugins/function.popup.php',
|
||||
'libs/plugins/function.popup_init.php',
|
||||
'libs/plugins/modifier.cat.php',
|
||||
'libs/plugins/modifier.count_characters.php',
|
||||
'libs/plugins/modifier.count_paragraphs.php',
|
||||
'libs/plugins/modifier.count_sentences.php',
|
||||
'libs/plugins/modifier.count_words.php',
|
||||
'libs/plugins/modifier.default.php',
|
||||
'libs/plugins/modifier.indent.php',
|
||||
'libs/plugins/modifier.lower.php',
|
||||
'libs/plugins/modifier.nl2br.php',
|
||||
'libs/plugins/modifier.string_format.php',
|
||||
'libs/plugins/modifier.strip.php',
|
||||
'libs/plugins/modifier.strip_tags.php',
|
||||
'libs/plugins/modifier.upper.php',
|
||||
'libs/plugins/modifier.wordwrap.php',
|
||||
'QUICK_START',
|
||||
'NEWS',
|
||||
'RELEASE_NOTES',
|
||||
'TODO'
|
||||
);
|
||||
|
||||
/**
|
||||
* Fix inpropper plugin constant names
|
||||
*
|
||||
@ -171,3 +228,57 @@ function serendipity_killPlugin($name) {
|
||||
|
||||
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}plugins WHERE name LIKE '" . serendipity_db_escape_string($name) . "%'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty a given directory recursively using the Standard PHP Library (SPL) iterator
|
||||
* Use as full purge by serendipity_removeDeadFiles_SPL(/path/to/dir)
|
||||
* Or strict by serendipity_removeDeadFiles_SPL('/path/to/dir', $filelist, $directorylist, true)
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @param string directory
|
||||
* @param array dead files list
|
||||
* @param array dead directories list
|
||||
* @param boolean run list only else recursive default
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
function serendipity_removeDeadFiles_SPL($dir=null, $deadfiles=null, $purgedir=null, $list_only=false) {
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
|
||||
$search = array("\\", '//');
|
||||
$replace = array('/');
|
||||
foreach ($iterator as $file) {
|
||||
$thisfile = str_replace($search, $replace, $file->__toString());
|
||||
if ($file->isFile()) {
|
||||
if (is_array($deadfiles) && !empty($deadfiles)) {
|
||||
foreach ($deadfiles AS $deadfile) {
|
||||
#if( basename($deadfile) == basename($thisfile) ) echo 'LIST FILE: '.$dir . '/' . $deadfile . ' == ' . $thisfile . ' && basename(file) == ' . basename($thisfile) . "<br>\n";
|
||||
if ($dir . '/' . $deadfile === $thisfile) {
|
||||
#echo '<b>LIST & REMOVE FILE</b>: '.basename($deadfile) . ' == <b>REAL FILE</b>: ' . basename($thisfile) . '<br><u>Remove</u>: '.$thisfile."<br>\n";
|
||||
@unlink($thisfile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// this is original file purge
|
||||
#echo '<b>FULL PURGE EACH FILE</b>: '.$thisfile."<br>\n";
|
||||
@unlink($thisfile);
|
||||
}
|
||||
} else {
|
||||
if (is_array($purgedir) && !empty($purgedir) ) {
|
||||
foreach ($purgedir AS $pdir) {
|
||||
if (basename($thisfile) == $pdir) {
|
||||
//echo '<b><u>LIST & REMOVE EMPTY DIRECTORY</u></b>: '.$thisfile."<br><br>\n";
|
||||
@rmdir($thisfile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// this is original directory purge
|
||||
if (!$list_only) {
|
||||
#echo '<b><u>FULL PURGE DIRECTORY</u></b>: '.$thisfile."<br>\n";
|
||||
@rmdir($thisfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ if (defined('USE_MEMSNAP')) {
|
||||
}
|
||||
|
||||
// The version string
|
||||
$serendipity['version'] = '2.0-alpha1';
|
||||
$serendipity['version'] = '2.0-alpha2';
|
||||
|
||||
// Setting this to 'false' will enable debugging output. All alpa/beta/cvs snapshot versions will emit debug information by default. To increase the debug level (to enable Smarty debugging), set this flag to 'debug'.
|
||||
// Setting this to 'false' will enable debugging output. All alpha/beta/cvs snapshot versions will emit debug information by default. To increase the debug level (to enable Smarty debugging), set this flag to 'debug'.
|
||||
if (!isset($serendipity['production'])) {
|
||||
$serendipity['production'] = (preg_match('@\-(alpha|beta|cvs|rc)@', $serendipity['version']) ? false : true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user