Stringy error (probably on bots)

I’m getting quite a few of those errors, the reversed DNS seems to imply those are caused by bots. Anything I can (should) do about it?

Uncaught InvalidArgumentException: Passed value cannot be an array in /lib/pkp/lib/vendor/danielstjules/stringy/src/Stringy.php:45
Stack trace:
#0 /lib/pkp/lib/vendor/danielstjules/stringy/src/Stringy.php(73): Stringy\\Stringy->__construct(Array, NULL)
#1 /lib/pkp/classes/core/PKPString.inc.php(160): Stringy\\Stringy::create(Array)
#2 /cache/t_compile/a95e9f20492587d73a4f35fa465ca6ee809b9709^c2055d14f27582f3361894f4184ce1a4c0497385_0.app.frontendpagessearchAuthor.php(58): PKPString::substr(Array, 0, 1)
#3 /lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6374e0eff31788_65506955(Object(Smarty_Internal_Template))
#4 /lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template))
#5 /lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template))
#6 /lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1)
#7 /lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'a95e9f20492587d...', NULL, 1)
#8 /lib/pkp/classes/template/PKPTemplateManager.inc.php(1187): Smarty_Internal_TemplateBase->display('frontend/pages/...', NULL, 'a95e9f20492587d...', NULL)
#9 /pages/search/SearchHandler.inc.php(297): PKPTemplateManager->display('frontend/pages/...')
#10 /lib/pkp/classes/core/PKPRouter.inc.php(395): SearchHandler->authors(Array, Object(Request))
#11 /lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)
#12 /lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route(Object(Request))
#13 /lib/pkp/classes/core/PKPApplication.inc.php(362): Dispatcher->dispatch(Object(Request))
#14 /index.php(68): PKPApplication->execute()
#15 {main}
  thrown in /lib/pkp/lib/vendor/danielstjules/stringy/src/Stringy.php on line 45

Hi @luizborges,

Have you already checked similar issues on the forum? E.g.: [OJS 3.2.1.1] danielstjules/stringy/src/Stringy.php error

@Vitaliy yes, I’ve seen that before (my mistake, I forgot to mention) and checked the database, I had some ‘primaryLocale’ in the ‘journal_settings’ (no null values) and I removed those. The issues still persists.
image

Also forgot to mention that I have on the last available OJS installed and this still happens.

It looks like the problem occurs here: ojs/searchAuthorIndex.tpl at stable-3_3_0 · pkp/ojs · GitHub (template for the search authors page ...[journal url]/search/authors)

In particular, $author->getLocalizedFamilyName() should be a string but according to the message, it returns an array. I’d debug here the same way as in the referenced post but looking at the author_settings table. There may be a duplicate of setting_name => familyName for the same author id (and locale), which leads to returning of multiple values or an invalid entry in setting_value

By the way, this page is deprecated and won’t be used since the next major OJS release

Good to know, I’m anxious for the 3.4 :slight_smile:

In the meantime, is there something I could/should do? This seems to be only affecting bots, so this is not much of a concern, but can I clean up the database somehow to make it “better”?

A duplicate is unlikely when looking at the unique index in this table, which includes author_id, locale, and setting_name columns. Maybe there is an unusual value for the familyName, which causes the error. But I can’t reproduce it and don’t know exactly what to look for. Are you using the Default theme? If it’s the custom one, which overrides the page, it can also explain the problem if that part of code is modified.

I’m on the Default theme. If there anything I can do to find the “offending” name, let me know.

As I don’t know what to look at the database, I’d try to debug it locally by installing OJS from a backup. If it’s possible to reproduce it locally, then, e.g., just add a debugging statement near the line I’ve pointed above. Something like:

{if is_array($author->getLocalizedFamilyName())}
  malformed data at author ID: {$author->getId()} 
{/if}  

The value(s) will be displayed on the search authors index page. And then check the values in the database, e.g., if author ID is 100 and you have only 1 locale:

SELECT * FROM author_settings WHERE author_id = 100 AND setting_name = 'familyName';

If it’s several authors, use WHERE IN instead:

SELECT * FROM author_settings WHERE setting_name = 'familyName' AND WHERE author_id IN (100,101,102);