GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e41d1f...51d0da )
by Liuta
03:06
created
includes/class-xcloner-remote-storage.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Mhetreramesh\Flysystem\BackblazeAdapter;
19 19
 use ChrisWhite\B2\Client as B2Client;
20 20
 
21
-class Xcloner_Remote_Storage{
21
+class Xcloner_Remote_Storage {
22 22
 	
23 23
 	private $storage_fields = array(
24 24
 					"option_prefix" => "xcloner_",
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 	{
93 93
 		$this->xcloner_sanitization 	= new Xcloner_Sanitization($hash);
94 94
 		$this->xcloner_file_system 		= new Xcloner_File_System($hash);
95
-		$this->logger 					= new XCloner_Logger("xcloner_remote_storage", $hash);
96
-		$this->xcloner 					= new Xcloner();
95
+		$this->logger = new XCloner_Logger("xcloner_remote_storage", $hash);
96
+		$this->xcloner = new Xcloner();
97 97
 	}
98 98
 	
99 99
 	public function get_available_storages()
100 100
 	{
101 101
 		$return = array();
102
-		foreach($this->storage_fields as $storage=>$data)
102
+		foreach ($this->storage_fields as $storage=>$data)
103 103
 		{
104 104
 			$check_field = $this->storage_fields["option_prefix"].$storage."_enable";
105
-			if(get_option($check_field))
105
+			if (get_option($check_field))
106 106
 				$return[$storage] = $data['text'];
107 107
 		}
108 108
 		
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
 		$storage = $this->xcloner_sanitization->sanitize_input_as_string($action);
115 115
 		$this->logger->debug(sprintf("Saving the remote storage %s options", strtoupper($action)));	
116 116
 		
117
-		if(is_array($this->storage_fields[$storage]))
117
+		if (is_array($this->storage_fields[$storage]))
118 118
 		{
119
-			foreach($this->storage_fields[$storage] as $field=>$validation)
119
+			foreach ($this->storage_fields[$storage] as $field=>$validation)
120 120
 			{
121 121
 				$check_field = $this->storage_fields["option_prefix"].$field;
122 122
 				$sanitize_method = "sanitize_input_as_".$validation;
123 123
 				
124
-				if(!isset($_POST[$check_field]))
124
+				if (!isset($_POST[$check_field]))
125 125
 					$_POST[$check_field] = 0;
126 126
 				
127
-				if(!method_exists($this->xcloner_sanitization, $sanitize_method))
127
+				if (!method_exists($this->xcloner_sanitization, $sanitize_method))
128 128
 					$sanitize_method = "sanitize_input_as_string";
129 129
 					
130 130
 				$sanitized_value = $this->xcloner_sanitization->$sanitize_method($_POST[$check_field]);
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 			$this->xcloner->trigger_message(__("%s storage settings saved.", 'xcloner-backup-and-restore'), "success", ucfirst($action));
135 135
 		}
136 136
 		
137
-		if(isset($_POST['connection_check']) && $_POST['connection_check'])
137
+		if (isset($_POST['connection_check']) && $_POST['connection_check'])
138 138
 		{
139
-			try{
139
+			try {
140 140
 				$this->verify_filesystem($action);
141 141
 				$this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", ucfirst($action));
142 142
 				$this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action)));	
143
-			}catch(Exception $e){
143
+			}catch (Exception $e) {
144 144
 				$this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", ucfirst($action));
145 145
 			}
146 146
 		}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		
154 154
 		$this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type)));	
155 155
 		
156
-		if(!method_exists($this, $method))
156
+		if (!method_exists($this, $method))
157 157
 			return false;
158 158
 		
159 159
 		list($adapter, $filesystem) = $this->$method();
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 		$test_file = substr(".xcloner_".md5(time()), 0, 15);
162 162
 			
163 163
 		//testing write access
164
-		if(!$filesystem->write($test_file, "data"))
165
-			throw new Exception(__("Could not write data",'xcloner-backup-and-restore'));
164
+		if (!$filesystem->write($test_file, "data"))
165
+			throw new Exception(__("Could not write data", 'xcloner-backup-and-restore'));
166 166
 		$this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type)));	
167 167
 		
168 168
 		//testing read access
169
-		if(!$filesystem->read($test_file))
170
-			throw new Exception(__("Could not read data",'xcloner-backup-and-restore'));
169
+		if (!$filesystem->read($test_file))
170
+			throw new Exception(__("Could not read data", 'xcloner-backup-and-restore'));
171 171
 		$this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type)));		
172 172
 		
173 173
 		//delete test file
174
-		if(!$filesystem->delete($test_file))
175
-			throw new Exception(__("Could not delete data",'xcloner-backup-and-restore'));
174
+		if (!$filesystem->delete($test_file))
175
+			throw new Exception(__("Could not delete data", 'xcloner-backup-and-restore'));
176 176
 		$this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type)));		
177 177
 	}
178 178
 	
179 179
 	public function upload_backup_to_storage($file, $storage)
180 180
 	{
181
-		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
181
+		if (!$this->xcloner_file_system->get_storage_filesystem()->has($file))
182 182
 			return false;
183 183
 			
184 184
 		$method = "get_".$storage."_filesystem";	
185 185
 		
186
-		if(!method_exists($this, $method))
186
+		if (!method_exists($this, $method))
187 187
 			return false;
188 188
 			
189 189
 		list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method();
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		
194 194
 		$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $file, strtoupper($storage)), array(""));
195 195
 		
196
-		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
196
+		if (!$this->xcloner_file_system->get_storage_filesystem()->has($file))
197 197
 		{
198 198
 			$this->logger->info(sprintf("File not found %s in local storage", $file));
199 199
 			return false;
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 		
202 202
 		$backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($file);
203 203
 
204
-		if(!$remote_storage_filesystem->updateStream($file, $backup_file_stream))
204
+		if (!$remote_storage_filesystem->updateStream($file, $backup_file_stream))
205 205
 		{
206 206
 			$this->logger->info(sprintf("Could not transfer file %s", $file));
207 207
 			return false;
208 208
 		}
209 209
 		
210
-		if($this->xcloner_file_system->is_multipart($file))
210
+		if ($this->xcloner_file_system->is_multipart($file))
211 211
 		{
212 212
 			$parts = $this->xcloner_file_system->get_multipart_files($file);
213
-			if(is_array($parts))
214
-				foreach($parts as $part_file)
213
+			if (is_array($parts))
214
+				foreach ($parts as $part_file)
215 215
 				{
216 216
 					$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $part_file, strtoupper($storage)), array(""));
217 217
 					
218 218
 					$backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($part_file);
219
-					if(!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream))
219
+					if (!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream))
220 220
 						return false;
221 221
 				}
222 222
 		}
@@ -232,19 +232,19 @@  discard block
 block discarded – undo
232 232
 	public function clean_remote_storage($storage, $remote_storage_filesystem)
233 233
 	{
234 234
 		$check_field = $this->storage_fields["option_prefix"].$storage."_cleanup_days";
235
-		if($expire_days = get_option($check_field))
235
+		if ($expire_days = get_option($check_field))
236 236
 		{
237 237
 			$this->logger->info(sprintf("Doing %s remote storage cleanup for %s days limit", strtoupper($storage), $expire_days));
238 238
 			$files = $remote_storage_filesystem->listContents();
239 239
 			
240 240
 			$current_timestamp = strtotime("-".$expire_days." days");
241 241
 			
242
-			if(is_array($files))
243
-			foreach($files as $file)
242
+			if (is_array($files))
243
+			foreach ($files as $file)
244 244
 			{
245 245
 				$file['timestamp'] = $remote_storage_filesystem->getTimestamp($file['path']);
246 246
 				
247
-				if($current_timestamp >= $file['timestamp'])
247
+				if ($current_timestamp >= $file['timestamp'])
248 248
 				{
249 249
 					$remote_storage_filesystem->delete($file['path']);
250 250
 					$this->logger->info("Deleting remote file ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$expire_days));
Please login to merge, or discard this patch.