- 🇨🇦Canada nedjo
Thanks for reporting this issue and submitting a patch.
Confirming that the patch at #15 🐛 Warning: addcslashes() expects parameter 1 to be string, array given in DatabaseConnection->escapeLike() Fixed correctly addresses what is clearly an error in the code. Nice!
More specifically:
- Currently, in
i18nviews_translate_page_form()
,views_invalidate_cache()
is registered as a form submit handler. - The first argument passed to a form submit callback is a form array.
- However, the first argument to
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. - The proposed fix - register a new form submit callback and, from there, call
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:
- When invoked as a form submit callback,
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.- The
::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.
- Currently, in
-
nedjo →
committed 25486536 on 7.x-3.x authored by
MaxMendez →
Issue #2975245 by MaxMendez: Warning: addcslashes() expects parameter 1...
-
nedjo →
committed 25486536 on 7.x-3.x authored by
MaxMendez →
- Status changed to Fixed
about 2 years ago 5:01pm 6 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.