From d282375fd1011726ccd9db0104805c07ffbc4631 Mon Sep 17 00:00:00 2001 From: "s.samko" Date: Wed, 27 Mar 2024 17:05:21 +0000 Subject: [PATCH] Fix #1872 - Admin - Install Module - "Back to Module Loader" shows page with header only --- modules/Administration/UpgradeHistory.php | 43 ++++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/modules/Administration/UpgradeHistory.php b/modules/Administration/UpgradeHistory.php index 26422adbf1d..d86584ecc52 100755 --- a/modules/Administration/UpgradeHistory.php +++ b/modules/Administration/UpgradeHistory.php @@ -1,14 +1,12 @@ filename))).'-restore'; $more_recent_patch_backup_path = clean_path(remove_file_extension(from_html($more_recent_patch->filename))).'-restore'; - $patch_to_check_timestamp = TimeDate::getInstance()->fromUser($patch_to_check->date_entered)->getTimestamp(); - $more_resent_patch_timestamp = TimeDate::getInstance()->fromUser($more_recent_patch->date_entered)->getTimestamp(); + $patch_to_check_timestamp = $this->getPackageTimestamp($this->getPackageDateString($patch_to_check)); + $more_resent_patch_timestamp = $this->getPackageTimestamp($this->getPackageDateString($more_recent_patch)); if ( $this->foundConflict($patch_to_check_backup_path, $more_recent_patch_backup_path) && ($more_resent_patch_timestamp >= $patch_to_check_timestamp) @@ -305,4 +303,31 @@ public function retrieve($id = -1, $encode=true, $deleted=true) { return parent::retrieve($id, $encode, false); //ignore the deleted filter. the table does not have the deleted column in it. } + + /** + * Returns correct string for getting timestamp if the package has just been installed; + * @param UpgradeHistory $bean + * @return string + */ + protected function getPackageDateString(UpgradeHistory $bean): string + { + global $timedate; + + if (!$bean->date_entered) { + return $timedate->to_display_date_time($bean->date_modified); + } + + return $bean->date_entered; + } + + /** + * Handler to get timestamp if the package has just been installed; + * @param $date + * @return int + */ + protected function getPackageTimestamp($date): int + { + global $timedate; + return $timedate->fromUser($date)->getTimestamp(); + } }