Jump to content
teppo

Version Control

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.

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thumbs up for 3.x branch!

  • Like 3

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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 = "";

 

Share this post


Link to post
Share on other sites
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). 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
33 minutes ago, teppo said:

Also, if you do run into issues, please let me know so that I can take a closer look at them

Thanks, will do.

  • Like 3

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hello

This valuable module is not usable here (with multi language setup?).

The input fields simply disappear after trying to restore.

See this short screencast please:

http://theowp.bplaced.net/upload/v2.html

ProcessWire 3.0.98 and VersionControl Branch 2.0 of today.

Thank you.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
×
×
  • Create New...