Jump to content

Version Control


teppo

Recommended Posts

Hi Teppo

Tested this on latest ProcessWire (ver 3.0.62). Seems to work very well, except Image/File fields. In both of those it is possible to recover removed files, but when doing so, it loses the current files. These screenshots probably shows it best:

First I have 2 images:

Sieppaa1.PNG

Then we remove the other one:

Sieppaa2.PNG

Now we only have the city photo there:

Sieppaa3.PNG

Then I can go back time and find the Desert also:

Sieppaa4.PNG

This preview works pretty nicely (although file names are hashed). But then after saving the page disaster happens:

Sieppaa5.PNG

Desert is saved, but the city has gone 0 bytes.

Any idea what might be causing this? I thought it might be image field related, but the very same happens with file fields also.

Link to comment
Share on other sites

Hi.

It seems that there is an issue when the Version Control is set to track input changes on a repeater matrix field. I get the following error when trying to revert to an older entry.

Error: 
Call to a member function getInputfield() on a non-object (line 480 of /Users/vayurobins/Sites/headhunterland.dev/site/assets/cache/FileCompiler/site/modules/VersionControl/ProcessVersionControl.module)

Is this module compatible with Profields Repeater Matrix module?

Link to comment
Share on other sites

@Vayu Robins, to be honest I wouldn't be surprised if it wasn't. Repeaters, I believe, are somewhat supported, but Repeater Matrix is a lot more complex, at least as a concept.

I'll look into this as soon as possible.

@apeisa, I'll look into that image issue too. Unless that's really easy to fix, it might be time to release a 3.x branch of this module though. Could probably solve a bunch of things more cleanly now.

API level tests still look good, so I'm thinking that this file issue might have something to do either with the "recent" UI updates, or perhaps the temp file thing..

  • Like 7
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Hi @teppo

Finding out that there is also few more bugs with PW3:

  • revisions don't work - it always shows the latest version (the sliding preview or /setup/version-control/preview/?pages_id=1328&revision=511 urls). I did debug this quite a bit and this SQL generated by PageSnapshot::snapshot always returns Empty set (although there should be data and database seems to been populated fine):
  • SELECT t1.pages_id, t1.id AS revision, t2.fields_id, t2.property, t2.data
        FROM (
            SELECT MAX(t1.id) id, t1.pages_id, t2.fields_id
            FROM version_control__revisions AS t1, version_control__data AS t2
            WHERE t1.id = 513 AND t1.pages_id IN (1328) AND t1.timestamp <= FROM_UNIXTIME(1511771437) AND t2.revisions_id = t1.id
            GROUP BY t1.pages_id, t2.fields_id, t2.property
        ) AS t1
        INNER JOIN version_control__data AS t2
        ON t2.revisions_id = t1.id AND t2.fields_id = t1.fields_id
        GROUP BY t1.pages_id, t2.fields_id, t2.property

    In history tab clicking pagination also changes the tab (minor annoyance)

 

I also updated this to PW3 (well, added namespace to each .module file and changed PDO references to \PDO, but that didn't had any affect to these bugs (didn't test the earlier image test though). Here are those attached if you are interested (didn't test that well and took about a minute or so).

ProcessVersionControl.zip

  • Like 1
Link to comment
Share on other sites

Quick update: there's now a 2.0 branch and 2.0 milestone for this module at GitHub. For the time being the 2.0 branch is identical with master branch, but it's a start. I'm going to get another project I've been working on out there today, and after that I should have some time to work on VersionControl 2.0 :)

  • Like 9
Link to comment
Share on other sites

  • 1 month later...

Version 2.0.0 of Version Control was just pushed to the 2.0 branch at GitHub.

While I'd be happy to hear how it works for you, please note that this should be considered a beta release: so far it seems to be working with basic text fields and file/image fields, but honestly I've not tested it much yet (got the file field part working literally minutes ago). Note also that this version bumps the required ProcessWire version to 3.0.62 – the current master/stable version.

Technically this release should work in 3.0.16 or 3.0.18 as well (the versions that introduced major changes to the image inputfield), but I don't plan to test this module in anything older than the master branch.

  • Like 1
Link to comment
Share on other sites

On 29/11/2017 at 10:15 PM, apeisa said:
  • revisions don't work - it always shows the latest version (the sliding preview or /setup/version-control/preview/?pages_id=1328&revision=511 urls)
  • In history tab clicking pagination also changes the tab (minor annoyance)

So far I've been unable to reproduce either one of these. Perhaps it's something that I fixed by accident, or perhaps it's something about my setup, but revisions seem to work fine and history tab pagination returns me to the history tab. I'll keep an eye out for these, though :)

Adding #VersionControlHistory to the pagination probably wouldn't hurt, so I'll try that in the next update.

Link to comment
Share on other sites

  • 4 weeks later...

Version 2.1.0 of VersionControl was just pushed to the 2.0 branch at GitHub.

Note that this update changes the field-level UI quite a bit (see screenshot below). Personally I like this UI better anyway, but the main reason for the change was that it would've been a major pain to get the old UI to work with both the (current) default admin theme and AdminThemeUikit – let alone any third party admin themes.

5a7751064985f_ScreenShot2018-02-04at19_36_50.thumb.png.13ede43a99022dcc178110ed3e9f66f2.png

The colour theme is currently hardcoded, so it doesn't adapt to whatever changes you might've made to your admin theme. It's also exactly the same for both built-in admin themes. I could make some parts configurable at some point, but for the time being this is better than nothing.

Next up: more testing. I'm pretty sure that there are a few bugs here and there that I've managed to miss, and I'd like the core features of this module to be as solid as possible. I'm also contemplating giving the History tab a major facelift, but that's not exactly the first item on my list right now :)

  • Like 12
Link to comment
Share on other sites

I have tried to use front-end editing using the <edit> tags. It seems, that I always get the history tab below the fields I am editing even though those fields are not under version control. Is there any option not to show the history tab with front-end editing modals?

  • Like 2
Link to comment
Share on other sites

Thanks Teppo, looks great!

The bugs I reported earlier were not fixed on these updates. That make me look more careful the server setup and the issue was that PW timezone was not the same that server was using - that caused history tab to work inproperly. Interesting thing is that the field specific compare/restore did work nicely even on bad configuration.

  • Like 2
Link to comment
Share on other sites

19 hours ago, apeisa said:

[...] the issue was that PW timezone was not the same that server was using - that caused history tab to work inproperly. Interesting thing is that the field specific compare/restore did work nicely even on bad configuration.

Thanks for letting me know. That makes sense: the page level snapshot feature makes use of timestamps, so timezone settings being off could make it misbehave. Field level features work just based on revision IDs, so this issue wouldn't affect them :)

I should probably add a note about this somewhere..

  • Like 1
Link to comment
Share on other sites

On 05/02/2018 at 8:45 PM, lpa said:

I have tried to use front-end editing using the <edit> tags. It seems, that I always get the history tab below the fields I am editing even though those fields are not under version control. Is there any option not to show the history tab with front-end editing modals?

Just pushed a fix for this issue to the 2.0 branch :)

  • Like 2
Link to comment
Share on other sites

I get a notice here, maybe that is interesting....

PHP Notice: Trying to get property of non-object in site/modules/VersionControl/ProcessVersionControl.module:660

if ($diff && wire('fields')->get($field)->type instanceof FieldtypeFile) $diff = "";

 

Link to comment
Share on other sites

  • 2 weeks later...
On 1/8/2018 at 8:08 AM, teppo said:

please note that this should be considered a beta release: so far it seems to be working with basic text fields and file/image fields, but honestly I've not tested it much yet

Hi @teppo,

Just wondering about updating to the v2 branch on a project I have under development. In the quote above, do you mean that the range of fieldtypes supported on the v2 branch is currently narrower than the v1 branch (only text and file/image fields)? Or do you expect that all the fieldtypes supported in v1 (integer, datetime, etc) will also work in v2 branch but just that you haven't tested them yet?

If it's the latter I will probably go ahead and upgrade (unless you think that wouldn't be wise to do yet). 

Link to comment
Share on other sites

@Robin S: it's the latter case. I had originally some weird issues with image fields and such, but got those fixed at the last minute, so was a bit worried that there might be other issues I just hadn't noticed yet.

Also the UI of the 2.0 branch could be a bit unstable: I've been moving things around, trying to figure out what works best, and I'm still considering rebuilding the History tab from the scratch.

That being said, if you're using PW 3.x, I'd definitely recommend going with the 2.0 branch. Current master branch works fine with PW <= 2.7, but not so much on 2.8 or 3.x. Also, if you do run into issues, please let me know so that I can take a closer look at them :)

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...

Hi @teppo,

There is a little UI issue with accessing version history for checkbox fields. When a checkbox field doesn't use a separate label (and it doesn't by default), the icon for accessing the history UI doesn't appear. And if the checkbox field is rendered collapsed by default the icon does appear but disappears when the field is opened.

versioncontrol.gif.de3dd0498db85df878c737bee24929f9.gif

Link to comment
Share on other sites

Another minor UI thing: the new UI can look a bit funny with AdminThemeDefault and AdminThemeReno because opening the history doesn't trigger the core column sizing JS, so the height of fields in the same row isn't updated to match. It's not a big deal, and the issue doesn't occur for AdminThemeUikit so maybe not worth doing anything about.

versioncontrol2.gif.1d9bf0b4abe5dd54d869d5083a61e1a3.gif

If there is a column to the right of an open history container then the history gets overlapped by 1 pixel on the right edge. Again, not a big deal, but maybe these things could be avoided by using absolute positioning for the history container so it appears in a layer over the Page Edit interface and doesn't expand the inputfield column.

Using the core panel UI could be a nice alternative too, but I don't know how easy it is to inject HTML directly into this. I think it's only set up to handle iframes (which if so is a bit of a shame because it reduces the range of things the panel can be used for).

  • Like 1
Link to comment
Share on other sites

Thanks @Robin S, I'll take a look at these ASAP.

Part of the reason the new UI works as it does (in context, not overlay) is so that it could play nicely with some admin theme quirks and differences. Another reason is that overlay UI's are a bit of a problem from usability point of view, so I'd rather steer away from them. Anyway, I'll see what I can do about these.

The part about checkbox is a bit of a surprise to me. This also means that other icons, such as the default "collapse" icon, disappear when the field gets expanded, right? Seems weird to me, but perhaps that's how it's supposed to work. Not sure how I managed to miss this earlier :)

  • Like 2
Link to comment
Share on other sites

@teppo, do you have any advice if I want to add support for fieldtypes beyond those in the core? Does the module have any hookable methods that allow for that?

For instance, I tested with FieldtypeMapMarker and the history and diff parts seemed to work okay but the restore action failed because the saved data needs to be converted into an object of the right class. It looks like the module saves the string value of a field - am I able to hook into the restore action to control how the string is restored back to the field value?

Link to comment
Share on other sites

  • 2 weeks later...

Hi @teppo,

The Version Control module is preventing the red asterisk from appearing in the header of required fields. The relevant admin CSS is:

.InputfieldStateRequired>.InputfieldHeader:first-child:after {
    content: ' *';
    color: #C00C19;
}

The addition of the field-revisions div interferes with this.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...