- FIX: Null check during child recursion of e_tree_model::flattenTree()
- FIX: TreeModelTest::testTreeParentsAreAssignedCorrectly() apparently never worked until now because the wrong index was used
There were two cases that led to missing tree nodes:
* If one node at the same depth as another node had a higher primary
key ID but showed up in the rows before, the lower primary key ID node
will go missing.
* If an unmatching row for the current node in moveRowsToTreeNodes
appeared between a matching row, the matching row would never be
reached and would not be added to the tree.
e_tree_model::prepareSimulatedCustomOrdering() performed an ORDER BY
second sort that doesn't add any benefit at all and causes #3086.
This second sort has been removed.
Fixes: #3086
e_tree_model is apparently used for flat lists as well as parent-child
relationships (trees). Trees are expected to be far smaller than possible flat
lists. Very large flat lists (10,000+ rows or greater) are rendered very slowly
because of the tree computation overhead.
This change figures out whether a flat list or a tree is requested and chooses
the appropriate code to run based on what is requested. Trees run the more
expensive code while flat lists are returned as-is.
In addition, the tree rendering code has been optimized. Optimizations:
* Unchanging tree node ID is set once instead of inside a foreach() loop
* The parent-child query is now sorted by the sort parent ID so that each move
rows to tree nodes iteration doesn't have to run through every remaining row
Fixes: #3062
An untested oversight in e_tree_model::multiFieldCmp() where $sort_field
could be a string has now been corrected.
$sort_field now accepts a string to prevent infinite recursion.
Fixes: #3044
e_tree_model::prepareSimulatedPagination() did not correctly handle the
count-only condition because of an incorrectly written emptiness check.
Fixes: #3034
In #3025, e_tree_model sorting was reimplemented in pure PHP, but this
broke custom sorting (like `?field=cat_name&asc=desc`).
This commit introduces a hack that simulates a subset of MySQL/MariaDB
ORDER BY clauses, which should be sufficient for all known custom
sorting that can be requested.
Tree formatting is always preserved, but custom sorting will apply for
all items at a certain depth under the same parent.
This commit also contains some minor formatting fixes and makes a minor
change to some regex to make use of non-capturing groups.
Fixes: #3029
Implementation parses db_query parameter and extracts the offset and/or
count from `LIMIT {offset} OFFSET {count}` or syntactically similar
Fixes: #3015
Supersedes: #3016
Eliminated e107 dependency on the MySQL/MariaDB CREATE PROCEDURE permission
As a bonus, any attempt to use e107's native custom sorting (e.g.
`?field=cat_name&asc=desc`) will preserve the correct tree hierarchy. The past
behavior was to sort as requested but keep showing depth, even though the
apparent tree hierarchy would be wrong.
Fixes: #3015
Supercedes: #2929