Skip to content

Commit

Permalink
Additional fixes to the upgrade scripts. Now clears all the caches an…
Browse files Browse the repository at this point in the history
…d the remove_headlinecontroller is disabled, but kept as an example script.
  • Loading branch information
dleffler committed Jun 14, 2011
1 parent 67013ee commit 4398144
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 21 deletions.
24 changes: 17 additions & 7 deletions install/pages/upgrade-2.php
Expand Up @@ -122,18 +122,20 @@
<tbody>
<?php
$row = "even";
$line = 0;
foreach ($tables as $table => $statusnum) {
if ($statusnum != TMP_TABLE_EXISTED) {
?>

<tr class="<?php echo $row ?>">
<td>
<?php echo gt($table) ?>
</td>
<td>
<?php if ($statusnum == TMP_TABLE_EXISTED) { ?>
<!-- <div style="color: blue; font-weight: bold">-->
<!-- --><?php //echo gt('Table Exists') ?>
<!-- </div>-->
<div style="color: blue; font-weight: bold">
<?php echo gt('Table Exists') ?>
</div>
<?php } elseif ($statusnum == TMP_TABLE_INSTALLED) { ?>
<div style="color: green; font-weight: bold">
<?php echo gt('Succeeded') ?>
Expand All @@ -153,10 +155,18 @@
<?php } ?>
</td>
</tr>
<?php
$row = $row == "even" ? "odd" : "even";
} ?>
<?php
$row = $row == "even" ? "odd" : "even";
$line++;
}
?>
<tbody>
</table>
<?php
}
if ($line == 0) {
echo "<b>No Tables Were Changed!</b>";
}
?>

<a class="awesome large green" href="?page=upgrade-3"><?php echo gt('Continue Upgrade') ?></a>
50 changes: 47 additions & 3 deletions install/upgrades/clear_cache.php
Expand Up @@ -20,12 +20,56 @@ class clear_cache extends upgradescript {
protected $from_version = '1.99.0';
// protected $to_version = '1.99.2';

function name() { return "Clear the Cache"; }
function name() { return "Clear the Caches"; }

function upgrade() {
$files = exponent_theme_remove_smarty_cache();
return count($files['removed'])." files were removed from the cache.";
// work our way through all the tmp files and remove them
if (!defined('SYS_FILES')) include_once(BASE.'subsystems/files.php');
$files = array(
BASE.'tmp/cache',
// BASE.'tmp/css', // css cache??
BASE.'tmp/mail',
BASE.'tmp/minify', // minify cache
BASE.'tmp/pods',
BASE.'tmp/rsscache',
BASE.'tmp/views_c', // smarty cache
);

// delete the files.
$removed = 0;
$errors = 0;
foreach ($files as $file) {
$files = exponent_files_remove_files_in_directory($file);
$removed += count($files['removed']);
$errors += count($files['not_removed']);
}

// delete the entire img_cache and recreate the folder
if (file_exists(BASE.'tmp/img_cache')) $this->cleardir_recursive(BASE.'tmp/img_cache');

return "Caches were cleared.<br>".$errors." files could not be removed.";
}

/**
* recursively clear a directories contents, but leave the directory
* @param $dir
*/
function cleardir_recursive($dir) {
$files = scandir($dir);
array_shift($files); // remove '.' from array
array_shift($files); // remove '..' from array
foreach ($files as $file) {
if (substr($file, 0, 1) != '.') { // don't remove dot files
$file = $dir . '/' . $file;
if (is_dir($file)) {
cleardir_recursive($file);
rmdir($file);
} else {
unlink($file);
}
}
}
// rmdir($dir);
}
}

Expand Down
19 changes: 13 additions & 6 deletions install/upgrades/install_tables.php
Expand Up @@ -125,7 +125,9 @@ function upgrade() {
<tbody>
<?php
$row = "even";
$line = 0;
foreach ($tables as $table => $statusnum) {
if ($statusnum != TMP_TABLE_EXISTED) {
?>

<tr class="<?php echo $row ?>">
Expand All @@ -134,9 +136,9 @@ function upgrade() {
</td>
<td>
<?php if ($statusnum == TMP_TABLE_EXISTED) { ?>
<!-- <div style="color: blue; font-weight: bold">-->
<!-- --><?php //echo gt('Table Exists') ?>
<!-- </div>-->
<div style="color: blue; font-weight: bold">
<?php echo gt('Table Exists') ?>
</div>
<?php } elseif ($statusnum == TMP_TABLE_INSTALLED) { ?>
<div style="color: green; font-weight: bold">
<?php echo gt('Succeeded') ?>
Expand All @@ -157,12 +159,17 @@ function upgrade() {
</td>
</tr>
<?php
$row = $row == "even" ? "odd" : "even";
} ?>
$row = $row == "even" ? "odd" : "even";
$line++;
}
?>
<tbody>
</table>
<?php
}
if ($line == 0) {
echo "<p class=\"success\">No Tables Were Changed!</p>";
}
}
}

?>
8 changes: 3 additions & 5 deletions install/upgrades/remove_headlinecontroller.php
Expand Up @@ -17,8 +17,9 @@
##################################################

class remove_headlinecontroller extends upgradescript {
protected $from_version = '1.99.0';
protected $to_version = '2.0.1';
// TODO next two lines are commented out to disable this script
// protected $from_version = '1.99.0';
// protected $to_version = '2.0.1';

function name() { return "Remove the (deprecated) Headline Controller"; }

Expand Down Expand Up @@ -79,9 +80,6 @@ function upgrade() {
$headlines_converted += 1;
}

// FIXME - remove when final
return "TEST - We're NOT removing the headline table nor the files yet...<br>".$modules_converted." Headline modules were converted.<br>".$headlines_converted." Headlines were converted.<br>";

// delete headline table
$db->dropTable('headline');

Expand Down

0 comments on commit 4398144

Please sign in to comment.