With the workspace DataHandler hook code being inlined to
moveRecord(), the code can be streamlined and moved around.
Goal is to reach a far more easy to understand code flow
and to optimize calls. The main barrier established with this
patch is the main sub method moveRecord_raw(). Its signature
and handling is kept as is. Handing over "sane" state from
moveRecord() to moveRecord_raw() will be another change.
This patch is the result of a series of logically following
changes. It is not trivial to proof correctness of the final patch
result in comparison to current state by reading the change. To
understand details, a look at the differences between single patch
set version can be helpful.
Patch risk assessment: We have pretty good functional test coverage
in this area. Everything that is actively tested leads to the same
DB state with the patch. About 90% of coding issues during this
refactoring did lead to test failures, with the remaining 10% being
edge cases that can be played through locally. I'd thus consider the
risk to break something with this patch when not in workspaces as
relatively low. The risk to break something with this patch when
in workspaces is moderate or low.
Overview:
* Split the worker part of moveRecord() to three distinct sections:
"moving in live", "moving a not-workspace-aware table record in
workspaces" (this scenario is so full of systematic issues that we
will most likely have to prevent it in TCA later), and "moving a
workspace aware table record in workspaces". This allows getting
rid of all the nasty variables like $recIsNewVersion and
$recordMustNotBeVersionized. This makes the entire method
significantly better readable.
* Fix a crash in "moving a not-workspace-aware table record in
workspaces" scenario. This is a drive-by since that scenario is
broken overall.
* Safe quite a few DB calls by not getting and checking the record
in question over and over again, especially in workspace.
* Inline moveRecord_moveVersionedRecord() to "moving a workspace aware
table in workspaces" and streamline it to the reduced scope.
* It turns out two workspace related methods moveRecord_processFields()
and moveRecord_processFieldValue() are nonsense and can be removed.
* Streamline versionizeRecord() slightly and add a couple of return
types in other methods. The method visibility changes will not be
backported.
* Always feed workspaceCannotEditOfflineVersion() with the full
record to suppress yet another DB call. The signature of that
method should be adapted in v14 with another patch.
* Add a series of `@todo` comments pointing out potentially broken
scenarios and fishy overall handling.