Hello, I updated 1.6.1 to 1.6.2 and while testing the functionality of upload in Invoices I get this error in GUI:
The action you have requested is not allowed.
Log:
ERROR - 2025-01-03 14:18:58 --> Severity: error --> Exception: Upload::validate_csrf(): Return value must be of type bool, CI_Security returned
/application/modules/upload/controllers/Upload.php 183
Hey,
Did you try to reload the page after you uploaded something?
Can you tell the exact steps that you did before tou got these errors?
I’ve cut out the irrelevant information.
You did an awesome job with formatting the code, i just had to clean it a tiny bit to make the errors more readable
I have created Invoice, filled it with items, prices etc. Then went to Upload, select some file, it shows uploading status and when it goes to end it writes that inside Upload section. After reloading the page Upload sections is empty. I did test this on 1.6.1. and it worked. Yesterday I upgraded to v.1.6.2. and it is not working now.
1 Like
Open application/modules/upload/controllers/Upload.php
and scroll to line 183
It shows this:
private function validate_csrf(): bool
{
return $this->security->csrf_verify();
}
and it should be:
private function validate_csrf()
{
return $this->security->csrf_verify();
}
All you need to do is remove the : bool
Is it possible that you give that a try?
1 Like
Now it prints the next error regarding that file - Severity: 8192:
ERROR - 2025-01-05 13:25:21 --> Could not find the language line ""
ERROR - 2025-01-05 13:25:21 --> Could not find the language line ""
ERROR - 2025-01-05 13:25:24 --> Could not find the language line ""
ERROR - 2025-01-05 13:25:24 --> Could not find the language line ""
ERROR - 2025-01-05 13:25:24 --> Could not find the language line "ip_lang.log_error_no_file"
ERROR - 2025-01-05 13:25:24 --> Could not find the language line "ip_lang.log_error_no_file"
ERROR - 2025-01-05 13:25:24 --> Severity: 8192 --> sprintf(): Passing null to parameter #1 ($format) of type string is deprecated /home/serverlab/public_html/racun/application/modules/upload/controllers/Upload.php 244
ERROR - 2025-01-05 13:25:24 -->
ERROR - 2025-01-05 13:25:24 --> Could not find the language line "ip_lang.error_no_file"
ERROR - 2025-01-05 13:25:24 --> Could not find the language line "ip_lang.error_no_file"
Btw what are those “Could not find the language line”? I am using Croatian, is the file missing some translations?
1 Like
I’ll get back to you on that one
log_message('error', sprintf(_trans($logKey), $dynamicValue));
That $langKey that it’s trying to pass isn’t there.
Try to do the following:
- Open
/application/modules/upload/controllers/Upload.php
en scroll to the respond_error
function
private function respond_error(int $httpCode, string $messageKey, string $logKey, string $dynamicValue = '')
{
$logKey = 'Language Key not found';
log_message('error', sprintf(_trans($logKey), $dynamicValue));
http_response_code($httpCode);
echo json_encode(['success' => false, 'message' => _trans($messageKey)]);
}
Btw what are those “Could not find the language line”? I am using Croatian, is the file missing some translations
There’s a difference between the English translations and the Croatian translations.
Those “” are language keys that are (I think) in the English file, but not in the Croatian file: https://crowdin.com/project/fusioninvoice/hr
If you log in to Crowdin, there might be a way you can translate those missing strings (I’m not sure if the English strings are there already)
If you’re on Windows, there’s a program called WinMerge
. You can compare the English file with the Croatian one.
If both files are sorted the same way you can easily see if some language keys are missing.
The English file has recently been sorted, so there might be a difference in the order of the language keys between English and Croatian
Can I fix that somehow? You mean $logKey not $langKey?
1 Like
I have added to that function
$logKey = 'Language Key not found';
and now it prints in the log
ERROR - 2025-01-07 13:26:16 --> Could not find the language line "Language Key not found"
ERROR - 2025-01-07 13:26:16 --> Could not find the language line "Language Key not found"
ERROR - 2025-01-07 13:26:16 --> Severity: 8192 --> sprintf(): Passing null to parameter #1 ($format) of type string is deprecated /home/serverlab/public_html/racun/application/modules/upload/controllers/Upload.php 245
ERROR - 2025-01-07 13:26:16 -->
ERROR - 2025-01-07 13:26:16 --> Could not find the language line "ip_lang.error_no_file"
ERROR - 2025-01-07 13:26:16 --> Could not find the language line "ip_lang.error_no_file"
1 Like
--> sprintf(): Passing null to parameter #1 ($format) of type string is deprecated /application/modules/upload/controllers/Upload.php 245
private function respond_error(int $httpCode, string $messageKey, string $logKey, string $dynamicValue = '')
{
$logKey = 'Language Key not found';
log_message('error', sprintf(_trans($logKey), $dynamicValue));
http_response_code($httpCode);
echo json_encode(['success' => false, 'message' => _trans($messageKey)]);
}
Whichever is passed to sprintf (the first parameter) is not allowed to be null
, that’s why we gave $logKey a value.
2 options:
- delete this line:
log_message('error', sprintf(_trans($logKey), $dynamicValue));
- change it to:
log_message('error', 'Language Key not found');
With that second option you eliminated the trouble with sprintf and $logKey not being present.
In the meantime try to match the english translation file, so you can add the translation strings
Btw the error was the same on english settting of site. Do you know which one I have to translate to croatian?
Also I have put this log_message('error', 'Language Key not found');
and there is no error in debug log but I still cannot upload. Its not crucial to me, I am just reporting the issue.
1 Like
I have freshly deployed installation with English and Uploads section is not working inside Invoice
1 Like