8000 Fix - BC Hook constants, Model ArrayAccess by abbadon1334 · Pull Request #31 · atk4/audit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix - BC Hook constants, Model ArrayAccess #31

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

Merged
merged 28 commits into from
Jun 18, 2020

Conversation

abbadon1334
Copy link
Collaborator

@codecov
Copy link
codecov bot commented Jun 11, 2020

Codecov Report

Merging #31 into develop will increase coverage by 18.15%.
The diff coverage is 87.80%.

Impacted file tree graph

@@              Coverage Diff               @@
##             develop      #31       +/-   ##
==============================================
+ Coverage      62.27%   80.43%   +18.15%     
- Complexity       115      131       +16     
==============================================
  Files              5        5               
  Lines            281      322       +41     
==============================================
+ Hits             175      259       +84     
+ Misses           106       63       -43     
Impacted Files Coverage Δ Complexity Δ
src/view/Lister.php 27.45% <0.00%> (+27.45%) 22.00 <0.00> (ø)
src/model/AuditLog.php 88.40% <88.63%> (+20.32%) 21.00 <0.00> (+9.00)
src/Controller.php 91.11% <89.61%> (+2.29%) 81.00 <16.00> (+7.00)
src/view/CommentForm.php 80.00% <0.00%> (+80.00%) 2.00% <0.00%> (ø%)
src/view/History.php 100.00% <0.00%> (+100.00%) 5.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8133bd...c1c4abf. Read the comment docs.

@@ -278,12 +278,12 @@ public function getDiffs(Model $m)
}

// don't log DSQL expressions because they can be recursive and we can't store them
if ($original instanceof Expression || $m[$key] instanceof Expression) {
if ($original instanceof Expression || $m->getField($key) instanceof Expression) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just replace with what i think is correct, i look further into it to be sure is not a useless code

Copy link
Collaborator
@georgehristov georgehristov Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be $m->get($key) instanceof Expression here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks for the type of Field, we already have because is get few lines before using

$f = $m->hasField($key);

so i take directly $f

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgehristov is right that original $m[$key] === $m->get($key)

$f = $m->hasField($key); will be deprecated no later than today :D in atk4/data#616 (more precisely it will be still valid, but it will return strictly bool only)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getField() strictly returnds instance of Field. Check if Expression is some extended class of Field.

Value on the other side can be anything - because of load/save typecasting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was introduced to avoid Expression to be included in audit.
this is the PR : b1e1af4#diff-3840aae95575d417f513143775141e9dR133

I clear don't remember if the value data was stored differently at that time, but now i think we have to get the model field type and compare to the Field_SQL_Expression

I'm on removing even hasFieldwhen is used to get the field and not to check for boolean presence

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically what this if should do is it should not audit any Expression field because expressions are not raw data - they are build based on raw data and are read-only. So no point of auditing them and also in some cases they can be recursive and then ... everything goes to hell if we try to audit them :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgehristov is right that original $m[$key] === $m->get($key)

Expr. field will usually have field of type Field\Callback, but simply update the code test $m->get($key) instanceof Expre... like before, that makes sense.

Copy link
Collaborator Author
@abbadon1334 abbadon1334 Jun 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition removed. Expression field has $f->read_only === true

Copy link
Member
@mvorisek mvorisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, otherwise LGTM

@abbadon1334 abbadon1334 force-pushed the fix/Hook-Constants-ArrayAccess branch from 8dc8a17 to 82c1a36 Compare June 11, 2020 17:57
@abbadon1334
Copy link
Collaborator Author

@mvorisek i think there are problems in atk4/data develop i recheck tests later

@abbadon1334 abbadon1334 force-pushed the fix/Hook-Constants-ArrayAccess branch from 22e5b3b to a4703b4 Compare June 13, 2020 13:44
@abbadon1334 abbadon1334 marked this pull request as draft June 13, 2020 13:59
@abbadon1334
Copy link
Collaborator Author
  • Removed duplicates
  • non scalar values are serialized to be stored
  • non scalar values are unserialized to be retrived
  • add Test for undo, undo_create, undo_update, undo_delete, which was only partially tested
  • add inclusion test for demos, to trigger an error

@abbadon1334 abbadon1334 marked this pull request as ready for review June 13, 2020 14:23
@DarkSide666
Copy link
Member

I will finalize this now.

If some additional tweaks will be needed then we can do this in new PR.
In this one I will add newest phpunit, check tests etc. Goal - to be compatible with 2.1.
Other issues can be fixed separately afterwards.

@DarkSide666 DarkSide666 self-assigned this Jun 18, 2020
Copy link
Member
@DarkSide666 DarkSide666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy as it is now. Thanks @abbadon1334 and @mvorisek for your good work here!

If you find some more issues with this then please start new branch because this one is already much to big to normally review :)

Merging.

@DarkSide666 DarkSide666 merged commit 2590909 into develop Jun 18, 2020
@DarkSide666 DarkSide666 deleted the fix/Hook-Constants-ArrayAccess branch June 18, 2020 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0