|
20 | 20 | use PhpOffice\PhpSpreadsheet\Comment; |
21 | 21 | use PhpOffice\PhpSpreadsheet\DefinedName; |
22 | 22 | use PhpOffice\PhpSpreadsheet\Exception; |
23 | | -use PhpOffice\PhpSpreadsheet\IComparable; |
24 | 23 | use PhpOffice\PhpSpreadsheet\ReferenceHelper; |
25 | 24 | use PhpOffice\PhpSpreadsheet\RichText\RichText; |
26 | 25 | use PhpOffice\PhpSpreadsheet\Shared; |
|
32 | 31 | use PhpOffice\PhpSpreadsheet\Style\Protection as StyleProtection; |
33 | 32 | use PhpOffice\PhpSpreadsheet\Style\Style; |
34 | 33 |
|
35 | | -class Worksheet implements IComparable |
| 34 | +class Worksheet |
36 | 35 | { |
37 | 36 | // Break types |
38 | 37 | public const BREAK_NONE = 0; |
@@ -305,15 +304,10 @@ class Worksheet implements IComparable |
305 | 304 | */ |
306 | 305 | private ?Color $tabColor = null; |
307 | 306 |
|
308 | | - /** |
309 | | - * Dirty flag. |
310 | | - */ |
311 | | - private bool $dirty = true; |
312 | | - |
313 | 307 | /** |
314 | 308 | * Hash. |
315 | 309 | */ |
316 | | - private string $hash; |
| 310 | + private int $hash; |
317 | 311 |
|
318 | 312 | /** |
319 | 313 | * CodeName. |
@@ -355,6 +349,7 @@ public function __construct(?Spreadsheet $parent = null, string $title = 'Worksh |
355 | 349 | $this->autoFilter = new AutoFilter('', $this); |
356 | 350 | // Table collection |
357 | 351 | $this->tableCollection = new ArrayObject(); |
| 352 | + $this->hash = spl_object_id($this); |
358 | 353 | } |
359 | 354 |
|
360 | 355 | /** |
@@ -383,6 +378,12 @@ public function __destruct() |
383 | 378 | unset($this->rowDimensions, $this->columnDimensions, $this->tableCollection, $this->drawingCollection, $this->chartCollection, $this->autoFilter); |
384 | 379 | } |
385 | 380 |
|
| 381 | + public function __wakeup(): void |
| 382 | + { |
| 383 | + $this->hash = spl_object_id($this); |
| 384 | + $this->parent = null; |
| 385 | + } |
| 386 | + |
386 | 387 | /** |
387 | 388 | * Return the cell collection. |
388 | 389 | */ |
@@ -897,7 +898,6 @@ public function setTitle(string $title, bool $updateFormulaCellReferences = true |
897 | 898 |
|
898 | 899 | // Set title |
899 | 900 | $this->title = $title; |
900 | | - $this->dirty = true; |
901 | 901 |
|
902 | 902 | if ($this->parent && $this->parent->getCalculationEngine()) { |
903 | 903 | // New title |
@@ -1032,7 +1032,6 @@ public function getProtection(): Protection |
1032 | 1032 | public function setProtection(Protection $protection): static |
1033 | 1033 | { |
1034 | 1034 | $this->protection = $protection; |
1035 | | - $this->dirty = true; |
1036 | 1035 |
|
1037 | 1036 | return $this; |
1038 | 1037 | } |
@@ -3014,7 +3013,7 @@ private function validateNamedRange(string $definedName, bool $returnNullIfInval |
3014 | 3013 |
|
3015 | 3014 | if ($namedRange->getLocalOnly()) { |
3016 | 3015 | $worksheet = $namedRange->getWorksheet(); |
3017 | | - if ($worksheet === null || $this->getHashCode() !== $worksheet->getHashCode()) { |
| 3016 | + if ($worksheet === null || $this->hash !== $worksheet->getHashInt()) { |
3018 | 3017 | if ($returnNullIfInvalid) { |
3019 | 3018 | return null; |
3020 | 3019 | } |
@@ -3154,17 +3153,15 @@ public function garbageCollect(): static |
3154 | 3153 | } |
3155 | 3154 |
|
3156 | 3155 | /** |
3157 | | - * Get hash code. |
3158 | | - * |
3159 | | - * @return string Hash code |
| 3156 | + * @deprecated 3.5.0 use getHashInt instead. |
3160 | 3157 | */ |
3161 | 3158 | public function getHashCode(): string |
3162 | 3159 | { |
3163 | | - if ($this->dirty) { |
3164 | | - $this->hash = md5($this->title . $this->autoFilter . ($this->protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__); |
3165 | | - $this->dirty = false; |
3166 | | - } |
| 3160 | + return (string) $this->hash; |
| 3161 | + } |
3167 | 3162 |
|
| 3163 | + public function getHashInt(): int |
| 3164 | + { |
3168 | 3165 | return $this->hash; |
3169 | 3166 | } |
3170 | 3167 |
|
@@ -3493,6 +3490,7 @@ public function __clone() |
3493 | 3490 | } |
3494 | 3491 | } |
3495 | 3492 | } |
| 3493 | + $this->hash = spl_object_id($this); |
3496 | 3494 | } |
3497 | 3495 |
|
3498 | 3496 | /** |
|
0 commit comments