JobBackupDataDto.php
1146 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup\Dto\Job; |
| 4 | |
| 5 | use WPStaging\Backup\Dto\Interfaces\RemoteUploadDtoInterface; |
| 6 | use WPStaging\Backup\Dto\Traits\IsExportingTrait; |
| 7 | use WPStaging\Backup\Dto\Traits\IsExcludingTrait; |
| 8 | use WPStaging\Backup\Dto\Traits\RemoteUploadTrait; |
| 9 | use WPStaging\Backup\Entity\BackupMetadata; |
| 10 | use WPStaging\Framework\Facades\Hooks; |
| 11 | use WPStaging\Framework\Job\Dto\JobDataDto; |
| 12 | |
| 13 | class JobBackupDataDto extends JobDataDto implements RemoteUploadDtoInterface |
| 14 | { |
| 15 | use IsExportingTrait; |
| 16 | use IsExcludingTrait; |
| 17 | use RemoteUploadTrait; |
| 18 | |
| 19 | /** @var string|null */ |
| 20 | private $name; |
| 21 | |
| 22 | /** @var array */ |
| 23 | private $excludedDirectories = []; |
| 24 | |
| 25 | /** @var int */ |
| 26 | private $totalDirectories; |
| 27 | |
| 28 | /** @var int The number of files in the backup index */ |
| 29 | private $totalFiles; |
| 30 | |
| 31 | /** @var array The number of files in backup parts */ |
| 32 | private $filesInParts = []; |
| 33 | |
| 34 | /** @var int The number of files the FilesystemScanner discovered */ |
| 35 | private $discoveredFiles = 0; |
| 36 | |
| 37 | /** @var array The number of files the FilesystemScanner discovered in themes,plugins,muplugins,uploads,others */ |
| 38 | private $discoveredFilesArray = []; |
| 39 | |
| 40 | /** @var int The number of discovered files couldn't be added to backup */ |
| 41 | private $invalidFiles = 0; |
| 42 | |
| 43 | /** @var string */ |
| 44 | private $databaseFile; |
| 45 | |
| 46 | /** |
| 47 | * @var int If a file couldn't be processed in a single request, |
| 48 | * this property holds how many bytes were written thus far |
| 49 | * so that the backup can start writing from this byte onwards. |
| 50 | */ |
| 51 | private $fileBeingBackupWrittenBytes; |
| 52 | |
| 53 | /** |
| 54 | * @var int If header of a file was written but it couldn't be processed in single requests, |
| 55 | */ |
| 56 | private $currentWrittenFileHeaderBytes = 0; |
| 57 | |
| 58 | /** |
| 59 | * @var int start offset of the current file being processed, |
| 60 | */ |
| 61 | private $currentFileStartOffset = 0; |
| 62 | |
| 63 | /** @var int */ |
| 64 | private $totalRowsBackup = 0; |
| 65 | |
| 66 | /** @var int */ |
| 67 | private $tableRowsOffset = 0; |
| 68 | |
| 69 | /** @var int */ |
| 70 | private $totalRowsOfTableBeingBackup = 0; |
| 71 | |
| 72 | /** @var int reset to PHP_INT_MIN for each table */ |
| 73 | private $lastInsertId = PHP_INT_MIN; |
| 74 | |
| 75 | /** @var array */ |
| 76 | private $tablesToBackup = []; |
| 77 | |
| 78 | /** @var array */ |
| 79 | private $nonWpTables = []; |
| 80 | |
| 81 | /** @var int The size in bytes of the database in this backup */ |
| 82 | private $databaseFileSize = 0; |
| 83 | |
| 84 | /** @var int The size in bytes of the filesystem in this backup */ |
| 85 | private $filesystemSize = 0; |
| 86 | |
| 87 | /** @var int The number of requests that the Discovering Files task has executed so far */ |
| 88 | private $discoveringFilesRequests = 0; |
| 89 | |
| 90 | /** @var string The cron to repeat this backup, if scheduled. */ |
| 91 | private $scheduleRecurrence = ''; |
| 92 | |
| 93 | /** @var array The hour and minute to repeat this backup, if scheduled. */ |
| 94 | private $scheduleTime = []; |
| 95 | |
| 96 | /** @var int How many backups to keep, if scheduled. */ |
| 97 | private $scheduleRotation = 0; |
| 98 | |
| 99 | /** @var string The absolute path to this .wpstg file */ |
| 100 | private $backupFilePath = ''; |
| 101 | |
| 102 | /** @var string If set, this backup was created as part of this schedule ID. */ |
| 103 | private $scheduleId = ''; |
| 104 | |
| 105 | /** @var bool Should the backup be validated for each file once the backup is created. */ |
| 106 | private $isValidateBackupFiles = false; |
| 107 | |
| 108 | /** @var bool Should this scheduled backup be created right now. Matters only if this backup is repeated on schedule */ |
| 109 | private $isCreateScheduleBackupNow = false; |
| 110 | |
| 111 | /** @var bool Should the backup be created in background? */ |
| 112 | private $isCreateBackupInBackground = false; |
| 113 | |
| 114 | /** @var array Site selected to backup */ |
| 115 | private $sitesToBackup = []; |
| 116 | |
| 117 | /** |
| 118 | * is network subsite or network main site backup |
| 119 | * @var bool */ |
| 120 | private $isNetworkSiteBackup = false; |
| 121 | |
| 122 | /** |
| 123 | * @var array |
| 124 | * Store max index for each category |
| 125 | */ |
| 126 | private $fileBackupIndices = []; |
| 127 | |
| 128 | /** @var int */ |
| 129 | private $maxDbPartIndex = 0; |
| 130 | |
| 131 | /** |
| 132 | * Persisted cross-AJAX state for the multipart big-file segmenter. |
| 133 | * Tracks how many bytes of the source file have already been written across previous |
| 134 | * segments / parts so an interrupted backup can resume mid-file. |
| 135 | * @var int |
| 136 | */ |
| 137 | private $bigFileSourceBytesWritten = 0; |
| 138 | |
| 139 | /** |
| 140 | * Persisted cross-AJAX state for the multipart big-file segmenter. |
| 141 | * True when the next segment to write must carry REQUIRE_PREVIOUS_PART. |
| 142 | * @var bool |
| 143 | */ |
| 144 | private $bigFileIsContinuation = false; |
| 145 | |
| 146 | /** @var int */ |
| 147 | private $currentMultipartFileInfoIndex = 0; |
| 148 | |
| 149 | /** @var array */ |
| 150 | private $multipartFilesInfo = []; |
| 151 | |
| 152 | /** |
| 153 | * @var array<string, int> |
| 154 | * Store total size for each category |
| 155 | */ |
| 156 | private $categorySizes = []; |
| 157 | |
| 158 | /** @var string */ |
| 159 | private $backupType = ''; |
| 160 | |
| 161 | /** @var int */ |
| 162 | private $subsiteBlogId = 0; |
| 163 | |
| 164 | /** @var int */ |
| 165 | private $filePartIndex = 0; |
| 166 | |
| 167 | /** @var bool */ |
| 168 | private $isContaining2GBFile = false; |
| 169 | |
| 170 | /** @var bool */ |
| 171 | private $isGlitchInBackup = false; |
| 172 | |
| 173 | /** @var string */ |
| 174 | private $glitchReason = ''; |
| 175 | |
| 176 | /** @var int */ |
| 177 | private $fileAppendTimeLimit = 10; |
| 178 | |
| 179 | /** @var bool */ |
| 180 | private $isCompressed = false; |
| 181 | |
| 182 | /** |
| 183 | * @var int |
| 184 | */ |
| 185 | private $backupSizeUncompressed = 0; |
| 186 | |
| 187 | /** |
| 188 | * @var int |
| 189 | */ |
| 190 | private $backupSizeCompressed = 0; |
| 191 | |
| 192 | /** |
| 193 | * @var int |
| 194 | */ |
| 195 | private $totalFilesCompressed = 0; |
| 196 | |
| 197 | /** @var array */ |
| 198 | private $pushPrepareData = []; |
| 199 | |
| 200 | /** |
| 201 | * @return string|null |
| 202 | */ |
| 203 | public function getName() |
| 204 | { |
| 205 | return $this->name; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Hydrated dynamically. |
| 210 | * |
| 211 | * @param string|null $name |
| 212 | */ |
| 213 | public function setName($name) |
| 214 | { |
| 215 | $this->name = $name; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @return array |
| 220 | */ |
| 221 | public function getPushPrepareData(): array |
| 222 | { |
| 223 | return $this->pushPrepareData; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * @param array $pushPrepareData |
| 228 | * @return void |
| 229 | */ |
| 230 | public function setPushPrepareData(array $pushPrepareData) |
| 231 | { |
| 232 | $this->pushPrepareData = $pushPrepareData; |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * @return array|null |
| 237 | */ |
| 238 | public function getExcludedDirectories() |
| 239 | { |
| 240 | return (array)$this->excludedDirectories; |
| 241 | } |
| 242 | |
| 243 | public function setExcludedDirectories(array $excludedDirectories = []) |
| 244 | { |
| 245 | $this->excludedDirectories = $excludedDirectories; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * @return int |
| 250 | */ |
| 251 | public function getTotalDirectories() |
| 252 | { |
| 253 | return $this->totalDirectories; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * @param int $totalDirectories |
| 258 | */ |
| 259 | public function setTotalDirectories($totalDirectories) |
| 260 | { |
| 261 | $this->totalDirectories = $totalDirectories; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * @return int |
| 266 | */ |
| 267 | public function getTotalFiles() |
| 268 | { |
| 269 | return $this->totalFiles; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * @param int $totalFiles |
| 274 | */ |
| 275 | public function setTotalFiles($totalFiles) |
| 276 | { |
| 277 | $this->totalFiles = $totalFiles; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @return int |
| 282 | */ |
| 283 | public function getDiscoveredFiles() |
| 284 | { |
| 285 | return $this->discoveredFiles; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * @param int $discoveredFiles |
| 290 | */ |
| 291 | public function setDiscoveredFiles($discoveredFiles) |
| 292 | { |
| 293 | $this->discoveredFiles = $discoveredFiles; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * @return int |
| 298 | */ |
| 299 | public function getInvalidFiles(): int |
| 300 | { |
| 301 | return $this->invalidFiles; |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * @param int $invalidFiles |
| 306 | * @return void |
| 307 | */ |
| 308 | public function setInvalidFiles(int $invalidFiles) |
| 309 | { |
| 310 | $this->invalidFiles = $invalidFiles; |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * @return void |
| 315 | */ |
| 316 | public function incrementInvalidFiles() |
| 317 | { |
| 318 | $this->invalidFiles++; |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * @return string |
| 323 | */ |
| 324 | public function getDatabaseFile() |
| 325 | { |
| 326 | return $this->databaseFile; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * @param string $databaseFile |
| 331 | */ |
| 332 | public function setDatabaseFile($databaseFile) |
| 333 | { |
| 334 | $this->databaseFile = $databaseFile; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * @return int |
| 339 | */ |
| 340 | public function getTableRowsOffset() |
| 341 | { |
| 342 | return (int)$this->tableRowsOffset; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * @param int $tableRowsOffset |
| 347 | */ |
| 348 | public function setTableRowsOffset($tableRowsOffset) |
| 349 | { |
| 350 | $this->tableRowsOffset = (int)$tableRowsOffset; |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * @return int |
| 355 | */ |
| 356 | public function getTotalRowsBackup() |
| 357 | { |
| 358 | return (int)$this->totalRowsBackup; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * @param int $totalRowsBackup |
| 363 | */ |
| 364 | public function setTotalRowsBackup($totalRowsBackup) |
| 365 | { |
| 366 | $this->totalRowsBackup = (int)$totalRowsBackup; |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * @return int |
| 371 | */ |
| 372 | public function getFileBeingBackupWrittenBytes() |
| 373 | { |
| 374 | return (int)$this->fileBeingBackupWrittenBytes; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * @param int $fileBeingBackupWrittenBytes |
| 379 | */ |
| 380 | public function setFileBeingBackupWrittenBytes($fileBeingBackupWrittenBytes) |
| 381 | { |
| 382 | $this->fileBeingBackupWrittenBytes = (int)$fileBeingBackupWrittenBytes; |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * @return array |
| 387 | */ |
| 388 | public function getTablesToBackup() |
| 389 | { |
| 390 | return (array)$this->tablesToBackup; |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * @param array $tablesToBackup |
| 395 | */ |
| 396 | public function setTablesToBackup($tablesToBackup) |
| 397 | { |
| 398 | $this->tablesToBackup = (array)$tablesToBackup; |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * @return array |
| 403 | */ |
| 404 | public function getNonWpTables() |
| 405 | { |
| 406 | return (array)$this->nonWpTables; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * @param array $nonWpTables |
| 411 | */ |
| 412 | public function setNonWpTables($nonWpTables) |
| 413 | { |
| 414 | $this->nonWpTables = (array)$nonWpTables; |
| 415 | } |
| 416 | |
| 417 | /** |
| 418 | * @return int |
| 419 | */ |
| 420 | public function getTotalRowsOfTableBeingBackup() |
| 421 | { |
| 422 | return (int)$this->totalRowsOfTableBeingBackup; |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * @param int $totalRowsOfTableBeingBackup |
| 427 | */ |
| 428 | public function setTotalRowsOfTableBeingBackup($totalRowsOfTableBeingBackup) |
| 429 | { |
| 430 | $this->totalRowsOfTableBeingBackup = (int)$totalRowsOfTableBeingBackup; |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * @return int |
| 435 | */ |
| 436 | public function getDatabaseFileSize() |
| 437 | { |
| 438 | return $this->databaseFileSize; |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * @param int $databaseFileSize |
| 443 | */ |
| 444 | public function setDatabaseFileSize($databaseFileSize) |
| 445 | { |
| 446 | $this->databaseFileSize = $databaseFileSize; |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * @return int |
| 451 | */ |
| 452 | public function getFilesystemSize() |
| 453 | { |
| 454 | return $this->filesystemSize; |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * @param int $filesystemSize |
| 459 | */ |
| 460 | public function setFilesystemSize($filesystemSize) |
| 461 | { |
| 462 | $this->filesystemSize = $filesystemSize; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * @return int |
| 467 | */ |
| 468 | public function getDiscoveringFilesRequests() |
| 469 | { |
| 470 | return $this->discoveringFilesRequests; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * @param int $discoveringFilesRequests |
| 475 | */ |
| 476 | public function setDiscoveringFilesRequests($discoveringFilesRequests) |
| 477 | { |
| 478 | $this->discoveringFilesRequests = $discoveringFilesRequests; |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * @see Cron For WP STAGING cron recurrences. |
| 483 | * |
| 484 | * @return string A WP STAGING cron schedule |
| 485 | */ |
| 486 | public function getScheduleRecurrence() |
| 487 | { |
| 488 | return $this->scheduleRecurrence; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * @param string $scheduleRecurrence |
| 493 | */ |
| 494 | public function setScheduleRecurrence($scheduleRecurrence) |
| 495 | { |
| 496 | $this->scheduleRecurrence = $scheduleRecurrence; |
| 497 | } |
| 498 | |
| 499 | /** |
| 500 | * @return array H:i time format, expected to be accurate to the site's timezone, example: 00:00 |
| 501 | */ |
| 502 | public function getScheduleTime() |
| 503 | { |
| 504 | return $this->scheduleTime; |
| 505 | } |
| 506 | |
| 507 | /** |
| 508 | * @param array $scheduleTime Hour and Minute ['00', '00'] |
| 509 | */ |
| 510 | public function setScheduleTime(array $scheduleTime) |
| 511 | { |
| 512 | $this->scheduleTime = $scheduleTime; |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * @return int How many backups to keep, example: 1 |
| 517 | */ |
| 518 | public function getScheduleRotation() |
| 519 | { |
| 520 | return $this->scheduleRotation; |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * @param int $scheduleRotation |
| 525 | */ |
| 526 | public function setScheduleRotation($scheduleRotation) |
| 527 | { |
| 528 | $this->scheduleRotation = $scheduleRotation; |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * @return string |
| 533 | */ |
| 534 | public function getBackupFilePath() |
| 535 | { |
| 536 | return $this->backupFilePath; |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * @param string $backupFilePath |
| 541 | */ |
| 542 | public function setBackupFilePath($backupFilePath) |
| 543 | { |
| 544 | $this->backupFilePath = $backupFilePath; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * @return string|null |
| 549 | */ |
| 550 | public function getScheduleId() |
| 551 | { |
| 552 | return $this->scheduleId; |
| 553 | } |
| 554 | |
| 555 | /** |
| 556 | * @param string $scheduleId |
| 557 | */ |
| 558 | public function setScheduleId($scheduleId) |
| 559 | { |
| 560 | $this->scheduleId = $scheduleId; |
| 561 | } |
| 562 | |
| 563 | /** |
| 564 | * @return bool |
| 565 | */ |
| 566 | public function getIsCreateScheduleBackupNow() |
| 567 | { |
| 568 | return $this->isCreateScheduleBackupNow; |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * @param bool $isCreateScheduleBackupNow |
| 573 | */ |
| 574 | public function setIsCreateScheduleBackupNow($isCreateScheduleBackupNow) |
| 575 | { |
| 576 | $this->isCreateScheduleBackupNow = (bool)$isCreateScheduleBackupNow; |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * @return bool |
| 581 | */ |
| 582 | public function getIsCreateBackupInBackground(): bool |
| 583 | { |
| 584 | return (bool)$this->isCreateBackupInBackground; |
| 585 | } |
| 586 | |
| 587 | /** |
| 588 | * Cannot strict type it yet, otherwise it might throw error for older scheduled backup |
| 589 | * @param bool $isCreateBackupInBackground |
| 590 | */ |
| 591 | public function setIsCreateBackupInBackground($isCreateBackupInBackground) |
| 592 | { |
| 593 | $this->isCreateBackupInBackground = (bool)$isCreateBackupInBackground; |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * @return array|null |
| 598 | */ |
| 599 | public function getSitesToBackup() |
| 600 | { |
| 601 | return (array)$this->sitesToBackup; |
| 602 | } |
| 603 | |
| 604 | public function setSitesToBackup(array $sitesToBackup = []) |
| 605 | { |
| 606 | $this->sitesToBackup = $sitesToBackup; |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * @return array |
| 611 | */ |
| 612 | public function getDiscoveredFilesArray() |
| 613 | { |
| 614 | return $this->discoveredFilesArray; |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * @param array $discoveredFiles |
| 619 | */ |
| 620 | public function setDiscoveredFilesArray($discoveredFiles = []) |
| 621 | { |
| 622 | $this->discoveredFilesArray = $discoveredFiles; |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * @param string $category |
| 627 | * @return int |
| 628 | */ |
| 629 | public function getDiscoveredFilesByCategory($category) |
| 630 | { |
| 631 | if (!array_key_exists($category, $this->discoveredFilesArray)) { |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | return $this->discoveredFilesArray[$category]; |
| 636 | } |
| 637 | |
| 638 | /** |
| 639 | * @param string $category |
| 640 | * @param int $discoveredFiles |
| 641 | */ |
| 642 | public function setDiscoveredFilesByCategory($category, $discoveredFiles) |
| 643 | { |
| 644 | $this->discoveredFilesArray[$category] = $discoveredFiles; |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * @return array |
| 649 | */ |
| 650 | public function getFilesInParts() |
| 651 | { |
| 652 | return $this->filesInParts; |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * @param array $filesInParts |
| 657 | */ |
| 658 | public function setFilesInParts($filesInParts = []) |
| 659 | { |
| 660 | $this->filesInParts = $filesInParts; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * @param string $category |
| 665 | * @param int $categoryIndex |
| 666 | * @return int |
| 667 | */ |
| 668 | public function getFilesInPart($category, $categoryIndex) |
| 669 | { |
| 670 | if (!array_key_exists($category, $this->filesInParts)) { |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | if (!isset($this->filesInParts[$category][$categoryIndex])) { |
| 675 | return 0; |
| 676 | } |
| 677 | |
| 678 | return $this->filesInParts[$category][$categoryIndex]; |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * @param string $category |
| 683 | * @param int $categoryIndex |
| 684 | * @param int $files |
| 685 | */ |
| 686 | public function setFilesInPart($category, $categoryIndex, $files) |
| 687 | { |
| 688 | if (!array_key_exists($category, $this->filesInParts)) { |
| 689 | $this->filesInParts[$category] = []; |
| 690 | } |
| 691 | |
| 692 | $this->filesInParts[$category][$categoryIndex] = $files; |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * @param string $category |
| 697 | * @param int $categoryIndex |
| 698 | * @return void |
| 699 | */ |
| 700 | public function incrementFilesInPart(string $category, int $categoryIndex = 0) |
| 701 | { |
| 702 | if (!array_key_exists($category, $this->filesInParts)) { |
| 703 | $this->filesInParts[$category] = []; |
| 704 | } |
| 705 | |
| 706 | if (!array_key_exists($categoryIndex, $this->filesInParts[$category])) { |
| 707 | $this->filesInParts[$category][$categoryIndex] = 0; |
| 708 | } |
| 709 | |
| 710 | $this->filesInParts[$category][$categoryIndex]++; |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * @return array |
| 715 | */ |
| 716 | public function getFileBackupIndices() |
| 717 | { |
| 718 | return $this->fileBackupIndices; |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * @param array $fileBackupIndices |
| 723 | */ |
| 724 | public function setFileBackupIndices($fileBackupIndices = []) |
| 725 | { |
| 726 | $this->fileBackupIndices = $fileBackupIndices; |
| 727 | } |
| 728 | |
| 729 | /** |
| 730 | * @return int |
| 731 | */ |
| 732 | public function getMaxDbPartIndex() |
| 733 | { |
| 734 | return $this->maxDbPartIndex; |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * @param int $maxDbPartIndex |
| 739 | */ |
| 740 | public function setMaxDbPartIndex($maxDbPartIndex) |
| 741 | { |
| 742 | $this->maxDbPartIndex = $maxDbPartIndex; |
| 743 | } |
| 744 | |
| 745 | public function getBigFileSourceBytesWritten(): int |
| 746 | { |
| 747 | return (int) $this->bigFileSourceBytesWritten; |
| 748 | } |
| 749 | |
| 750 | public function setBigFileSourceBytesWritten(int $bigFileSourceBytesWritten) |
| 751 | { |
| 752 | $this->bigFileSourceBytesWritten = $bigFileSourceBytesWritten; |
| 753 | } |
| 754 | |
| 755 | public function getBigFileIsContinuation(): bool |
| 756 | { |
| 757 | return (bool) $this->bigFileIsContinuation; |
| 758 | } |
| 759 | |
| 760 | public function setBigFileIsContinuation(bool $bigFileIsContinuation) |
| 761 | { |
| 762 | $this->bigFileIsContinuation = $bigFileIsContinuation; |
| 763 | } |
| 764 | |
| 765 | /** |
| 766 | * @return int |
| 767 | */ |
| 768 | public function getCurrentMultipartFileInfoIndex() |
| 769 | { |
| 770 | return $this->currentMultipartFileInfoIndex; |
| 771 | } |
| 772 | |
| 773 | /** |
| 774 | * @param int $currentMultipartFileInfoIndex |
| 775 | */ |
| 776 | public function setCurrentMultipartFileInfoIndex($currentMultipartFileInfoIndex) |
| 777 | { |
| 778 | $this->currentMultipartFileInfoIndex = $currentMultipartFileInfoIndex; |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * @return array |
| 783 | */ |
| 784 | public function getMultipartFilesInfo() |
| 785 | { |
| 786 | return $this->multipartFilesInfo; |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * @param array $multipartFilesInfo |
| 791 | */ |
| 792 | public function setMultipartFilesInfo($multipartFilesInfo) |
| 793 | { |
| 794 | $this->multipartFilesInfo = $multipartFilesInfo; |
| 795 | } |
| 796 | |
| 797 | /** |
| 798 | * @param array $multipartFileInfo |
| 799 | */ |
| 800 | public function addMultipartFileInfo($multipartFileInfo) |
| 801 | { |
| 802 | $this->multipartFilesInfo[] = $multipartFileInfo; |
| 803 | } |
| 804 | |
| 805 | /** |
| 806 | * @param array $multipartFileInfo |
| 807 | * @param int $index |
| 808 | */ |
| 809 | public function updateMultipartFileInfo($multipartFileInfo, $index) |
| 810 | { |
| 811 | $this->multipartFilesInfo[$index] = $multipartFileInfo; |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * @param int $lastInsertId |
| 816 | */ |
| 817 | public function setLastInsertId($lastInsertId) |
| 818 | { |
| 819 | $this->lastInsertId = $lastInsertId; |
| 820 | } |
| 821 | |
| 822 | /** |
| 823 | * @return int |
| 824 | */ |
| 825 | public function getLastInsertId() |
| 826 | { |
| 827 | return $this->lastInsertId; |
| 828 | } |
| 829 | |
| 830 | /** |
| 831 | * @param array<string, int> $categorySizes |
| 832 | */ |
| 833 | public function setCategorySizes($categorySizes) |
| 834 | { |
| 835 | $this->categorySizes = $categorySizes; |
| 836 | } |
| 837 | |
| 838 | /** |
| 839 | * @return array<string, int> |
| 840 | */ |
| 841 | public function getCategorySizes() |
| 842 | { |
| 843 | return $this->categorySizes; |
| 844 | } |
| 845 | |
| 846 | /** |
| 847 | * @return int |
| 848 | */ |
| 849 | public function getFilePartIndex(): int |
| 850 | { |
| 851 | return $this->filePartIndex; |
| 852 | } |
| 853 | |
| 854 | /** |
| 855 | * @param int $index |
| 856 | * @return void |
| 857 | */ |
| 858 | public function setFilePartIndex(int $index = 0) |
| 859 | { |
| 860 | $this->filePartIndex = $index; |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * @param bool $isNetworkSiteBackup |
| 865 | * @return void |
| 866 | */ |
| 867 | public function setIsNetworkSiteBackup(bool $isNetworkSiteBackup) |
| 868 | { |
| 869 | $this->isNetworkSiteBackup = $isNetworkSiteBackup; |
| 870 | } |
| 871 | |
| 872 | /** |
| 873 | * @return bool |
| 874 | */ |
| 875 | public function getIsNetworkSiteBackup(): bool |
| 876 | { |
| 877 | return (bool)$this->isNetworkSiteBackup; |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * @param string $backupType |
| 882 | * @return void |
| 883 | */ |
| 884 | public function setBackupType(string $backupType) |
| 885 | { |
| 886 | $this->backupType = $backupType; |
| 887 | } |
| 888 | |
| 889 | /** |
| 890 | * @return string |
| 891 | */ |
| 892 | public function getBackupType(): string |
| 893 | { |
| 894 | return $this->backupType; |
| 895 | } |
| 896 | |
| 897 | /** |
| 898 | * @param int|null $subsiteBlogId |
| 899 | * @return void |
| 900 | */ |
| 901 | public function setSubsiteBlogId($subsiteBlogId) |
| 902 | { |
| 903 | $this->subsiteBlogId = $subsiteBlogId; |
| 904 | } |
| 905 | |
| 906 | /** |
| 907 | * @return int |
| 908 | */ |
| 909 | public function getSubsiteBlogId(): int |
| 910 | { |
| 911 | if (empty($this->subsiteBlogId)) { |
| 912 | $this->subsiteBlogId = get_current_blog_id(); |
| 913 | } |
| 914 | |
| 915 | return (int)$this->subsiteBlogId; |
| 916 | } |
| 917 | |
| 918 | /** |
| 919 | * @return bool |
| 920 | */ |
| 921 | public function getIsValidateBackupFiles(): bool |
| 922 | { |
| 923 | return (bool)$this->isValidateBackupFiles; |
| 924 | } |
| 925 | |
| 926 | /** |
| 927 | * Cannot strict type it yet, otherwise it might throw error for older scheduled backup |
| 928 | * @param bool $isValidateBackupFiles |
| 929 | */ |
| 930 | public function setIsValidateBackupFiles($isValidateBackupFiles) |
| 931 | { |
| 932 | $this->isValidateBackupFiles = (bool)$isValidateBackupFiles; |
| 933 | } |
| 934 | |
| 935 | /** |
| 936 | * @return bool |
| 937 | */ |
| 938 | public function getIsBackupFormatV1(): bool |
| 939 | { |
| 940 | return Hooks::applyFilters(BackupMetadata::FILTER_BACKUP_FORMAT_V1, false); |
| 941 | } |
| 942 | |
| 943 | /** |
| 944 | * @return bool |
| 945 | */ |
| 946 | public function getIsContaining2GBFile(): bool |
| 947 | { |
| 948 | return $this->isContaining2GBFile; |
| 949 | } |
| 950 | |
| 951 | /** |
| 952 | * @param bool $isContaining2GBFile |
| 953 | * @return void |
| 954 | */ |
| 955 | public function setIsContaining2GBFile(bool $isContaining2GBFile) |
| 956 | { |
| 957 | $this->isContaining2GBFile = $isContaining2GBFile; |
| 958 | } |
| 959 | |
| 960 | public function getIsGlitchInBackup(): bool |
| 961 | { |
| 962 | return $this->isGlitchInBackup; |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * @param bool $isGlitchInBackup |
| 967 | * @return void |
| 968 | */ |
| 969 | public function setIsGlitchInBackup(bool $isGlitchInBackup) |
| 970 | { |
| 971 | $this->isGlitchInBackup = $isGlitchInBackup; |
| 972 | } |
| 973 | |
| 974 | public function getGlitchReason(): string |
| 975 | { |
| 976 | return $this->glitchReason; |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * @param string $glitchReason |
| 981 | * @return void |
| 982 | */ |
| 983 | public function setGlitchReason(string $glitchReason) |
| 984 | { |
| 985 | $this->glitchReason = $glitchReason; |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * @return int |
| 990 | */ |
| 991 | public function getCurrentWrittenFileHeaderBytes(): int |
| 992 | { |
| 993 | return (int)$this->currentWrittenFileHeaderBytes; |
| 994 | } |
| 995 | |
| 996 | /** |
| 997 | * @param int $currentWrittenFileHeaderBytes |
| 998 | * @return void |
| 999 | */ |
| 1000 | public function setCurrentWrittenFileHeaderBytes(int $currentWrittenFileHeaderBytes) |
| 1001 | { |
| 1002 | $this->currentWrittenFileHeaderBytes = (int)$currentWrittenFileHeaderBytes; |
| 1003 | } |
| 1004 | |
| 1005 | public function getCurrentFileStartOffset(): int |
| 1006 | { |
| 1007 | return $this->currentFileStartOffset; |
| 1008 | } |
| 1009 | |
| 1010 | /** |
| 1011 | * @param int $currentFileStartOffset |
| 1012 | * @return void |
| 1013 | */ |
| 1014 | public function setCurrentFileStartOffset(int $currentFileStartOffset) |
| 1015 | { |
| 1016 | $this->currentFileStartOffset = (int)$currentFileStartOffset; |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * @param int $timeLimit |
| 1021 | * @return void |
| 1022 | */ |
| 1023 | public function setFileAppendTimeLimit(int $timeLimit) |
| 1024 | { |
| 1025 | $this->fileAppendTimeLimit = $timeLimit; |
| 1026 | } |
| 1027 | |
| 1028 | /** |
| 1029 | * @return int |
| 1030 | */ |
| 1031 | public function getFileAppendTimeLimit(): int |
| 1032 | { |
| 1033 | return $this->fileAppendTimeLimit; |
| 1034 | } |
| 1035 | |
| 1036 | /** |
| 1037 | * @return void |
| 1038 | */ |
| 1039 | public function incrementFileAppendTimeLimit() |
| 1040 | { |
| 1041 | $this->fileAppendTimeLimit += 5; |
| 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * @return void |
| 1046 | */ |
| 1047 | public function resetFileAppendTimeLimit() |
| 1048 | { |
| 1049 | $this->fileAppendTimeLimit = 10; |
| 1050 | } |
| 1051 | |
| 1052 | /** |
| 1053 | * @return bool |
| 1054 | */ |
| 1055 | public function getIsCompressed(): bool |
| 1056 | { |
| 1057 | return $this->isCompressed; |
| 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * @param bool $isCompressed |
| 1062 | * @return void |
| 1063 | */ |
| 1064 | public function setIsCompressed(bool $isCompressed) |
| 1065 | { |
| 1066 | $this->isCompressed = $isCompressed; |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * @return int |
| 1071 | */ |
| 1072 | public function getBackupSizeUncompressed(): int |
| 1073 | { |
| 1074 | return $this->backupSizeUncompressed; |
| 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * @param int $backupSizeUncompressed |
| 1079 | * @return void |
| 1080 | */ |
| 1081 | public function setBackupSizeUncompressed(int $backupSizeUncompressed) |
| 1082 | { |
| 1083 | $this->backupSizeUncompressed = $backupSizeUncompressed; |
| 1084 | } |
| 1085 | |
| 1086 | /** |
| 1087 | * @param int $backupSizeUncompressed |
| 1088 | * @return void |
| 1089 | */ |
| 1090 | public function addBackupSizeUncompressed(int $backupSizeUncompressed) |
| 1091 | { |
| 1092 | $this->backupSizeUncompressed += $backupSizeUncompressed; |
| 1093 | } |
| 1094 | |
| 1095 | /** |
| 1096 | * @return int |
| 1097 | */ |
| 1098 | public function getBackupSizeCompressed(): int |
| 1099 | { |
| 1100 | return $this->backupSizeCompressed; |
| 1101 | } |
| 1102 | |
| 1103 | /** |
| 1104 | * @param int $backupSizeCompressed |
| 1105 | * @return void |
| 1106 | */ |
| 1107 | public function setBackupSizeCompressed(int $backupSizeCompressed) |
| 1108 | { |
| 1109 | $this->backupSizeCompressed = $backupSizeCompressed; |
| 1110 | } |
| 1111 | |
| 1112 | /** |
| 1113 | * @param int $backupSizeCompressed |
| 1114 | * @return void |
| 1115 | */ |
| 1116 | public function addBackupSizeCompressed(int $backupSizeCompressed) |
| 1117 | { |
| 1118 | $this->backupSizeCompressed += $backupSizeCompressed; |
| 1119 | } |
| 1120 | |
| 1121 | /** |
| 1122 | * @return int |
| 1123 | */ |
| 1124 | public function getTotalFilesCompressed(): int |
| 1125 | { |
| 1126 | return $this->totalFilesCompressed; |
| 1127 | } |
| 1128 | |
| 1129 | /** |
| 1130 | * @param int $totalFilesCompressed |
| 1131 | * @return void |
| 1132 | */ |
| 1133 | public function setTotalFilesCompressed(int $totalFilesCompressed) |
| 1134 | { |
| 1135 | $this->totalFilesCompressed = $totalFilesCompressed; |
| 1136 | } |
| 1137 | |
| 1138 | /** |
| 1139 | * @return void |
| 1140 | */ |
| 1141 | public function incrementTotalFilesCompressed() |
| 1142 | { |
| 1143 | $this->totalFilesCompressed++; |
| 1144 | } |
| 1145 | } |
| 1146 |