Help - Search - Members - Calendar
Full Version: MTEntryModifiedDate and MTEntryDate the same?
Movable Type Community Forum > Other Product Discussion > Bugs and Odd Behavior
jasonheyd
i'm using MT 2.661 and i can't seem to get MTEntryModifiedDate working. regardless of whether i've updated a particular entry, the MTEntryModifiedDate is always the same as MTEntryDate.

has anyone run into (and hopefully resolved) this?
girlie
Hmmm. Mine returns the same date too - although the database shows the correct modification date. huh.gif
jasonheyd
QUOTE (girlie @ Feb 22 2004, 02:53 AM)
Hmmm. Mine returns the same date too - although the database shows the correct modification date.  huh.gif

well, at least i'm not alone. smile.gif

not sure of proper "protocol" .. is this something that i should file as a bug somewhere?
LisaJill
In lieu of this you could use the plugin LastModified which I use as well. I never really looked at the new inbuilt tag because it doesn't have the functionality of the plugin. Mostly, that is, it does not have a leeway. I have a 15 minute leeway on mine and that is just brilliant. =)

hth
girlie
Jason, I'll just move the post to the Bug Reports forum.
atlantis
I'm noticing the same problem. Does anyone know where in the source code this can be fixed?
GrandfatherTrout
::bump::

Does anybody have any advice on this? I'd rather just patch the code than install a plug-in to work around it, but I guess I'll use the plug-in if I must.
jasonheyd
QUOTE (GrandfatherTrout @ Mar 13 2004, 01:28 PM)
::bump::

Does anybody have any advice on this? I'd rather just patch the code than install a plug-in to work around it, but I guess I'll use the plug-in if I must.

i just used the plugin.
atlantis
I am trying to look through the code to find our where MT reads the information from the database and then creates the static HTML file. Does anyone know the file which performs this? I'm sure the modified_on date and time bug is there.
TweezerMan
The problem is in lib/MT/Template/Context.pm. Here is why I think MTEntryModifiedDate does not work:

When an MTEntries tag is processed, MT stores the modified_on date within the context of the entry.

(Line 690 in Context.pm)
CODE
   for my $e (@entries) {
       local $ctx->{__stash}{entry} = $e;
       local $ctx->{current_timestamp} = $e->created_on;
       local $ctx->{modification_timestamp} = $e->modified_on;

This is the code that specifically handles MTEntryModifiedDate tags (starting at line 782 in Context.pm):
CODE
sub _hdlr_entry_mod_date {
   my $args = $_[1];
   $args->{ts} = $args->{modification_timestamp};
   _hdlr_date($_[0], $args);
}

What this code is supposed to do is read the entry modified date from the entry, store it as a 'ts' (timestamp) argument in the argument list, then pass the entry context and the argument list (including the new 'ts' argument) to the code that handles MT's date tags.

Line 784 fails to correctly read the entry modified date:
CODE
   $args->{ts} = $args->{modification_timestamp};

...because it is trying to read the entry modified date from the list of arguments ($args), instead obtaining it from the entry context where it was stored (which can be accessed via $_[0]).

In MT's date handler code (line 1068 in Context.pm):
CODE
sub _hdlr_date {
   my $args = $_[1];
   my $ts = $args->{ts} || $_[0]->{current_timestamp};

...MT then picks up the created_on date instead (3rd line above), because the MTEntryModifiedDate code failed to properly read the modified_on date (the 'ts' argument here will be empty/undefined). Note that MT picks up the created_on date here from $_[0] (the entry context), not $args (the argument list).

How to fix:

Change line 784 in Context.pm:
CODE
   $args->{ts} = $args->{modification_timestamp};

...to the following, making it read the modified_on date from the entry context:
CODE
   $args->{ts} = $_[0]->{modification_timestamp};

Save the modified Context.pm, upload to the server in ASCII mode, and the MTEntryModifiedDate tag should now function correctly. (You'll need to rebuild your templates to see the new code take effect.)
cynics
read from the bug listing that this has been fixed in 3.0.

however, i'm running 3.0D but my entries modified info still shows the same as the creation date even though my database shows the correct time.

anything i should look out for?

for exampe this post's last modified date on should show 17 may 2004 instead of aug 25 2003.

thanks
shelley
The line of code has definitely been changed in 3.0 (though it's at line 848 now):

CODE
   $args->{ts} = $_[0]->{modification_timestamp};


Does it look that way in your copy of Context.pm on the server?

Edit: Very weird. I just tested it on 3.0D and it gives the same date still.

Well, it works halfway haha! See second entry on this page - works there, but not on the Individual Entry Archive.

I'll update our internal bug report after I test it in some more archives.
shelley
QUOTE
lib/MT.pm, after line 495, add

        $ctx->{modification_timestamp} = $entry->modified_on;

(individual entries don't get their context set up in Context.pm, they get it there).


Thanks to philor who responded to the bug report.
cynics
thank you. that change made the difference.
atlantis
In version 2.661, you would add it directly after line 319 of MT.pm.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.