Bug in multilingual plugin for empty searches

Found a bug? Tell us!!
Post Reply
stephanbrunker
Regular
Posts: 23
Joined: Sat Nov 25, 2017 12:08 am

Bug in multilingual plugin for empty searches

Post by stephanbrunker »

Hello,

I don't want to nag, but I don't know if you appreciate if a bug is discovered, even a small one.

In this case: If the quicksearch returns empty or too short, the multilingual plugin is not triggered, so the title is not translated and is displayed with the {{}} brackets. If entries are shown as result, these entries trigger the strip_languages() function on the title and description.

Unfortunately, I don't know enough to locate the problem, like which event is triggered for the empty search of is simply none is triggered … in the genpage, it is get - action = search, and the genpage hook with title translation is listed in the plugin, but it doesn't work.
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Bug in multilingual plugin for empty searches

Post by onli »

I don't want to nag, but I don't know if you appreciate if a bug is discovered, even a small one.
We do! Let's see whether we can pinpoint the issue. Only thing better than bug reports are pull requests ;)

Could you debug this a bit more? Is tag_title being called on that search result page when the error occurs?
stephanbrunker
Regular
Posts: 23
Joined: Sat Nov 25, 2017 12:08 am

Re: Bug in multilingual plugin for empty searches

Post by stephanbrunker »

Stupid question - how do find out if tag_title is being called? Only thing I did was a look in the source code and with $serendipity['production'] = 'debug' I get the smarty vars, with the unprocessed $BlogDescription string.

PS: I got creative and changed the tag_title function to display nonsense in the title:

Code: Select all

$serendipity['smarty']->assign('blogTitle', 'BBB');
But this nonsense doesn't appear in the empty search result, so the answer is no. I did the same within the genpage hook in the multilingual plugin, and this hook is called. But the line

Code: Select all

$serendipity['blogDescription'] = $this->strip_langs($serendipity['blogDescription']);
there doesn't have an effect while this smarty->assign does. There are the $serendipity vars and the smarty vars and somewhere in between it doesn't work.

For archive pages, the genpage hook calls the smarty assign for the title explicitly - why?

Code: Select all

                    // assign lang stripped blogTitle to archive page, which overwrites them for case archive pages
                    if ($serendipity['plugindata']['smartyvars']['view'] == 'archive') {
                        $serendipity['smarty']->assign('blogTitle', $serendipity['blogTitle']);
                        $serendipity['smarty']->assign('blogDescription', $serendipity['blogDescription']);
                    }
                    
Doing that for all pages or the search result too would work, but is that the right solution?
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Bug in multilingual plugin for empty searches

Post by onli »

how do find out if tag_title is being called?
I would have added a

Code: Select all

echo "tag_title";
at the top of the function, that would then be displayed at the top of the page.
For archive pages, the genpage hook calls the smarty assign for the title explicitly - why?
I guess it depends on when this gets called. If serendipity later assigns the regular blogTitle and description the smarty variables could get overwritten.

Or it might be that the plugin grew a bit organically and these are different approaches mixed together, without a real reason.
Doing that for all pages or the search result too would work, but is that the right solution?
I'm not familiar at all with how the plugin works. The strange thing is that the search result page look different depending on whether there are search results. That might come from something in the core, different behaviour with the smarty variables by ending earlier. But I would suggest to try it out: If assigning those variabels explicitely like for the archives pages fixes the bug, then that would work for me.
stephanbrunker
Regular
Posts: 23
Joined: Sat Nov 25, 2017 12:08 am

Re: Bug in multilingual plugin for empty searches

Post by stephanbrunker »

Okay, i took the quick fix and removed the if-statement, so that the assign in the genpage hook is now done no matter what and that worked. Would you like to implement the fix yourself or should I make an pull request via Github?
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Bug in multilingual plugin for empty searches

Post by onli »

I'd much prefer a pull request via github :) You can also directly raise the version number in there.
Post Reply