소스 검색

add backup before update

CauseFX 4 년 전
부모
커밋
8daa0be45e
1개의 변경된 파일21개의 추가작업 그리고 18개의 파일을 삭제
  1. 21 18
      api/functions/upgrade-functions.php

+ 21 - 18
api/functions/upgrade-functions.php

@@ -96,24 +96,27 @@ trait UpgradeFunctions
 	
 	public function removeOldCustomHTML()
 	{
-		$keys = [
-			'homepageCustomHTML01Enabled' => 'homepageCustomHTMLoneEnabled',
-			'homepageCustomHTML01Auth' => 'homepageCustomHTMLoneAuth',
-			'customHTML01' => 'customHTMLone',
-			'homepageCustomHTML02Enabled' => 'homepageCustomHTMLtwoEnabled',
-			'homepageCustomHTML02Auth' => 'homepageCustomHTMLtwoAuth',
-			'customHTML02' => 'customHTMLtwo',
-		];
-		$updateItems = $this->checkForConfigKeyAddToArray($keys);
-		$updateComplete = false;
-		if (!empty($updateItems)) {
-			$updateComplete = $this->updateConfig($updateItems);
-		}
-		if ($updateComplete) {
-			$this->config = $this->config();
-			$this->removeConfigItem(['homepageOrdercustomhtml', 'homepageOrdercustomhtmlTwo', 'homepageCustomHTMLoneEnabled', 'homepageCustomHTMLoneAuth', 'customHTMLone', 'homepageCustomHTMLtwoEnabled', 'homepageCustomHTMLtwoAuth', 'customHTMLtwo']);
-			$this->config = $this->config();
-			return true;
+		$backup = $this->backupOrganizr();
+		if ($backup) {
+			$keys = [
+				'homepageCustomHTML01Enabled' => 'homepageCustomHTMLoneEnabled',
+				'homepageCustomHTML01Auth' => 'homepageCustomHTMLoneAuth',
+				'customHTML01' => 'customHTMLone',
+				'homepageCustomHTML02Enabled' => 'homepageCustomHTMLtwoEnabled',
+				'homepageCustomHTML02Auth' => 'homepageCustomHTMLtwoAuth',
+				'customHTML02' => 'customHTMLtwo',
+			];
+			$updateItems = $this->checkForConfigKeyAddToArray($keys);
+			$updateComplete = false;
+			if (!empty($updateItems)) {
+				$updateComplete = $this->updateConfig($updateItems);
+			}
+			if ($updateComplete) {
+				$this->config = $this->config();
+				$this->removeConfigItem(['homepageOrdercustomhtml', 'homepageOrdercustomhtmlTwo', 'homepageCustomHTMLoneEnabled', 'homepageCustomHTMLoneAuth', 'customHTMLone', 'homepageCustomHTMLtwoEnabled', 'homepageCustomHTMLtwoAuth', 'customHTMLtwo']);
+				$this->config = $this->config();
+				return true;
+			}
 		}
 		return false;
 	}