Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Use render() as primary ViewHelper method #983

Merged
merged 1 commit into from
Aug 24, 2024

Commits on Aug 24, 2024

  1. [TASK] Use render() as primary ViewHelper method

    Until now it was best practice to differentiate between object-based
    ViewHelpers, using the object method `render()` as their primary render
    method, and static ViewHelpers, using the static method `renderStatic()`.
    This distinction has been introduced to Fluid mainly for performance reasons:
    With earlier PHP versions it was quite expensive performance-wise to create a
    new ViewHelper object for each ViewHelper call. However, PHP's performance
    characteristics for objects have changed quite a bit with newer versions,
    which questions the usefulness of this performance optimization nowadays.
    
    Our performance tests have shown that the performance gains are still existent
    today if you compare `renderStatic()` to `render()` ViewHelpers, especially
    if no further optimizations are applied to Fluid's core implementation.
    However, the impact is quite small and almost not measurable in real-world
    scenarios.
    
    In contrast to that, we see meaningful opportunities for the further development
    and optimization for Fluid if we streamline and simplify Fluid's APIs. It
    improves the developer experience if there's only one correct way to
    implement ViewHelpers and if all ViewHelpers use the same API. For Fluid
    internally, this opens up new opportunities of optimization and refactoring,
    which are currently not feasible to tackle.
    
    Ultimately, we have taken the decision to deprecate `renderStatic()` with Fluid v4.
    ViewHelpers should use `render()` as their primary render method from now on.
    This patch deprecates both the trait `CompileWithRenderStatic` and the usage
    of `renderStatic()` without any trait applied to the ViewHelper (which is probably
    only an edge case). Instead, the `ViewHelperInvoker` is called both for uncached
    and cached templates to initiate and perform each ViewHelper call.
    
    We will backport the `@deprecated` annotation on `CompileWithRenderStatic` to
    Fluid v2.15 to let users know in advance of this change.
    
    `AbstractConditionViewHelper` will be adjusted to this change in a follow-up patch.
    There will probably also be further code optimization patches that are made possible
    because of this decision, either still in Fluid v4 or later in Fluid v5, when
    `renderStatic()` will be removed completely.
    s2b committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    54f5eb7 View commit details
    Browse the repository at this point in the history