Cannot access protected property XnttViewsQuery::$orderby

Created on 6 June 2025, 4 months ago

Problem/Motivation

When adding a sort to a view, this error is produced:

Error: Cannot access protected property Drupal\xntt_views\Plugin\views\query\XnttViewsQuery::$orderby in Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->query() (line 160 of core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php).

Drupal\views\ViewExecutable->build() (Line: 393)
Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 198)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1690)
Drupal\views\ViewExecutable->executeDisplay() (Line: 81)
Drupal\views\Element\View::preRenderViewElement()
call_user_func_array() (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 875)
Drupal\Core\Render\Renderer->doCallback() (Line: 432)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

  1. Create an EE with some fields.
  2. Create a view of that EE.
  3. Add some fields to the view.
  4. Add a sort to the view with one of the configured fields.
  5. Save it.
  6. Go look at the page/block/whatever.
  7. The error is shown.

Proposed resolution

I don't see a sort implementation at https://git.drupalcode.org/project/external_entities/-/tree/3.0.x/module..., maybe that's the problem?

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Views

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada colan Toronto ๐Ÿ‡จ๐Ÿ‡ฆ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @colan
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kalpanajaiswal

    Drupal Views core was built assuming Sql::$orderby is public.
    If query plugin replaces the default one and doesnโ€™t declare it (or keeps it protected), this line fails:

    $this->view->query->orderby
    

    in ExposedFormPluginBase::query() (line 160)

    Problem:
    protected array $orderby;
    Core Views expects this to be public because it accesses it directly from outside (e.g., in ExposedFormPluginBase::query()).

    Fix:
    public array $orderby = [];
    Also initialize it to an empty array to avoid undefined property errors when using null coalescing: foreach ($this->orderby ?? []).

    $fields should be public
    Core plugins may access $fields too, e.g., during rendering or sorting.

    public array $fields = []

  • Merge request !92Update file XnttViewsQuery.php โ†’ (Merged) created by kalpanajaiswal
  • Pipeline finished with Success
    3 months ago
    Total: 252s
    #546730
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada colan Toronto ๐Ÿ‡จ๐Ÿ‡ฆ

    Explanation & code make sense, but I haven't tested it. Thanks!

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance guignonv Montpellier

    Thanks kalpanajaiswal, I checked what you pointed out and the changes make sense (and not a big deal). Merged.
    @Colan if you can test and confirm the fix, I let you close the issue.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada colan Toronto ๐Ÿ‡จ๐Ÿ‡ฆ

    I'm not in a good position to test right now so let's just mark it fixed, and then reopen if there are problems.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada colan Toronto ๐Ÿ‡จ๐Ÿ‡ฆ
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024