Conversation
…Variable(), eliminating per-row overhead - Move Horde_Form_Variable initialization from row.inc into constructor, leveraging Horde_Form::createVariable() instead of direct getType() calls, eliminating per-row per-column isset() checks and throwaway Horde_Form instantiations - Normalize email column type to 'html' at initialization time - Replace index-based for loop in row.inc with foreach over columns, using parallel index into pre-built variables array - Remove now-unused $form property (was always null) and pass null directly to renderer->render() - Restrict $variables and $columns to protected visibility - Mark unused variables in display() for removal ($hasDelete, $hasEdit, $hasExport, $start, $end)
|
Please double check if this is still needed - today's release cannot reproduce the issue reported. |
|
Yes, it fixes the issue, but this PR should still be merged as it also redesigns the class by eliminating bad code. |
|
It is also important to note that for V3 type is part of variable class, so the approach "create type, then create variable using this type" would not be viable. By using |
|
Also, I just noticed this in horde/Form@dd8194a: I am sorry, but The V3 types merge |
createVariable is a good step forward but it has a major caveat: It tries to wrap concerns of constructing a variable-of-type into an operation USING that type. That's OK for now but I would much prefer that new thing eating a typed interface. ´´´ ´´´ In the current form I'd rather not propagate the bag of attributes pattern in new places. Going forward, I'd like to support this style: In the current form I veto this PR. |
ralflang
left a comment
There was a problem hiding this comment.
Please untangle the "better handling" aspect from the createVariable aspect.
Please explain permission handling in the new model and then remove rather than comment out code.
|
|
||
| $this->columns = $columns ?? []; | ||
| foreach ($this->columns as $column) { | ||
| $type = $GLOBALS['attributes'][$column]['type']; |
There was a problem hiding this comment.
Avoid new access to globals. Feed the global into the view constructor and use it as a member variable inside.
| $type = 'html'; | ||
| $params = []; | ||
| } else { | ||
| $params = $GLOBALS['attributes'][$column]['params'] ?? []; |
There was a problem hiding this comment.
Avoid new access to globals. Feed the global into the view constructor and use it as a member variable inside.
| $hasDelete = $driver->hasPermission(Horde_Perms::DELETE); | ||
| $hasEdit = $driver->hasPermission(Horde_Perms::EDIT); | ||
| $hasExport = ($GLOBALS['conf']['menu']['import_export'] && !empty($GLOBALS['cfgSources'][Turba::$source]['export'])); | ||
| //$hasDelete = $driver->hasPermission(Horde_Perms::DELETE); |
There was a problem hiding this comment.
No - please explain how permissions are now handled and then remove the code, don't comment out.
| $max = $min + $perpage; | ||
| $start = ($page * $perpage) + 1; | ||
| $end = min($numitem, $start + $perpage - 1); | ||
| //$start = ($page * $perpage) + 1; |
| } else { | ||
| $params = $GLOBALS['attributes'][$column]['params'] ?? []; | ||
| } | ||
| $this->variables[] = Horde_Form::createVariable('', $column, $type, $params); |
There was a problem hiding this comment.
See generic discussion on createVariable - keep the current solution until we have finalized the createVariable discussion. We should separate both aspects to unblock this current PR.
Pre-initialize column variables via createVariable(), eliminating per-row overhead
Horde_Form_Variableinitialization from row.inc into constructor,leveraging
Horde_Form::createVariable()instead of directgetType()calls, eliminating per-row per-column
isset()checks and throwawayHorde_Forminstantiationsusing parallel index into pre-built variables array
$formproperty (was always null) and pass nulldirectly to
renderer->render()$variablesand$columnsto protected visibility$hasDelete,$hasEdit,$hasExport,$start,$end)This fixes #25 (inability to view address books with customized columns).
IMPORTANT: This code relies on the recent change ( see horde/Form@971e5ee) in
Horde_Formclass.