Wrong revision number with versioning plugin

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
GHoSti
Regular
Posts: 12
Joined: Wed Dec 12, 2007 8:18 pm
Location: Büdelsdorf/Germany

Wrong revision number with versioning plugin

Post by GHoSti »

Hi!

I've installed the Versioning plugin some days ago after having ~60 entries and I had to edit some old entries after the install.

First I've saved the old again, 'cause it wasn't saved after installing the plugin.
Second I've edited the stuff I wanted to and saved.
This led me to correct numbers like:
Revision #2 on 15.10.2008 01:48 by GHoSt
Revision #1 on 15.10.2008 01:44 by GHoSt

That first change were only some typos. I've made another change at the same day in the evening and landed into this:
Revision #2 on 15.10.2008 01:48 by GHoSt
Revision #2 on 15.10.2008 22:47 by GHoSt
Revision #1 on 15.10.2008 01:44 by GHoSt

Shouldn't be the middle one above the first one and shouldn't it have #3?

I've thought I did something wrong, 'cause I've edited in the archive without clicking on the last revision first. So I've tried it with another entry and the result is likely the same.
Revision #2 on 13.10.2008 19:15 by GHoSt
Revision #2 on 14.10.2008 23:13 by GHoSt
Revision #1 on 13.10.2008 18:57 by GHoSt
Again a problem with date and number.

I don't know what the problem is, maybe it's me?!

/EDIT:
Found one I've edited four times now and this is how it looks like:
Revision #2 on 15.10.2008 19:49 by GHoSt
Revision #2 on 15.10.2008 23:39 by GHoSt
Revision #2 on 17.10.2008 14:22 by GHoSt
Revision #1 on 15.10.2008 19:48 by GHoSt
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I think this means that your autoincrement is not working.

If you can examine your database (perhaps with phpMyAdmin or something) and find the serendipity_versioning table, make sure the ID column is set to autoincrement and primary key.
Judebert
---
Website | Wishlist | PayPal
GHoSti
Regular
Posts: 12
Joined: Wed Dec 12, 2007 8:18 pm
Location: Büdelsdorf/Germany

Post by GHoSti »

It hadn't to do with increment of the ID, but it had to do with the version column. I've looked through the code and found the problem and a solution!

Find in serendipity_event_versioning.php

Code: Select all

GROUP BY v.entry_id, v.id, a.realname, v.version_date";
Replace with:

Code: Select all

GROUP BY v.entry_id, v.id, a.realname, v.version_date
ORDER BY v.version DESC";
It's working fine for me now and I've edited the wrong numbers to the correct ones with phpMyAdmin.
Now I've got this:
Revision #5 on 17.10.2008 15:30 by GHoSt
Revision #4 on 17.10.2008 14:22 by GHoSt
Revision #3 on 15.10.2008 23:39 by GHoSt
Revision #2 on 15.10.2008 19:49 by GHoSt
Revision #1 on 15.10.2008 19:48 by GHoSt
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Thanks a lot for the contribution, I added your patch to the repository!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
GHoSti
Regular
Posts: 12
Joined: Wed Dec 12, 2007 8:18 pm
Location: Büdelsdorf/Germany

Post by GHoSti »

You're always welcome! :)
GHoSti
Regular
Posts: 12
Joined: Wed Dec 12, 2007 8:18 pm
Location: Büdelsdorf/Germany

Post by GHoSti »

As I've installed the plugin after I've done some entries I've noticed an error at the very bottom of the page if no version info exists, due to the foreach stuff inside the code. I'm too lazy to edit nearly 60 entries now, but made a little change in the code. (yeah funny, I'm not too lazy for this :lol: )

So here's a quick&dirty nighthack from a lazy ghost ;)

Find in serendipity_event_versioning.php

Code: Select all

$msg = '<div class="serendipity_versioningInfo">' . VERSIONING_TITLE . ':<br />%s</div>';
Add BEFORE:

Code: Select all

if (!empty($versions[0])) {
Find:

Code: Select all

$html .= '</ul>';
Add AFTER:

Code: Select all

}
Maybe someone could use this, too :) As I've said it's quick&dirty. I've figured out that count($versions) is always 1, but if one or more version info/s exists for that entry $versions[0] is an array (so it's not empty). Maybe it's a strange solution... Guess I need some sleep now ;)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I used your patch in a slightly different way (that requirered no further indentation):

Code: Select all

                         $versions = &$this->getVersions($eventData[0]['id']);
-                        if (count($versions) < 1) {
+                        if (count($versions) < 1 || empty($versions[0])) {
                             return true;
                         }
Thanks a lot for your contributions!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
GHoSti
Regular
Posts: 12
Joined: Wed Dec 12, 2007 8:18 pm
Location: Büdelsdorf/Germany

Post by GHoSti »

Ah thx! :) I'll change to your version!
Post Reply