Closed (fixed)
Project:
Internationalization Views
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 May 2018 at 08:03 UTC
Updated:
20 Apr 2023 at 17:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kris77 commentedI have the same issue...
Comment #3
Anonymous (not verified) commentedMaybe related:
When saving a view translation I get
Warning: addcslashes() expects parameter 1 to be string, array given in DatabaseConnection->escapeLike() (regel 1007 van /home/dev/domains/.....path....../includes/database/database.inc).Comment #4
antims commentedMe too.
Comment #5
maxmendez commentedMe too.
Comment #6
nicofnjnu commentedSame issue here.
Warning: addcslashes() expects parameter 1 to be string, array given in DatabaseConnection->escapeLike()
Comment #7
marinex commentedMe too!!!
Comment #8
amirma commentedSubscribe!
Comment #9
Anonymous (not verified) commentedI'm facing this too.
I've been trying to find the problem for a while now and so far it looks like the error from title
is different than the error that breaks the site from the parts where translated view is used.
Second error comes from entity.wrapper.inc line 760~
where empty value is pushed to function and validation fails. One can comment out the 'throw new...' and everything works but this doesn't fix the problem.
If somebody who knows more how this system works could give a hint from where these functions are called (DB queries to find the translation I presume), I can try to search for a solution.
Comment #10
Anonymous (not verified) commentedOkay, after a day well spent this patch is what I came up with.
This might introduce problems with security if malicious user has translate privileges. (I'm not sure. Maintainer, please have a look)
BUT...
If I understood correctly the
function save_string($string, $keys = array(), $format = '')with the I18N_STRING_FILTER_XSS_ADMIN doesn't allow saving the translation with any malicious code and thefunction translate_string($string, $keys = array(), $format = '') {modified in the patch just does the printing of the strings (strings that should be secure as the save_string already checked that??)Edit.
In my project this removes the error
introduced in the title and also the errorfrom entity.wrapper 'The website encountered an unexpected error. please try again later' that was breaking practically the whole site.I translated few lines and got the error again, It's one huge array printed to the list of translateable view names. Tried dpm() the array and it crashed the browser.
Comment #11
Anonymous (not verified) commentedComment #12
tankeroo commentedI have the same issue! following and will apply patch once maintainer approves.
Comment #13
anybodySame problem here!
Comment #14
sano commented... applied the patch and tried to translate a string. Upon saving the translation I see the same error; so no change here.
Comment #15
maxmendez commentedI've tested the patch #10 an it does not fixed the problem, so i've debugged from escapeLike using debug_backtrace and detects that i18nviews_translate_page_form was calling views_invalidate_cache as a submit function.
This is a bad implementation of views_invalidate_cache because it will received incorrect parameter (https://api.drupal.org/api/views/views.module/function/views_invalidate_...).
I've created a custom submit function to call views_invalidate_cache without parameter and the problem disapeared.
Comment #16
anrikun commentedComment #17
anrikun commentedPath at #15 works for me.
Comment #18
poker10 commentedThis throws an error on PHP 8.1:
After applying the patch #15 the error is gone.
Comment #19
nedjoThanks for reporting this issue and submitting a patch.
Confirming that the patch at #15 correctly addresses what is clearly an error in the code. Nice!
More specifically:
i18nviews_translate_page_form(),views_invalidate_cache()is registered as a form submit handler.views_invalidate_cache()is an optional cache ID string, with a default value provided. As a result, an invalid value (a form array) is passed in.views_invalidate_cache()- correctly addresses this error.Exactly how does this fix relate to the reported error? That's a bit more involved. Here are the specific steps:
views_invalidate_cache()callscache_clear_all($cid), feeding the form array as$cid.cache_clear_all()loads a database cache object and calls its::clear()methodreturn _cache_get_object($bin)->clear($cid, $wildcard);::clear()method callsdb_like()as part of generating an argument value:db_delete($this->bin)->condition('cid', db_like($cid) . '%', 'LIKE')->execute();db_like()calls the database connection object's::escapeLike()method.::escapeLike()method callsaddslashes(), feeding an array rather than a string, and thus triggers the error.Nitpick: it would be nice to have a "docblock" for the new form submit callback.
Comment #21
nedjoThx, applied.