PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/update/manager.php +66 -3 1.7.1 → 1.8.16 View file →
@@ -511,8 +511,62 @@
511 511 return JFile::copy($dest, $backup_dirs[$dir_key] . DIRECTORY_SEPARATOR . basename($dest));
512 512 }
513 513
514 514 /**
515 + * Trigger called whenever a mirroring file has been deleted.
516 + * Checks if the destination path is recognized, and attempts to
517 + * delete the previously backed up file in order to never restore it.
518 + *
519 + * @param string $dest The path to the file just deleted.
520 + *
521 + * @return boolean True on success.
522 + *
523 + * @since 1.8.12
524 + */
525 + public static function triggerDeletionBackup($dest)
526 + {
527 + // seek the key of the uploaded dir
528 + $dir_key = false;
529 + foreach (self::getUploadBackupDirs(true) as $key => $path) {
530 + if (strpos($dest, $path) !== false) {
531 + $dir_key = $key;
532 + break;
533 + }
534 + }
535 + if (!$dir_key) {
536 + // could not recognize upload dir path from destination file
537 + return false;
538 + }
539 +
540 + // always make sure the upload backup dirs are set for bc with those that installed a previous version of the plugin
541 + if (!self::installUploadBackup()) {
542 + // cannot proceed because backup folders are not set
543 + return false;
544 + }
545 +
546 + // import the File class
547 + JLoader::import('adapter.filesystem.file');
548 +
549 + // get the backup upload dir path for this type of file
550 + $backup_dirs = self::getUploadBackupDirs();
551 + if (!isset($backup_dirs[$dir_key])) {
552 + // do not proceed
553 + return false;
554 + }
555 +
556 + // build the full file path on the mirroring directory
557 + $mirroredFilePath = $backup_dirs[$dir_key] . DIRECTORY_SEPARATOR . basename($dest);
558 +
559 + if (!is_file($mirroredFilePath)) {
560 + // do not proceed
561 + return false;
562 + }
563 +
564 + // delete the file from its backup dir
565 + return JFile::delete($mirroredFilePath);
566 + }
567 +
568 + /**
515 569 * This method should be called after importing a full backup
516 570 * copy from another Vik Booking installation. It recursively
517 571 * parses all the upload backup directories to mirror. This
518 572 * way, installing a future update will be safe.
@@ -739,15 +793,24 @@
739 793
740 794 $ok = true;
741 795
742 796 $sql_base = VIKBOOKING_BASE . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . 'mysql' . DIRECTORY_SEPARATOR;
797 + $sqlFiles = glob($sql_base . '*.sql');
743 798
799 + /**
800 + * Make sure the SQL files are properly executed per ascending version rather than alphabetically.
801 + *
802 + * @since 1.8.3
803 + */
804 + usort($sqlFiles, function($a, $b) {
805 + return version_compare(basename($a, '.sql'), basename($b, '.sql'));
806 + });
807 +
744 808 try
745 809 {
746 - foreach (glob($sql_base . '*.sql') as $file)
810 + foreach ($sqlFiles as $file)
747 811 {
748 - $name = basename($file);
749 - $sql_v = substr($name, 0, strrpos($name, '.'));
812 + $sql_v = basename($file, '.sql');
750 813
751 814 if (version_compare($sql_v, $version, '>'))
752 815 {
753 816 // in case the SQL version is newer, execute the queries listed in the file