Problem/Motivation

On Drupal 9, I see the following error message:

Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of theme_google_cse_search_noresults(). See https://www.drupal.org/node/1831138 in Drupal\Core\Theme\Registry->processExtension() (line 498 of core/lib/Drupal/Core/Theme/Registry.php).

Proposed resolution

Research (below) has determined that the "No results" behavior in this module is, and has always been non-functional. Therefore, the maintainers recommend that the nonfunctional code related to this be removed.

Issue fork google_cse-3178602

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jwilson3 created an issue. See original summary.

jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB
juanolalla’s picture

Great work, thanks @jwilson3.

It works well but I don't get why you use 'variables' => ['message' => ''], in the theme function instead of no_results_message.

jwilson3’s picture

Status: Needs review » Needs work

Good point @juanolalla.

That's a mistake. 'variables' => ['message' => ''], was a vestige of my first approach at writing the code in a different way.

AFAICT simply removing that line should have no negative effect, but this needs to be tested.

mark_fullmer made their first commit to this issue’s fork.

mark_fullmer’s picture

Thanks for the report and the proposed patch. That theme implementation certainly is deprecated, so we should do something about it, but I first have a couple questions.

I'd been involved in the resolution of #3159988: Remove references to "Google CSE Advanced" awhile back, during which time we discovered that most of the configuration provided by this plugin was added in a long time ago as an attempt to merge the base Google CSE functionality with a now-deprecated Google API for advanced options. Our discovery was that most of the configuration in the plugin in nonfunctional.

Therefore, can you provide steps of under what circumstances the "No results" input is being honored/displayed? When I test the behavior and input a string that will generate no results, I only see the Google Javascript-provided results, not anything generated from a Drupal theme function.

I could be missing something, but looking at the code, also don't see how the no results behavior would end up on a page. Before, and after this patch, there is a hook_theme() implementation registered in the .module file, but there is nowhere in code that actually calls that theme function.

Specifically, I did a search for the string google_cse_search_noresults throughout the module. There was no render invocation via #theme. In contrast, for example, there are invocations of the main google_cse_results theme function.

If I am correct and the no results behavior actually is nonfunctional, I propose we just remove the functionality related to "No results" to resolve the deprecation problem. That's a subset of everything that needs to be removed, but it's a start. Merge request coming.

mark_fullmer’s picture

Status: Needs work » Needs review

The provided merge request in https://git.drupalcode.org/project/google_cse/-/merge_requests/1 completely removes the non-functional "No results" behavior, including the input on the configuration form.

As a byproduct, this fixes the Drupal 10 deprecation warning of using a theme function directly in hook_theme that was the cause of this original issue report.

Setting to "Needs Review."

If the reviewer(s) agree that the no results behavior is non-functional and should be removed, the issue title should be changed to reflect the focus to "Remove non-functional no results behavior."

superfluousapostrophe’s picture

@mark_fullmer I think you are right. When I worked on the patch for #3094772, I was never able to trigger that particular function. As you suggested, the entirety of the results appear to come straight from the Google side of things. I think it would be fine to remove that code.

mark_fullmer’s picture

Title: Theme functions are deprecated theme_google_cse_search_noresults() » Remove non-functional 'no results' behavior.
Issue summary: View changes

I've changed the issue title and updated the description to capture the new scope/intent.

superfluousapostrophe’s picture

The changes in merge request in #10 work for me. I don't see any other issues with removing the code relating to no search results.

ccjjmartin’s picture

Status: Needs review » Reviewed & tested by the community

At first I wondered why we were removing the code in the MR but not in the original patch, after looking over this issue this makes sense to me and functionally this checks out too. Marking this as RTBC.

  • mark_fullmer committed 87529dc on 8.x-3.x
    Issue #3178602 by mark_fullmer, jwilson3, SuperfluousApostrophe,...
mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.