cornernote / yii-audit-module

Track and display usage information including page requests, database field changes, php errors and yii logs.
https://cornernote.github.io/yii-audit-module
Other
22 stars 13 forks source link

Inconsistent behaviour between servers #34

Open zeb600 opened 8 years ago

zeb600 commented 8 years ago

Hi,

first of all thanks for a great module.

I do have two kind-of-issues - maybe questions - though: Right now I'm only using it to monitor and track changes to a couple of fields in one model. On my dev box everything works fine. After pushing to production there's the slight issue of "0" not being written to the audit_field table.

I.e.: On dev box:

old value new value
0 1
1 0

On prod box:

old value new value
1
1

There's literally nothing in where 0 should be. My "ingoreValues" array for that model is empty:

'AuditFieldBehavior' => array(
                'class' => 'audit.components.AuditFieldBehavior',
                'additionalAuditModels' => array(
                    //'Tipp' => 'fk_tipp_user_id',
                ),
                'ignoreFields' => array(
                    'insert' => array('tipp_last_updated, tipp_adm_visit_date'),
                    'update' => array('tipp_last_updated, tipp_adm_visit_date'),
                ),
                'enableAuditField' => true,
                'ignoreValues' => array(),
            ),

Any thoughts?

Also the audit_request_id never changes (always 0), is that expected behaviour?

I'm using the latest stable version (1.1.10) /w yii 1.1.15

cornernote commented 8 years ago

For your first issue (0 vs null), are the databases exactly the same? At a guess I would assume that your prod db allows null and the dev box is set to not null for the field in question.

For your second issue (audit_request_id=0), it would seem that for some reason the AuditRequest is not being written. This is very strange. I would recommend debugging the code that starts here, and reporting your findings: https://github.com/cornernote/yii-audit-module/blob/master/audit/components/AuditErrorHandler.php#L192

zeb600 commented 8 years ago

Thanks for your quick reply.

First issue: That's what I thought at first, but the DBs are the same. Both allow NULL.

EDIT AH I found something:

changing

'ignoreValues' => array(),

to

'ignoreValues' => array('ohwelljustignoreme'),

seems to fix it, 0 is now written correctly to the prod DB. Somehow the empty ignoreValue array didn't overwrite the default

public $ignoreValues = array('0', '0.0', '0.00', '0.000', '0.0000', '0.00000', '0.000000', '0000-00-00', '0000-00-00 00:00:00');

in AuditFieldBehavior.php? Don't really see how that's possible - or could be different depending on box.

Second issue: Will investigate.

cornernote commented 8 years ago

Yes, it should be assigning array() to AuditFieldBehavior->ignoreValues when the CActiveRecord attaches the behaviors here: https://github.com/yiisoft/yii/blob/1.1.17/framework/YiiBase.php#L220

Very strange that this functionality differs on a different operating environment.

Can you list the OS and PHP versions in your dev/prod boxes?