Enhance SQL query reduction in page tree in workspaces
This changeset is a follow-up to the changes for issue #50349 and
it partly reverts the changes that have been introduced back then.
- Allow early return on first found record in hasPageVersions.
The previous implementation performed SQL queries on all tables
that are defined in the global TCA array. Now the first version
occurrence is enought to infer that a page has versions.
- Integrate hooks to modify the determined results. This way, the
meaning of having versions can be modified by hooks further.
For instance the default behavior of the TYPO3 core is to create
a workspace version record on persisting the same record in the
backend - without any actual changes to the data model.