Failed to open stream: No such file or directory in views_plugin_display->options_form()
Steps To Reproduce
To reproduce the behavior:
- Enable the Entity Reference module.
- Enable showing all error messages under
admin/config/development/logging. - Go to
/admin/structure/views/view, select any Views. - Add
Entity referencedisplay and then click on theInformationlink under theOthersection against theTheme:option. - Click on
Style outputorRow 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).
Additional Information
-
The path
/core/modules/views/theme/does not exist, because all the templates are in the/core/modules/views/templates/. -
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.
Confirmed @alanmels 👍🏼 ...it seems to be an easy fix. PR coming up.
Jinx 😅 ...closing my PR.
Pardon @klonos, I was doing the same staff :)
No worries @alanmels ...this is RTBC.
PS: I've updated the issue summary with some additional steps to reproduce the problem more easily.
Thanks @alanmels and @klonos! I merged https://github.com/backdrop/backdrop/pull/4812 into 1.x and 1.28.x.