Problem/Motivation
Menu links don't have changed time tracking. See various reasons why this is a problem at #2074191: [META] Add changed timestamp tracking to content entities.
Proposed resolution
Add change time tracking to menu links.
Remaining tasks
Needs upgrade path.
User interface changes
None.
API changes
Schema changed. New getChangedTime method added. This naming is already used on other entity types. See #2044583: Add EntityChangedInterface to allow entities with "changed" field to be properly cached for unification of this.
Related Issues
#2044583: Add EntityChangedInterface to allow entities with "changed" field to be properly cached
#2074191: [META] Add changed timestamp tracking to content entities
Comment | File | Size | Author |
---|---|---|---|
#30 | add_changed_time-2074203-30.patch | 3.04 KB | cilefen |
#30 | interdiff-25-30.txt | 570 bytes | cilefen |
#25 | add_changed_time-2074203-25.patch | 3 KB | cilefen |
#25 | interdiff-23-25.txt | 412 bytes | cilefen |
#23 | add_changed_time-2074203-23.patch | 2.95 KB | cilefen |
Comments
Comment #1
Gábor HojtsyI did not find where the menu links module is broken out of menu module, and if there is a schema update or creation happening. Needs the upgrade path adjusted.
Comment #3
Gábor Hojtsychange-tracking-menu-link.patch queued for re-testing.
Comment #5
Wim LeersWe're not working on this right now.
Comment #6
Wim Leerschange-tracking-menu-link.patch queued for re-testing.
Comment #8
Wim LeersComment #9
Wim LeersComment #10
BerdirRepeating the method definition in the menu link interface is not necessary.
Might make sense to wait with this until #1842858: [PP-1] Convert menu links to the new Entity Field API, also related is #2145103: Provide non-configurable field types for entity created, changed and timestamp fields, for all those issues.
Comment #11
Wim Leers#10: You're right, I should remove that (a remnant from the first patch). Fixed.
Since #1842858: [PP-1] Convert menu links to the new Entity Field API has been taking a long time already and it doesn't look like it'll be solved soon, I'd rather get this in now.
Thanks for linking to #2145103: Provide non-configurable field types for entity created, changed and timestamp fields, I did not yet know about that one. However, that too looks like something that will take quite a long time to materialize; this patch is simple and at least moves us forward :)
So AFAICT, there's no actual harm in moving forward with this patch as-is.
Comment #12
amateescu CreditAttribution: amateescu commentedYeah, I don't think it's fair to postpone this on the menu link conversion, that one is at least a couple of months away :(
And about the patch, how about retiring the 'updated' boolean which I'm pretty sure is not useful anymore (coming from D5), and rename it to changed?
Comment #13
Wim Leers#12: I'd be fine with that renaming, but unfortunately the
updated
DB schema field is actually being used in many places. So it seems its meaning has been changed or overloaded. It's used in:menu_link_delete_multiple()
MenuLinkAccessController::checkAccess()
MenuLinkStorageController::loadUpdatedCustomized()
So, I'd rather not include that in the scope here, because it feels out of scope and relatively dangerous to make such a change here. It also makes me wonder whether the change Gábor made in the original patch is even accurate?
Comment #14
Gábor Hojtsy@Wim Leers:
1. As for the doc change on timestamp vs. flag. I just copied over the doc from the DB field from
core/modules/menu_link/menu_link.install
A smallint can certainly not hold a timestamp, but I did not check how it was used.
2. We also discussed upgrade path in chat. I think we don't necessarily need to provide an update function, but it is helpful for the IMP effort to have one, so we don't need yet another issue to track this to be done in IMP :) Upgrade tests should definitely not be written anymore AFAIS.
Comment #15
Gábor HojtsyRe: The scope of this issue I don't see how updating the 'updated' usage relevant to this issue. I just scyned up the docs on the property, because that was in scope, since the docs lie that there is already a modification timestamp, and we are adding one more :D Since there is no modification timestamp, the docs need 'fixing'. I think copying the doc from the other place where its defined constitutes fixing. If it is incorrect, at least its incorrect the same way and another issue can clean it up :)
Fixing how the update flag is used is not in scope for this issue.
Comment #16
Berdir11: entitychangedinterface_menulink-2074203-10.patch queued for re-testing.
Comment #19
Gábor HojtsyThis is unfortunately very outdated now. It should be redone based on other similar issues, eg. #2074255: Add changed time tracking to users being the most recent. It also has view integration, etc. The current menu content entity is at http://cgit.drupalcode.org/drupal/tree/core/modules/menu_link_content/sr...
Comment #20
pwolanin CreditAttribution: pwolanin commentedSo, sounds liek this is only relevant for the content entities, not all menu links? The summary needs to be clarified
Comment #21
cilefen CreditAttribution: cilefen commentedPatch for menu_link_content...
Comment #22
dawehnerThe patch itself looks really nice!
Some kind of test coverage would be cool as well.
Comment #23
cilefen CreditAttribution: cilefen commentedI added some tests.
Comment #24
dawehnerLet's adda a one line description.
Mh in order to know that it is updated maybe change the REQUEST_TIME constant, save and ensure it is the new value. Here you just check that the changed item didn't changed at all.
Comment #25
cilefen CreditAttribution: cilefen commentedI agree the test could be better but how can you change a constant? I tried putting a sleep() between the asserts but the changed time always equals REQUEST_TIME.
What else could we try? One idea would be to make a database query to set the changed value to zeroes, then edit the link and check the value.
Comment #26
dawehnerYeah that is sad. Beside of using runkit or something like that, there is no way to change the value of a define statement.
You could though test it using the REST interface or just the normal UI.
Comment #27
Gábor HojtsyYou can update the entity with the API and specify a changed time in the past. Then update on the UI and see it changed.
Comment #28
Wim LeersNW for #27.
Comment #29
BerdirNo, it is not possible to change changed with the API, that happens in preSave() of the field.
The only thing you could do is to change it directly in the database, then load and re-save, so it is set to REQUEST_TIME.
However, I would just test this:
That should be proof enough that you are using the changed field type, which takes care of everything.
Comment #30
cilefen CreditAttribution: cilefen commentedComment #31
dawehnerberdir, simple and beatiful!
This seems seems to cover now enough.
Comment #32
webchickCommitted and pushed to 8.x. Thanks!