Problem/Motivation
We had some reports last week of a user getting 5xx errors when trying to save translations.
When looking at the logs for those days and times (Friday 26th May, Saturday 27th May), we can see some errors and warnings.
The error is due to trying to set the "translation" column to NULL, so triggers a PDO exception.
Related to the error, there is a warning for the "l10n_community_pack_string" function regarding implode.
There are two things we can improve here:
1. When adding translations, the code only checks if $tranlation === '' but that might not be enough in some cases.
2. Also, if "implode" receives a string instead of an array, it will return NULL, so it might be connected in this case.
Steps to reproduce
Proposed resolution
Change the check for a more generic PHP empty call and check the input before trying to run "implode" to make sure that it's an array.
Remaining tasks
Provide MR.
User interface changes
API changes
Data model changes
Issue fork l10n_server-3363293
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
Comment #2
fjgarlin commentedComment #3
fjgarlin commentedComment #5
fjgarlin commentedComment #6
fjgarlin commentedComment #7
fjgarlin commentedComment #8
bramdriesenFollowed this thread in Slack. Code changes look straight forward to me so RTBC.
Comment #9
bramdriesenProbably worth double checking if the same issue is present in the ported code for the D9/10 release.
Comment #10
fjgarlin commentedGood point. It seems like it could also happen there based on this: https://git.drupalcode.org/issue/l10n_server-3363293/-/blob/3.0.x/l10n_s...
If the current 7.x fix gets merged then we can follow up with a similar one for 3.0.x? 2.0.x? or we can chat about it on the #localize channel.
Comment #11
fmb commentedThe 2.0.x branch is abandoned. A fix is welcome on the 3.0.x branch. If you need to run a local instance, the code of the platfom is on GitLab.
Comment #12
fjgarlin commentedAfter reviewing the code in more depth, I don't think this will happen in the 3.0.x branch.
The parameters of the affected functions are typed. See:
*
public static function addSuggestion(int $sid, string $translation, string $langcode, ...*
protected function packString(array $strings)...Also, the code is doing some additional checks, before calling them, which will force them to be the right type.
ie:
where
$all_valueswill only be greater than$empty_valuesif$options['value']is an array and is not empty.So it seems like the fix is only needed on the 7.x version.
Comment #13
bramdriesenGreat, thanks for checking @fjgarlin. Still RTBC in that case
Comment #16
drummMerged & deployed, thanks!