-
Notifications
You must be signed in to change notification settings - Fork 539
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
Fix returning empty text in some cases #666
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.
Thank you @xAzoom for this PR!
Please provide at least one unit test to cover this change. Or is there already one?
Unfortunately, I can't mock the internal protected getUniqueId() function in PDFObject to ensure that the comparison is already correct. But I think it's most important that this change doesn't break any part of the library and passes all tests. Is it possible to release v2.7.1 with this fix? |
I also have no idea currently how to mock this code part. It might be possible, but is not worth my time. Can you provide a PDF which triggered the problem before this fix? That would also fit.
It could be part of our next release (v2.8.1) when its ready. But I can give you no fixed date. |
After examining this PR, my first thought was: "There's gotta be more than just two places in PdfParser that use While it would be easy to create a test to directly compare strict vs. non-strict If that's impossible, I can see if I can somehow create some fake document code that tests this, but I ain't looking forward to it! |
Please merge in master branch, to get rid of these coding style issues. |
Here I also have the bad news, it totally does not depend on the PDF document, but rather on the structure of the code. My quick fix in my project was to move one of the test methods up, and all tests passed (I didn't actually change any line of code, just reordered the methods). So I suppose spl_object_hash works in a deterministic way, but it will be difficult to simulate the creation of hashes like "0000000000000e030000000000000000000000000000". |
Sorry for the delay here. We recently fixed Scrutinizer which provides code coverage. Its report says that the lines in question are covered by
I think its reasonable to merge it without any tests. |
Type of pull request
Bug fix (involves code and configuration changes)
About
In some cases, we may have received empty text, due to an invalid
!\in_array($xobject->getUniqueId(), self::$recursionStack)
comparison in PDFObject (e.g.,in_array('0000000000000e110000000000000000', ['0000000000000e030000000000000000'])
will return true). For more information, see https://www.php.net/manual/en/function.spl-object-hash.php notes. In this PR strict parameter to in_array has been added.