Closed mjordan closed 6 years ago
Bump... as this is a genuine bug I'd like to have it merged. I can provide test data if you feel it's necessary, but I'd also be happy to provide extra PHPUnit tests specifically for this bug.
I've provided a new PHPUnit test for this issue, testWritePackagesIssue466()
, and it passes.
WRT newspapers, I can't think of a situation where this problem would occur since "each issue's page files must be in a directory named with the date of the issue in yyyy-mm-dd format." Therefore, even though I modified the CsvNewspaper filegetter to include the fix, I probably didn't need to. The existing toolchain tests for newspapers passes with the fix.
Hi Mark. I'm not really familiar with PHPUnit testing, so I can't really comment on that. If @MarcusBarnes is ready to merge based on the above, then great. If you have sample data that I can use to test, then I'd be happy to do so.
@mjordan @bondjimbond I've just reviewed the changes and it looks good. Give me a bit and I'll run the unit tests, and if it still looks good, I'll merge the changes.
Thanks guys. I did add test data for the new PHPUnit test (for books only), but as I say, I don't really think anyone will encounter this problem in the wild with newspapers if they have well-formed input (yyyy-mm-dd issue folders). Running the input validation will detect those.
With the CSV toolchains, we should really have PHPUnit tests for everthing, since all the necessary input data can be included in our repo. For Cdm and OAI, and whatever else we come up with that consumes external data, we are a bit more constrained.
@MarcusBarnes I'd like to push one more commit, to improve the clarity of my new test. At https://github.com/MarcusBarnes/mik/blob/issue-466/tests/toolchain/CsvBookToolchainTest.php#L242 I use the variable $pages
but its value doesn't hold the number of pages, it holds the number of things in the book directory, which include a MODS.xml
file for the book and .
and ..
. This inconsistency could cause someone (like me, or anyone else) in the future undue investigation while debugging this test or using it as the basis for another one.
@mjordan Please push the modification and I'll review today. Thanks!
@mjordan @bondjimbond I've reviewed and run the unit tests. Let's go ahead and merge!
Thanks!
Github issue: #466
What does this Pull Request do?
Fixes a bug where files under a path like
/foo/bar
are the intended "children" of a book or newspaper issue, but files under paths that begin with the intended path, such as/foo/barfly
are erroneously included.What's new?
Instead of relying on a simple substring match such as
if (strpos($path, $book_input_path) === 0)
, the CsvBooks and CsvNewspapers filegetters now use more explicit directory-matching code,if ($current_book_dirname === $this->input_directory . DIRECTORY_SEPARATOR . $book_directory)
.How should this be tested?
Running PHPUnit tests shows that this change does not introduce any regression errors, and that the toolchain tests for CsvBooks and CsvNewspapers work as before the change.
An example of the list of pages in a book that illustrates the bug prior to the change is:
After the fix, the list of pages for the book only contains the files in the "letter1" directory:
Providing sample data to capture this bug, across two toolchains, is complex. I hope the PHPUnit tests and the
var_dump()
ed output showing the list of pages detected for the "letter1" object are sufficient evidence that the fix works.Interested parties
@MarcusBarnes @bondjimbond