Problem/Motivation

When the last_access or access_count as set as part of the redirect object the values are overridden in presave. For example we're migrating redirects from D7 to D9 and all the old counts and last access values are lost.

Steps to reproduce

  1. Set the last_access or access_count values in the redirect entity prior to saving a new redirect
  2. Save the new redirect
  3. Values are overridden

Proposed resolution

Add a check if empty on those fields before setting defaults.

CommentFileSizeAuthor
#2 3205839-01-lastaccessempty.patch849 bytesminoroffense

Comments

minorOffense created an issue. See original summary.

minoroffense’s picture

Status: Active » Needs review
StatusFileSize
new849 bytes

Here's a patch that adds the check.

tonytheferg’s picture

+1 for this. The patch worked - Thanks!

On a side note is there a created timestamp in 7 to migrate?

Also, i noticed that when the last_access is 0, then i get this Wed, 12/31/1969 - 7:00pm as a date instead of never

sam152’s picture

Patch looks good, it is missing a test though. It would be pretty easy to add as a follow-up if anyone was interested: https://git.drupalcode.org/project/redirect_metrics/-/blob/8.x-1.x/tests...

sam152’s picture

  • Sam152 committed b4788d5 on 8.x-1.x authored by minorOffense
    Issue #3205839 by minorOffense, tonytheferg: Metrics overridden when...
sam152’s picture

Status: Needs review » Needs work

Needs work for the test.