Commit aaac33b97e6a4cd79663f1016d7f2a891436ca8a
1 parent
f162a5dd
Merged in from DEV trunk...
KTS-3596 "Remove old search plugins when upgrading from 3.4.6 to 3.5.3" Fixed. Corrected rmdir() non-recursive issue. Committed by: Kevin Fourie Reviewed by: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@9110 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
35 additions
and
10 deletions
lib/upgrades/UpgradeFunctions.inc.php
| @@ -1312,19 +1312,44 @@ class UpgradeFunctions { | @@ -1312,19 +1312,44 @@ class UpgradeFunctions { | ||
| 1312 | // {{{ removeOldSearchPlugins | 1312 | // {{{ removeOldSearchPlugins |
| 1313 | function removeOldSearchPlugins() { | 1313 | function removeOldSearchPlugins() { |
| 1314 | global $default; | 1314 | global $default; |
| 1315 | - $oldPath1 = KT_DIR . "/templates/ktstandard/searchdashlet"; | ||
| 1316 | - if(file_exists($oldPath1)) rmdir($oldPath1); | ||
| 1317 | - $oldPath2 = KT_DIR . "/plugins/generalmetadata"; | ||
| 1318 | - if(file_exists($oldPath2)) rmdir($oldPath2); | 1315 | + $oldFile = KT_DIR . "/plugins/ktstandard/SearchDashletPlugin.php"; |
| 1316 | + if(file_exists($oldFile)) unlink($oldFile); | ||
| 1317 | + $oldFile = KT_DIR . "/plugins/ktstandard/SearchDashlet.php"; | ||
| 1318 | + if(file_exists($oldFile)) unlink($oldFile); | ||
| 1319 | + | ||
| 1320 | + // Files MUST be removed before folders and folders MUST be empty | ||
| 1321 | + $oldPath1 = KT_DIR . "/templates/ktstandard/searchdashlet/"; | ||
| 1322 | + rm_recursive($oldPath1); | ||
| 1323 | + $oldPath2 = KT_DIR . "/plugins/generalmetadata/"; | ||
| 1324 | + rm_recursive($oldPath2); | ||
| 1319 | 1325 | ||
| 1320 | - $oldFile1 = KT_DIR . "/plugins/ktstandard/SearchDashletPlugin.php"; | ||
| 1321 | - if(file_exists($oldFile1)) unlink($oldFile1); | ||
| 1322 | - $oldFile2 = KT_DIR . "/plugins/ktstandard/SearchDashlet.php"; | ||
| 1323 | - if(file_exists($oldFile2)) unlink($oldFile2); | ||
| 1324 | - | ||
| 1325 | - // FIXME: We should check that they all succeded | 1326 | + // FIXME: We should check that they all worked |
| 1326 | return true; | 1327 | return true; |
| 1328 | + } | ||
| 1327 | 1329 | ||
| 1330 | + function rm_recursive($filepath) | ||
| 1331 | + { | ||
| 1332 | + if (is_dir($filepath) && !is_link($filepath)) | ||
| 1333 | + { | ||
| 1334 | + if ($dh = opendir($filepath)) | ||
| 1335 | + { | ||
| 1336 | + while (($sf = readdir($dh)) !== false) | ||
| 1337 | + { | ||
| 1338 | + if ($sf == '.' || $sf == '..') | ||
| 1339 | + { | ||
| 1340 | + continue; | ||
| 1341 | + } | ||
| 1342 | + if (!rm_recursive($filepath.'/'.$sf)) | ||
| 1343 | + { | ||
| 1344 | + //throw new Exception( $filepath.'/'.$sf.' could not be deleted.'); | ||
| 1345 | + return false; | ||
| 1346 | + } | ||
| 1347 | + } | ||
| 1348 | + closedir($dh); | ||
| 1349 | + } | ||
| 1350 | + return rmdir($filepath); | ||
| 1351 | + } | ||
| 1352 | + return unlink($filepath); | ||
| 1328 | } | 1353 | } |
| 1329 | // }}} | 1354 | // }}} |
| 1330 | } | 1355 | } |