HomePhabricator

Make Importer fail in a nice way with empty ImportOperations
533bf0318997Unpublished

Authored by thiemowmde on Jan 4 2019, 6:29 PM.

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Make Importer fail in a nice way with empty ImportOperations

It should be impossible to have a file with zero file revisions as well
as zero text revisions. The API request can not return something like
this. However, the code consuming the two arrays can not know this.

Currently the import fails with a bad PHP error when trying to access
a non-existing array index …[0]. If this error is ignored, the import
goes on and even succeeds, but creates an empty, broken page. Just
returning false makes the whole thing collapse in an *expected* way, and
shows a nice error message.

This patch also adds a missing sanity check to the ImportOperations
class. Before it was possible to add operations in the middle of the
3-step process.

The same "… === []" can be added to all 3 operations. But this would not
make any difference. It would even be impossible to test this, and
therefor dead code.

Bug: T212199
Change-Id: Iaef2784bb7c9244f22789b4158c22cda07ea030c