JobBackupDataDto.php
812 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup\Dto\Job; |
| 4 | |
| 5 | use WPStaging\Backup\Dto\Interfaces\RemoteUploadDtoInterface; |
| 6 | use WPStaging\Backup\Dto\JobDataDto; |
| 7 | use WPStaging\Backup\Dto\Traits\IsExportingTrait; |
| 8 | use WPStaging\Backup\Dto\Traits\IsExcludingTrait; |
| 9 | use WPStaging\Backup\Dto\Traits\RemoteUploadTrait; |
| 10 | use WPStaging\Backup\Entity\BackupMetadata; |
| 11 | use WPStaging\Backup\Service\ZlibCompressor; |
| 12 | use WPStaging\Core\WPStaging; |
| 13 | use WPStaging\Framework\Facades\Hooks; |
| 14 | |
| 15 | class JobBackupDataDto extends JobDataDto implements RemoteUploadDtoInterface |
| 16 | { |
| 17 | use IsExportingTrait; |
| 18 | use IsExcludingTrait; |
| 19 | use RemoteUploadTrait; |
| 20 | |
| 21 | /** @var string|null */ |
| 22 | private $name; |
| 23 | |
| 24 | /** @var array */ |
| 25 | private $excludedDirectories = []; |
| 26 | |
| 27 | /** @var int */ |
| 28 | private $totalDirectories; |
| 29 | |
| 30 | /** @var int The number of files in the backup index */ |
| 31 | private $totalFiles; |
| 32 | |
| 33 | /** @var array The number of files in backup parts */ |
| 34 | private $filesInParts = []; |
| 35 | |
| 36 | /** @var int The number of files the FilesystemScanner discovered */ |
| 37 | private $discoveredFiles; |
| 38 | |
| 39 | /** @var array The number of files the FilesystemScanner discovered in themes,plugins,muplugins,uploads,others */ |
| 40 | private $discoveredFilesArray = []; |
| 41 | |
| 42 | /** @var string */ |
| 43 | private $databaseFile; |
| 44 | |
| 45 | /** |
| 46 | * @var int If a file couldn't be processed in a single request, |
| 47 | * this property holds how many bytes were written thus far |
| 48 | * so that the backup can start writing from this byte onwards. |
| 49 | */ |
| 50 | private $fileBeingBackupWrittenBytes; |
| 51 | |
| 52 | /** @var int */ |
| 53 | private $totalRowsBackup; |
| 54 | |
| 55 | /** @var int */ |
| 56 | private $tableRowsOffset = 0; |
| 57 | |
| 58 | /** @var int */ |
| 59 | private $totalRowsOfTableBeingBackup = 0; |
| 60 | |
| 61 | /** @var int reset to PHP_INT_MIN for each table */ |
| 62 | private $lastInsertId; |
| 63 | |
| 64 | /** @var array */ |
| 65 | private $tablesToBackup = []; |
| 66 | |
| 67 | /** @var array */ |
| 68 | private $nonWpTables = []; |
| 69 | |
| 70 | /** @var int The size in bytes of the database in this backup */ |
| 71 | private $databaseFileSize = 0; |
| 72 | |
| 73 | /** @var int The size in bytes of the filesystem in this backup */ |
| 74 | private $filesystemSize = 0; |
| 75 | |
| 76 | /** @var int The number of requests that the Discovering Files task has executed so far */ |
| 77 | private $discoveringFilesRequests = 0; |
| 78 | |
| 79 | /** @var string The cron to repeat this backup, if scheduled. */ |
| 80 | private $scheduleRecurrence; |
| 81 | |
| 82 | /** @var array The hour and minute to repeat this backup, if scheduled. */ |
| 83 | private $scheduleTime = []; |
| 84 | |
| 85 | /** @var int How many backups to keep, if scheduled. */ |
| 86 | private $scheduleRotation; |
| 87 | |
| 88 | /** @var string The absolute path to this .wpstg file */ |
| 89 | private $backupFilePath; |
| 90 | |
| 91 | /** @var string If set, this backup was created as part of this schedule ID. */ |
| 92 | private $scheduleId; |
| 93 | |
| 94 | /** @var bool Should the backup be validated for each file once the backup is created. */ |
| 95 | private $isValidateBackupFiles = false; |
| 96 | |
| 97 | /** @var bool Should this scheduled backup be created right now. Matters only if this backup is repeated on schedule */ |
| 98 | private $isCreateScheduleBackupNow; |
| 99 | |
| 100 | /** @var bool Should the backup be created in background? */ |
| 101 | private $isCreateBackupInBackground; |
| 102 | |
| 103 | /** @var array Site selected to backup */ |
| 104 | private $sitesToBackup = []; |
| 105 | |
| 106 | /** |
| 107 | * is network subsite or network main site backup |
| 108 | * @var bool */ |
| 109 | private $isNetworkSiteBackup = false; |
| 110 | |
| 111 | /** |
| 112 | * @var array |
| 113 | * Store max index for each category |
| 114 | */ |
| 115 | private $fileBackupIndices = []; |
| 116 | |
| 117 | /** @var int */ |
| 118 | private $maxDbPartIndex = 0; |
| 119 | |
| 120 | /** @var int */ |
| 121 | private $currentMultipartFileInfoIndex = 0; |
| 122 | |
| 123 | /** @var array */ |
| 124 | private $multipartFilesInfo = []; |
| 125 | |
| 126 | /** |
| 127 | * @var array<string, int> |
| 128 | * Store total size for each category |
| 129 | */ |
| 130 | private $categorySizes = []; |
| 131 | |
| 132 | /** @var string */ |
| 133 | private $backupType; |
| 134 | |
| 135 | /** @var int */ |
| 136 | private $subsiteBlogId; |
| 137 | |
| 138 | /** @var int */ |
| 139 | private $filePartIndex = 0; |
| 140 | |
| 141 | /** |
| 142 | * @return string|null |
| 143 | */ |
| 144 | public function getName() |
| 145 | { |
| 146 | return $this->name; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Hydrated dynamically. |
| 151 | * |
| 152 | * @param string|null $name |
| 153 | */ |
| 154 | public function setName($name) |
| 155 | { |
| 156 | $this->name = $name; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * @return array|null |
| 161 | */ |
| 162 | public function getExcludedDirectories() |
| 163 | { |
| 164 | return (array)$this->excludedDirectories; |
| 165 | } |
| 166 | |
| 167 | public function setExcludedDirectories(array $excludedDirectories = []) |
| 168 | { |
| 169 | $this->excludedDirectories = $excludedDirectories; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * @return int |
| 174 | */ |
| 175 | public function getTotalDirectories() |
| 176 | { |
| 177 | return $this->totalDirectories; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * @param int $totalDirectories |
| 182 | */ |
| 183 | public function setTotalDirectories($totalDirectories) |
| 184 | { |
| 185 | $this->totalDirectories = $totalDirectories; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @return int |
| 190 | */ |
| 191 | public function getTotalFiles() |
| 192 | { |
| 193 | return $this->totalFiles; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @param int $totalFiles |
| 198 | */ |
| 199 | public function setTotalFiles($totalFiles) |
| 200 | { |
| 201 | $this->totalFiles = $totalFiles; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * @return int |
| 206 | */ |
| 207 | public function getDiscoveredFiles() |
| 208 | { |
| 209 | return $this->discoveredFiles; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * @param int $discoveredFiles |
| 214 | */ |
| 215 | public function setDiscoveredFiles($discoveredFiles) |
| 216 | { |
| 217 | $this->discoveredFiles = $discoveredFiles; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * @return string |
| 222 | */ |
| 223 | public function getDatabaseFile() |
| 224 | { |
| 225 | return $this->databaseFile; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * @param string $databaseFile |
| 230 | */ |
| 231 | public function setDatabaseFile($databaseFile) |
| 232 | { |
| 233 | $this->databaseFile = $databaseFile; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * @return int |
| 238 | */ |
| 239 | public function getTableRowsOffset() |
| 240 | { |
| 241 | return (int)$this->tableRowsOffset; |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * @param int $tableRowsOffset |
| 246 | */ |
| 247 | public function setTableRowsOffset($tableRowsOffset) |
| 248 | { |
| 249 | $this->tableRowsOffset = (int)$tableRowsOffset; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * @return int |
| 254 | */ |
| 255 | public function getTotalRowsBackup() |
| 256 | { |
| 257 | return (int)$this->totalRowsBackup; |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * @param int $totalRowsBackup |
| 262 | */ |
| 263 | public function setTotalRowsBackup($totalRowsBackup) |
| 264 | { |
| 265 | $this->totalRowsBackup = (int)$totalRowsBackup; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * @return int |
| 270 | */ |
| 271 | public function getFileBeingBackupWrittenBytes() |
| 272 | { |
| 273 | return (int)$this->fileBeingBackupWrittenBytes; |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * @param int $fileBeingBackupWrittenBytes |
| 278 | */ |
| 279 | public function setFileBeingBackupWrittenBytes($fileBeingBackupWrittenBytes) |
| 280 | { |
| 281 | $this->fileBeingBackupWrittenBytes = (int)$fileBeingBackupWrittenBytes; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * @return array |
| 286 | */ |
| 287 | public function getTablesToBackup() |
| 288 | { |
| 289 | return (array)$this->tablesToBackup; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * @param array $tablesToBackup |
| 294 | */ |
| 295 | public function setTablesToBackup($tablesToBackup) |
| 296 | { |
| 297 | $this->tablesToBackup = (array)$tablesToBackup; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * @return array |
| 302 | */ |
| 303 | public function getNonWpTables() |
| 304 | { |
| 305 | return (array)$this->nonWpTables; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * @param array $nonWpTables |
| 310 | */ |
| 311 | public function setNonWpTables($nonWpTables) |
| 312 | { |
| 313 | $this->nonWpTables = (array)$nonWpTables; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * @return int |
| 318 | */ |
| 319 | public function getTotalRowsOfTableBeingBackup() |
| 320 | { |
| 321 | return (int)$this->totalRowsOfTableBeingBackup; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * @param int $totalRowsOfTableBeingBackup |
| 326 | */ |
| 327 | public function setTotalRowsOfTableBeingBackup($totalRowsOfTableBeingBackup) |
| 328 | { |
| 329 | $this->totalRowsOfTableBeingBackup = (int)$totalRowsOfTableBeingBackup; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * @return int |
| 334 | */ |
| 335 | public function getDatabaseFileSize() |
| 336 | { |
| 337 | return $this->databaseFileSize; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * @param int $databaseFileSize |
| 342 | */ |
| 343 | public function setDatabaseFileSize($databaseFileSize) |
| 344 | { |
| 345 | $this->databaseFileSize = $databaseFileSize; |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * @return int |
| 350 | */ |
| 351 | public function getFilesystemSize() |
| 352 | { |
| 353 | return $this->filesystemSize; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * @param int $filesystemSize |
| 358 | */ |
| 359 | public function setFilesystemSize($filesystemSize) |
| 360 | { |
| 361 | $this->filesystemSize = $filesystemSize; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * @return int |
| 366 | */ |
| 367 | public function getDiscoveringFilesRequests() |
| 368 | { |
| 369 | return $this->discoveringFilesRequests; |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * @param int $discoveringFilesRequests |
| 374 | */ |
| 375 | public function setDiscoveringFilesRequests($discoveringFilesRequests) |
| 376 | { |
| 377 | $this->discoveringFilesRequests = $discoveringFilesRequests; |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * @see Cron For WP STAGING cron recurrences. |
| 382 | * |
| 383 | * @return string A WP STAGING cron schedule |
| 384 | */ |
| 385 | public function getScheduleRecurrence() |
| 386 | { |
| 387 | return $this->scheduleRecurrence; |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * @param string $scheduleRecurrence |
| 392 | */ |
| 393 | public function setScheduleRecurrence($scheduleRecurrence) |
| 394 | { |
| 395 | $this->scheduleRecurrence = $scheduleRecurrence; |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * @return array H:i time format, expected to be accurate to the site's timezone, example: 00:00 |
| 400 | */ |
| 401 | public function getScheduleTime() |
| 402 | { |
| 403 | return $this->scheduleTime; |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * @param array $scheduleTime Hour and Minute ['00', '00'] |
| 408 | */ |
| 409 | public function setScheduleTime(array $scheduleTime) |
| 410 | { |
| 411 | $this->scheduleTime = $scheduleTime; |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * @return int How many backups to keep, example: 1 |
| 416 | */ |
| 417 | public function getScheduleRotation() |
| 418 | { |
| 419 | return $this->scheduleRotation; |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * @param int $scheduleRotation |
| 424 | */ |
| 425 | public function setScheduleRotation($scheduleRotation) |
| 426 | { |
| 427 | $this->scheduleRotation = $scheduleRotation; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * @return string |
| 432 | */ |
| 433 | public function getBackupFilePath() |
| 434 | { |
| 435 | return $this->backupFilePath; |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * @param string $backupFilePath |
| 440 | */ |
| 441 | public function setBackupFilePath($backupFilePath) |
| 442 | { |
| 443 | $this->backupFilePath = $backupFilePath; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * @return string|null |
| 448 | */ |
| 449 | public function getScheduleId() |
| 450 | { |
| 451 | return $this->scheduleId; |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * @param string $scheduleId |
| 456 | */ |
| 457 | public function setScheduleId($scheduleId) |
| 458 | { |
| 459 | $this->scheduleId = $scheduleId; |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * @return bool |
| 464 | */ |
| 465 | public function getIsCreateScheduleBackupNow() |
| 466 | { |
| 467 | return $this->isCreateScheduleBackupNow; |
| 468 | } |
| 469 | |
| 470 | /** |
| 471 | * @param bool $isCreateScheduleBackupNow |
| 472 | */ |
| 473 | public function setIsCreateScheduleBackupNow($isCreateScheduleBackupNow) |
| 474 | { |
| 475 | $this->isCreateScheduleBackupNow = (bool)$isCreateScheduleBackupNow; |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | * @return bool |
| 480 | */ |
| 481 | public function getIsCreateBackupInBackground(): bool |
| 482 | { |
| 483 | return (bool)$this->isCreateBackupInBackground; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Cannot strict type it yet, otherwise it might throw error for older scheduled backup |
| 488 | * @param bool $isCreateBackupInBackground |
| 489 | */ |
| 490 | public function setIsCreateBackupInBackground($isCreateBackupInBackground) |
| 491 | { |
| 492 | $this->isCreateBackupInBackground = (bool)$isCreateBackupInBackground; |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * @return array|null |
| 497 | */ |
| 498 | public function getSitesToBackup() |
| 499 | { |
| 500 | return (array)$this->sitesToBackup; |
| 501 | } |
| 502 | |
| 503 | public function setSitesToBackup(array $sitesToBackup = []) |
| 504 | { |
| 505 | $this->sitesToBackup = $sitesToBackup; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * @return array |
| 510 | */ |
| 511 | public function getDiscoveredFilesArray() |
| 512 | { |
| 513 | return $this->discoveredFilesArray; |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * @param array $discoveredFiles |
| 518 | */ |
| 519 | public function setDiscoveredFilesArray($discoveredFiles = []) |
| 520 | { |
| 521 | $this->discoveredFilesArray = $discoveredFiles; |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * @param string $category |
| 526 | * @return int |
| 527 | */ |
| 528 | public function getDiscoveredFilesByCategory($category) |
| 529 | { |
| 530 | if (!array_key_exists($category, $this->discoveredFilesArray)) { |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | return $this->discoveredFilesArray[$category]; |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * @param string $category |
| 539 | * @param int $discoveredFiles |
| 540 | */ |
| 541 | public function setDiscoveredFilesByCategory($category, $discoveredFiles) |
| 542 | { |
| 543 | $this->discoveredFilesArray[$category] = $discoveredFiles; |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * @return array |
| 548 | */ |
| 549 | public function getFilesInParts() |
| 550 | { |
| 551 | return $this->filesInParts; |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * @param array $filesInParts |
| 556 | */ |
| 557 | public function setFilesInParts($filesInParts = []) |
| 558 | { |
| 559 | $this->filesInParts = $filesInParts; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * @param string $category |
| 564 | * @param int $categoryIndex |
| 565 | * @return int |
| 566 | */ |
| 567 | public function getFilesInPart($category, $categoryIndex) |
| 568 | { |
| 569 | if (!array_key_exists($category, $this->filesInParts)) { |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | if (!isset($this->filesInParts[$category][$categoryIndex])) { |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | return $this->filesInParts[$category][$categoryIndex]; |
| 578 | } |
| 579 | |
| 580 | /** |
| 581 | * @param string $category |
| 582 | * @param int $categoryIndex |
| 583 | * @param int $files |
| 584 | */ |
| 585 | public function setFilesInPart($category, $categoryIndex, $files) |
| 586 | { |
| 587 | if (!array_key_exists($category, $this->filesInParts)) { |
| 588 | $this->filesInParts[$category] = []; |
| 589 | } |
| 590 | |
| 591 | $this->filesInParts[$category][$categoryIndex] = $files; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * @return array |
| 596 | */ |
| 597 | public function getFileBackupIndices() |
| 598 | { |
| 599 | return $this->fileBackupIndices; |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * @param array $fileBackupIndices |
| 604 | */ |
| 605 | public function setFileBackupIndices($fileBackupIndices = []) |
| 606 | { |
| 607 | $this->fileBackupIndices = $fileBackupIndices; |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * @return int |
| 612 | */ |
| 613 | public function getMaxDbPartIndex() |
| 614 | { |
| 615 | return $this->maxDbPartIndex; |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * @param int $maxDbPartIndex |
| 620 | */ |
| 621 | public function setMaxDbPartIndex($maxDbPartIndex) |
| 622 | { |
| 623 | $this->maxDbPartIndex = $maxDbPartIndex; |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * @return int |
| 628 | */ |
| 629 | public function getCurrentMultipartFileInfoIndex() |
| 630 | { |
| 631 | return $this->currentMultipartFileInfoIndex; |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * @param int $currentMultipartFileInfoIndex |
| 636 | */ |
| 637 | public function setCurrentMultipartFileInfoIndex($currentMultipartFileInfoIndex) |
| 638 | { |
| 639 | $this->currentMultipartFileInfoIndex = $currentMultipartFileInfoIndex; |
| 640 | } |
| 641 | |
| 642 | /** |
| 643 | * @return array |
| 644 | */ |
| 645 | public function getMultipartFilesInfo() |
| 646 | { |
| 647 | return $this->multipartFilesInfo; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * @param array $multipartFilesInfo |
| 652 | */ |
| 653 | public function setMultipartFilesInfo($multipartFilesInfo) |
| 654 | { |
| 655 | $this->multipartFilesInfo = $multipartFilesInfo; |
| 656 | } |
| 657 | |
| 658 | /** |
| 659 | * @param array $multipartFileInfo |
| 660 | */ |
| 661 | public function addMultipartFileInfo($multipartFileInfo) |
| 662 | { |
| 663 | $this->multipartFilesInfo[] = $multipartFileInfo; |
| 664 | } |
| 665 | |
| 666 | /** |
| 667 | * @param array $multipartFileInfo |
| 668 | * @param int $index |
| 669 | */ |
| 670 | public function updateMultipartFileInfo($multipartFileInfo, $index) |
| 671 | { |
| 672 | $this->multipartFilesInfo[$index] = $multipartFileInfo; |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * @param int $lastInsertId |
| 677 | */ |
| 678 | public function setLastInsertId($lastInsertId) |
| 679 | { |
| 680 | $this->lastInsertId = $lastInsertId; |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * @return int |
| 685 | */ |
| 686 | public function getLastInsertId() |
| 687 | { |
| 688 | return $this->lastInsertId; |
| 689 | } |
| 690 | |
| 691 | /** |
| 692 | * @param array<string, int> $categorySizes |
| 693 | */ |
| 694 | public function setCategorySizes($categorySizes) |
| 695 | { |
| 696 | $this->categorySizes = $categorySizes; |
| 697 | } |
| 698 | |
| 699 | /** |
| 700 | * @return array<string, int> |
| 701 | */ |
| 702 | public function getCategorySizes() |
| 703 | { |
| 704 | return $this->categorySizes; |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * @return int |
| 709 | */ |
| 710 | public function getFilePartIndex(): int |
| 711 | { |
| 712 | return $this->filePartIndex; |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * @param int $index |
| 717 | * @return void |
| 718 | */ |
| 719 | public function setFilePartIndex(int $index = 0) |
| 720 | { |
| 721 | $this->filePartIndex = $index; |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * @param bool $isNetworkSiteBackup |
| 726 | * @return void |
| 727 | */ |
| 728 | public function setIsNetworkSiteBackup(bool $isNetworkSiteBackup) |
| 729 | { |
| 730 | $this->isNetworkSiteBackup = $isNetworkSiteBackup; |
| 731 | } |
| 732 | |
| 733 | /** |
| 734 | * @return bool |
| 735 | */ |
| 736 | public function getIsNetworkSiteBackup(): bool |
| 737 | { |
| 738 | return (bool)$this->isNetworkSiteBackup; |
| 739 | } |
| 740 | |
| 741 | /** |
| 742 | * @param string $backupType |
| 743 | * @return void |
| 744 | */ |
| 745 | public function setBackupType(string $backupType) |
| 746 | { |
| 747 | $this->backupType = $backupType; |
| 748 | } |
| 749 | |
| 750 | /** |
| 751 | * @return string |
| 752 | */ |
| 753 | public function getBackupType(): string |
| 754 | { |
| 755 | return $this->backupType; |
| 756 | } |
| 757 | |
| 758 | /** |
| 759 | * @param int|null $subsiteBlogId |
| 760 | * @return void |
| 761 | */ |
| 762 | public function setSubsiteBlogId($subsiteBlogId) |
| 763 | { |
| 764 | $this->subsiteBlogId = $subsiteBlogId; |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * @return int |
| 769 | */ |
| 770 | public function getSubsiteBlogId(): int |
| 771 | { |
| 772 | if (empty($this->subsiteBlogId)) { |
| 773 | $this->subsiteBlogId = get_current_blog_id(); |
| 774 | } |
| 775 | |
| 776 | return (int)$this->subsiteBlogId; |
| 777 | } |
| 778 | |
| 779 | /** |
| 780 | * @return bool |
| 781 | */ |
| 782 | public function getIsValidateBackupFiles(): bool |
| 783 | { |
| 784 | return (bool)$this->isValidateBackupFiles; |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * Cannot strict type it yet, otherwise it might throw error for older scheduled backup |
| 789 | * @param bool $isValidateBackupFiles |
| 790 | */ |
| 791 | public function setIsValidateBackupFiles($isValidateBackupFiles) |
| 792 | { |
| 793 | $this->isValidateBackupFiles = (bool)$isValidateBackupFiles; |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * @return bool |
| 798 | */ |
| 799 | public function getIsBackupFormatV1(): bool |
| 800 | { |
| 801 | return Hooks::applyFilters(BackupMetadata::FILTER_BACKUP_FORMAT_V1, true); |
| 802 | } |
| 803 | |
| 804 | /** |
| 805 | * @return bool |
| 806 | */ |
| 807 | public function getIsCompressedBackup(): bool |
| 808 | { |
| 809 | return WPStaging::make(ZlibCompressor::class)->isCompressionEnabled(); |
| 810 | } |
| 811 | } |
| 812 |