Refactor VarRenderer class to use candidates for class loading#119
Closed
TDannhauer wants to merge 1 commit into
Closed
Refactor VarRenderer class to use candidates for class loading#119TDannhauer wants to merge 1 commit into
TDannhauer wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
Horde_Core_Ui_VarRenderer::factory()app renderer resolutionSummary
Horde_Core_Ui_VarRenderer::factory()so lowercase application IDs invarrenderer_driver(e.g.['kronolith', 'html']) resolve to the correct{App}_Ui_VarRenderer_{Driver}class via Composer autoload.include_oncefallback that could instantiateHorde_Core_Ui_VarRenderer_*after loading an application renderer file.Horde\Util\HordeStringfor string normalization instead of deprecatedHorde_String.Problem
Horde applications extend
Horde_Core_Ui_VarRenderer_Htmlwith app-specific classes (e.g.Kronolith_Ui_VarRenderer_Html,Turba_Ui_VarRenderer_Html) to render custom form field types. Forms pass a driver tuple to the form renderer:When the factory cannot load the application renderer, form fields fall back to
Horde_Core_Ui_VarRenderer_Html::_renderVarInputDefault(), which outputs inline HTML such as:Those messages are usually not written to the application log.
Root cause
In
Horde_Core_Ui_VarRenderer::factory():Horde_String::ucfirst()(html→Html).kronolith→kronolith).kronolith_Ui_VarRenderer_Html, which is not in Composer’s classmap (Kronolith_Ui_VarRenderer_Htmlis).Autoload failed. The legacy path then:
include_once’d the app’slib/Ui/VarRenderer/Html.php(definingKronolith_Ui_VarRenderer_Html, etc.).class_exists('Horde_Core_Ui_VarRenderer_Html')— always true.new Horde_Core_Ui_VarRenderer_Html()— the base renderer without app-specific_renderVarInput_*methods.This regressed as applications renamed renderers to
{App}_Ui_VarRenderer_{Driver}for classmap autoloading without updating the factory fallback.Solution
lib/Horde/Core/Ui/VarRenderer.phpinclude_onceor registry fileroot paths).{Ucfirst(app)}_Ui_VarRenderer_{Ucfirst(driver)}— matches Composer classmap names.{app}_Ui_VarRenderer_{Ucfirst(driver)}— only if different from (1), for callers that already pass a capitalized app id.Horde_Core_Ui_VarRenderer_{Ucfirst(driver)}— fallback when an app has no custom renderer.Horde\Util\HordeString::ucfirst()andbasename()for driver normalization.Package
horde/core—Horde_Core_Ui_VarRenderer::factory()only.Test plan
lib/Ui/VarRenderer/Html.phpand lowercasevarrenderer_driver(e.g. Kronolith calendar edit, Turba contact edit, Ingo filter forms), open a form that uses app-specific field types and confirm controls render correctly (no “Unknown variable type” warnings).reloadaction on a field that usesHorde_Form_Action_reloadand confirm the re-rendered form still uses the application renderer.varrenderer_driverset to'html'only (no app segment) still usesHorde_Core_Ui_VarRenderer_Html.Horde_Core_Ui_VarRenderer_Htmlwhen passing['someapp', 'html'].Notes for reviewers