backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Failed to open stream: No such file or directory in views_plugin_display->options_form()

Open alanmels opened this issue 1 year ago • 5 comments

Steps To Reproduce

To reproduce the behavior:

  1. Enable the Entity Reference module.
  2. Enable showing all error messages under admin/config/development/logging.
  3. Go to /admin/structure/views/view, select any Views.
  4. Add Entity reference display and then click on the Information link under the Other section against the Theme: option.
  5. Click on Style output or Row style output -> the default theme template text box is empty, and errors are shown 👎🏼

The errors for each selection are respectively:

Warning: file_get_contents(./core/modules/views/theme/views-view-unformatted.tpl.php): Failed to open stream: No such file or directory in views_plugin_display->options_form() (line 2040 of /var/www/html/docroot/core/modules/views/plugins/views_plugin_display.inc).

and

Warning: file_get_contents(./core/modules/views/theme/views-view-fields.tpl.php): Failed to open stream: No such file or directory in views_plugin_display->options_form() (line 2067 of /var/www/html/docroot/core/modules/views/plugins/views_plugin_display.inc).

alanmels avatar Jun 25 '24 04:06 alanmels

Additional Information

  1. The path /core/modules/views/theme/ does not exist, because all the templates are in the /core/modules/views/templates/.

  2. The code block around offending line 2040 looks like this:

{
          $output .= '<p>' . t('This is the default theme template used for this style.') . '</p>';
          $output .= '<textarea readonly="readonly" rows="15" cols="82" class="code-sample">' . check_plain(file_get_contents('./' . $plugin->definition['theme path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</textarea>';
        }

Looking the content of $plugin->definition shows an array of 17 elements:

 (Array, 17 elements)

    title (String, 21 characters ) Entity Reference list
    help (String, 54 characters ) Returns results as a list of labels and rendere...
    handler (String, 28 characters ) entityreference_plugin_style
    theme (String, 22 characters ) views_view_unformatted
    theme path (String, 24 characters ) core/modules/views/theme
    theme file (String, 9 characters ) theme.inc
    uses row plugin (Boolean) TRUE
    uses fields (Boolean) TRUE
    uses options (Boolean) TRUE
    type (String, 15 characters ) entityreference
    even empty (Boolean) TRUE
    module (String, 15 characters ) entityreference
    path (String, 36 characters ) core/modules/entityreference/plugins
    file (String, 32 characters ) entityreference_plugin_style.inc
    parent (String, 6 characters ) parent
    name (String, 21 characters ) entityreference_style
    uses grouping (Boolean) TRUE

and as you see the used theme path element has a value of core/modules/views/theme, which does not exist. I am not sure here if the theme path is really needed in order not to break anything, and a new template path element must be added indicating the existing core/modules/views/templates, or just the value must be replaced with the existing path.

alanmels avatar Jun 25 '24 04:06 alanmels

Confirmed @alanmels 👍🏼 ...it seems to be an easy fix. PR coming up.

klonos avatar Jun 25 '24 04:06 klonos

Jinx 😅 ...closing my PR.

klonos avatar Jun 25 '24 04:06 klonos

Pardon @klonos, I was doing the same staff :)

alanmels avatar Jun 25 '24 04:06 alanmels

No worries @alanmels ...this is RTBC.

PS: I've updated the issue summary with some additional steps to reproduce the problem more easily.

klonos avatar Jun 25 '24 04:06 klonos

Thanks @alanmels and @klonos! I merged https://github.com/backdrop/backdrop/pull/4812 into 1.x and 1.28.x.

quicksketch avatar Aug 30 '24 20:08 quicksketch