-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skipping to clone Worksheet object when cloning DrawingCollection #613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this can be merged as is, because the worksheet should still be cloned somehow.
{ | ||
public function testCloningWorksheetWithImages() | ||
{ | ||
$filename = './data/Reader/Xls/with_images.xls'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refrain from adding binary files to the repo and instead create them from scratch, in memory with PhpSpreadsheet.
$clonedWorksheet = clone $worksheet; | ||
$clonedDrawingCount = count($clonedWorksheet->getDrawingCollection()); | ||
self::assertEquals($originDrawingCount, $clonedDrawingCount); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should assert that the drawing collection is not the exact same object and was indeed cloned. Probably with assertNotSame
.
And same for worksheet, it must be cloned. So the patch might be too simple as it is now.
…seDrawing:: Iterating over a copy of Worksheet:: because the proper way to add BaseDrawing to a Worksheet already add it to their drawingCollection attribute and in this case the foreach got a infinte loop
…ng cloned objects exist and they are differents
@PowerKiKi thanks for your feedback, I completed your suggestions I think |
Thanks ! it's been merged |
When cloning `BaseDrawing`, its worksheet will be set as null and thus be orphaned. But when cloning the worksheet, it will re-assign itself as the new worksheet for the BaseDrawing. That way we avoid recursive cloning of a Worksheet that would clone a BaseDrawing that would clone a Worksheet etc. Fixes PHPOffice#437 Fixes PHPOffice#613
This is:
Checklist:
Why this change is needed?
Fixing issue #437