OJS Version 3.4.0.5
Error similar to Failed Ajax request or invalid JSON returned (Reviewer). (Another Journal)
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in …/public_html/lib/pkp/classes/services/PKPSchemaService.php:598
I solved it by changing the following code snippet in PKPSchemaService.php:
foreach ($values as $key => $value) {
if (!in_array($key, $multilingualProps)) {
continue;
}
foreach ($localeKeys as $localeKey) {
if (is_array($value) && array_key_exists($localeKey, $value)) {
continue;
}
switch ($schema->properties->{$key}->type) {
case 'string':
$values[$key][$localeKey] = '';
break;
case 'array':
$values[$key][$localeKey] = [];
break;
default:
$values[$key][$localeKey] = null;
}
}
}
For:
foreach ($values as $key => $value) {
if (!in_array($key, $multilingualProps)) {
continue;
}
foreach ($localeKeys as $localeKey) {
// Verifica se $value é um array e se $localeKey não está presente em $value
if (!is_array($value) || !array_key_exists($localeKey, $value)) {
// Verifica se $values[$key] é um array
if (!isset($values[$key]) || !is_array($values[$key])) {
$values[$key] = [];
}
// Atribui o valor de acordo com o tipo de propriedade
switch ($schema->properties->{$key}->type) {
case 'string':
$values[$key][$localeKey] = '';
break;
case 'array':
$values[$key][$localeKey] = [];
break;
default:
$values[$key][$localeKey] = null;
}
}
}
}