Skip to content
Snippets Groups Projects

Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28

Closed Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28
3 unresolved threads
Closed Alexandre Dias requested to merge issue/drupal-3313342:3313342- into 9.5.x
3 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
25 25 * {@inheritdoc}
26 26 */
27 27 public function getContext() {
28 return 'is_layout_builder_ui.' . (int) (strpos($this->routeMatch->getRouteName(), 'layout_builder.') !== 0);
28 if (!empty($this->routeMatch->getRouteName()) && strpos($this->routeMatch->getRouteName(), 'layout_builder.') === 0) {
  • Jess
    Jess @xjm started a thread on the diff
  • 25 25 * {@inheritdoc}
    26 26 */
    27 27 public function getContext() {
    28 return 'is_layout_builder_ui.' . (int) (strpos($this->routeMatch->getRouteName(), 'layout_builder.') !== 0);
    28 if (!empty($this->routeMatch->getRouteName()) && strpos($this->routeMatch->getRouteName(), 'layout_builder.') === 0) {
    29 return 'is_layout_builder_ui.1';
    30 }
    31 return 'is_layout_builder_ui.0';
    • Comment on lines +29 to +31
      Maintainer

      Isn't this still inverting the logic? The previous code, read as a sentence, is:

      Return is_layout_builder_ui. concatenated with the integer cast of the boolean result for: "Does the route name not start with layout_builder?"

    • @xjm : Can you pls give clarity on this comment.

      Do you mean to say that the return statements need to be reversed like below?

          if (!empty($this->routeMatch->getRouteName()) && str_starts_with($this->routeMatch->getRouteName(), 'layout_builder.')) {
            return 'is_layout_builder_ui.0';
          }
          return 'is_layout_builder_ui.1';
    • Please register or sign in to reply
  • 158 158 // If the entity is displayed within a Layout Builder block and the current
    159 159 // route is in the Layout Builder UI, then remove all contextual link
    160 160 // placeholders.
    161 if ($display instanceof LayoutBuilderEntityViewDisplay && strpos($route_name, 'layout_builder.') === 0) {
    161 if ($display instanceof LayoutBuilderEntityViewDisplay && !empty($route_name) && strpos($route_name, 'layout_builder.') === 0) {
  • Bhanu D added 1 commit

    added 1 commit

    • 43fc8126 - Replaced strpos with str_starts_with.

    Compare with previous version

  • Alexandre Dias changed target branch from 10.0.x to 9.5.x

    changed target branch from 10.0.x to 9.5.x

  • Please register or sign in to reply
    Loading