After juggling moveRecord() and moveRecord_raw() for three days,
the code is better tamed, more easy to follow and grasp, with
fewer lines of code.
* moveRecord_raw() becomes obsolete by integrating it into
moveRecord().
* getRecordProperties() finally bites the dust.
* moveRecord_procBasedOnFieldType() is merged into
moveRecord_procFields().
* resolvePid() is simplified and will most likely become
unused soon.
* history "logging" data is improved: The existing solution did
not write good "oldData". Rollback of moved record still does
not work, but that is a second issue in HistoryController, not
in DataHandler.
Removed methods that are still public in v13 will remain in the
v13 backport, but moved to the end of the class and marked unused.
The patch makes moveRecord() lengthy, but it splits into sections
that take care of preparation, fact gathering, data preparation,
permission checking and finally main move handling. The code is
not yet in a truly "clean" state, there is still room for further
improvements. Further iterations should be more easy to review.
The change saves a few queries again. To get an idea of the current
state, I measured query count of functional test
DataScenarios/Regular/{Modify|WorkspacesModify}/ActionTest.php
"movePageToDifferentPageTwice". "Before checkpoint" is git commit
eb7776ab2b35ebb49efe2088c17709b500522880, a commit before the
current series of DataHandler improvements.
Before: Modify: 739; WorkspacesModify 1555
With patch: Modify 469; WorkspacesModify 934
The absolute numbers don't say much (and mysql probably counts
each "true" query twice due to sql preparation, unsure).
But we can see these patches not only make more DataHandler
code maintainable, but also improve performance. For move, we
shaved off about 1/3 of queries already, other operations
got some share as well. There is potential for much more.
DataHandler.php:4356