Page 1 of 1

Wrong revision number with versioning plugin

Posted: Fri Oct 17, 2008 10:51 am
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

Posted: Fri Oct 17, 2008 3:30 pm
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.

Posted: Fri Oct 17, 2008 3:36 pm
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

Posted: Sat Oct 18, 2008 1:31 pm
by garvinhicking
Hi!

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

Regards,
Garvin

Posted: Sun Oct 19, 2008 12:44 am
by GHoSti
You're always welcome! :)

Posted: Sun Oct 19, 2008 5:57 am
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 ;)

Posted: Sun Oct 19, 2008 1:05 pm
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

Posted: Sun Oct 19, 2008 1:21 pm
by GHoSti
Ah thx! :) I'll change to your version!