Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date format #27

Closed
SirJohn2024 opened this issue Nov 18, 2013 · 4 comments
Closed

Date format #27

SirJohn2024 opened this issue Nov 18, 2013 · 4 comments
Assignees

Comments

@SirJohn2024
Copy link

Hi there,

I'm facing an error so big that probably I'm doing something wrong.
I'm using Acra 4.5 to report crashes, with default configuration:

@ReportsCrashes(
formKey = "",
formUri = "http://..../report/report.php",
httpMethod = org.acra.sender.HttpSender.Method.PUT,
reportType = org.acra.sender.HttpSender.Type.JSON,
formUriBasicAuthLogin = "....",
formUriBasicAuthPassword = "....."

)

but when report get inserted to DB, I have this error:

Incorrect datetime value: '2013-11-18T17:04:17.000+01:00' for column 'user_app_start_date' at row 1

From what I read, all Acra dates are RFC 3339 formatted and MySql cannot handle this format.

Looking in the mablab.log file I get these values:

[user_crash_date] => 2013-11-18 17:04:27
[user_app_start_date] => 2013-11-18T17:04:17.000+01:00

user_crash_date seems somehow converted, the other one no...

My question is: what I'm missing?

Hope you can help

Best regards
Sergio

@ghost ghost assigned Medialoha Nov 18, 2013
@Medialoha
Copy link
Owner

Hello,

I'm not sure you miss something, I will check asap.

@Medialoha
Copy link
Owner

The rfc is converted before being inserted into db. The value _2013-11-18T17:04:17.000+01:00_ is already converted. I need the original value.

Edit the file report/report.php, line 90, change like this :

    Debug::logi("Seems to be a valid request... Try to decode JSON and save to DB.", 'REPORT');

    $json = json_decode($data, true);

    Debug::Logd($json['USER_CRASH_DATE'], 'CHECK_DATE');

    // open db connection
    DBHelper::open();

    $values = ReportHelper::buildMySQLValuesArr($json);

    Debug::Logd($json['USER_CRASH_DATE'], 'CHECK_DATE');

    $result = DBHelper::insertReport($values);

This will log the user crash date, before and after convertion.

@SirJohn2024
Copy link
Author

I've looked at the code and found the problem, it lies here:

public static function buildMySQLValuesArr($json) {
$json['USER_CRASH_DATE'] = self::convertRFCDateToMySQLTimestamp($json['USER_CRASH_DATE']);

$values = array();
    ....

only USER_CRASH_DATE is converted, adding

$json['USER_APP_START_DATE'] = self::convertRFCDateToMySQLTimestamp($json['USER_APP_START_DATE']);

solves the problem, I can now write successfully to DB.

Thanks for your prompt response

Regards
Sergio

@Medialoha
Copy link
Owner

Thanks !

Script updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants