Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

I 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.

Status: Needs review » Needs work
Issue tags: -sprint, -Needs upgrade path, -Spark

The last submitted patch, change-tracking-menu-link.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review

change-tracking-menu-link.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +sprint, +Needs upgrade path, +Spark

The last submitted patch, change-tracking-menu-link.patch, failed testing.

Wim Leers’s picture

Issue tags: -sprint

We're not working on this right now.

Wim Leers’s picture

Status: Needs work » Needs review

change-tracking-menu-link.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, change-tracking-menu-link.patch, failed testing.

Wim Leers’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
3.42 KB
939 bytes
Wim Leers’s picture

Berdir’s picture

Repeating 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.

Wim Leers’s picture

FileSize
3.01 KB
839 bytes

#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.

amateescu’s picture

Yeah, 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?

Wim Leers’s picture

#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?

-   * The menu link modification timestamp.
+   * Flag that indicates that this link was generated during the update from Drupal 5.
Gábor Hojtsy’s picture

@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

      'updated' => array(
        'description' => 'Flag that indicates that this link was generated during the update from Drupal 5.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),

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.

Gábor Hojtsy’s picture

Re: 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.

Berdir’s picture

Status: Needs review » Needs work

The last submitted patch, 11: entitychangedinterface_menulink-2074203-10.patch, failed testing.

The last submitted patch, 11: entitychangedinterface_menulink-2074203-10.patch, failed testing.

Gábor Hojtsy’s picture

Component: menu_link.module » menu_link_content.module
Issue tags: -Needs upgrade path

This 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...

pwolanin’s picture

So, sounds liek this is only relevant for the content entities, not all menu links? The summary needs to be clarified

cilefen’s picture

Status: Needs work » Needs review
FileSize
1.79 KB

Patch for menu_link_content...

dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

The patch itself looks really nice!
Some kind of test coverage would be cool as well.

cilefen’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.04 KB
2.95 KB

I added some tests.

dawehner’s picture

  1. +++ b/core/modules/menu_link_content/src/Tests/LinksTest.php
    @@ -123,6 +123,27 @@ function assertMenuLinkParents($links, $expected_hierarchy) {
    +   *
    

    Let's adda a one line description.

  2. +++ b/core/modules/menu_link_content/src/Tests/LinksTest.php
    @@ -123,6 +123,27 @@ function assertMenuLinkParents($links, $expected_hierarchy) {
    +    );
    +    $link->setOptions($options);
    +    $link->save();
    +    // Make sure the changed timestamp is updated.
    +    $this->assertEqual($link->getChangedTime(), REQUEST_TIME, 'Changing a menu link sets "changed" timestamp.');
    

    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.

cilefen’s picture

I 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.

dawehner’s picture

Yeah 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.

Gábor Hojtsy’s picture

You can update the entity with the API and specify a changed time in the past. Then update on the UI and see it changed.

Wim Leers’s picture

Status: Needs review » Needs work

NW for #27.

Berdir’s picture

No, 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:

$entity->changed->value = REQUEST_TIME - 5;
$entity->save();
// assert for request time.

That should be proof enough that you are using the changed field type, which takes care of everything.

cilefen’s picture

Status: Needs work » Needs review
FileSize
570 bytes
3.04 KB
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

berdir, simple and beatiful!

This seems seems to cover now enough.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed a222458 on 8.0.x
    Issue #2074203 by cilefen, Wim Leers, Gábor Hojtsy: Add changed time...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.