-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File Versioning #121
Comments
Sorry, I cannot find such configuration, please tell me.
Do you tell about files which are stored on disc and not in DB, if yes then where do you plan to store the old versions, also on the disc, i.e. after each update we should create an additional file with some suffix of the modification date? |
@yurabakhtin Here the configuration part: No, the Idea is this: With versioning, each |
@luke- Ok, thanks for the info, however in your examples the same class so I think you mean this:
Right? |
@yurabakhtin Yes! |
When do you plan to merge the PR #131? Because if I will add the new context menu item "Versions" in old version then it will be not easy to merge. |
@yurabakhtin Ok great looks good so far! |
What I should still do:
|
@yurabakhtin Looks already pretty good! Probably a table in the version dialog would be nicer. Columns could be: It would be important that other modules like OnlyOffice or other file editors could work with versioning. Maybe we should provide here some API? |
Currently the code model If some another model from external module will want to have same multiple File records then code should be changed from the external module side, if we tell about OnlyOffice then I guess here https://github.com/ONLYOFFICE/onlyoffice-humhub/blob/master/models/CreateDocument.php#L91 we should allow to find existing File instead of current Then I don't understand why we need to implement some API if each external module has an access to core DB tables. I.e. if we need some UI to work with file versions we can get the data directly from DB without API requests. |
@yurabakhtin "Don't show the context menu item "Versions" if the file has only single version," , sorry for the late feedback, but if you use a table view on this lightbox, we should always show this menu entry. Otherwise it may confuses users. |
@yurabakhtin Regarding the API: Here is the code line where in the OO Module a change of the document is saved. How would the code have to look like to support versioning in CFiles? Maybe a extra API is too much here, but the code should be as simple as possible. Ok, interesting point that versioning could theoretically be possible for files from normal posts as well. However, this is currently not absolutely necessary. |
@yurabakhtin Here a quick idea/thought: The HumHub Core File Model has the attributes Example of core Current situation:
Idea:
What do you think? |
Sorry, not clear your idea why we should display the "Versions" table when CFile has only single version, please see how it will looks: I.e. there is no the action link to switch to revision because no reason to switch to the same version, so do you still think we should display the context menu item "Versions" and then the table with single row like on my screenshot above? |
@yurabakhtin Thank you for the screenshot. Yes, I would nevertheless show it, even if only one version is available. That way the user sees that there is a versioning at all. |
Looks good. But I would prefer that the latest version always appears at the top. If, for example, there are 5 pages with 10 versions each, and you roll back to page 3 of one version, it becomes confusing. |
From the "Current situation:" table we can know what base/core Files are linked with CFile model, but how can we know this from the "Idea:" table? Currently we select versions by |
@yurabakhtin The main point of my idea is that, theoretically, with the Example:
Advantages:
Disadvantages:
|
Here is an example code of how the code on the core side might look like: Example how to rollback to a version: /** @var humhub\modules\file\models\File $file */
/** @var humhub\modules\file\models\File $previousFileVersion */
$previousFileVersion = $file->getFileVersionsQuery()->limit(1)->one();
$file->replaceWithFile($previousFileVersion); |
@luke- Thank you for the details, yes now I got it, so if we have these data:
after uploading new CFile the data will be updated to this:
on switching the CFile#1 to the version File#2 the data will be like this:
I will implement core helpers to work with such versions algorithm. |
@yurabakhtin Yes, exactly! |
@luke- I have implemented the file versioning from core side in PR humhub/humhub#5293. You didn't answer yet on the question:
but I think we need this because it looks like this: |
@luke- Please note the PR has errors in tests https://github.com/humhub/cfiles/runs/3634226999?check_suite_focus=true#step:25:31 because the branch |
@yurabakhtin Awesome & Thanks, please see my PR reviews. Looks quite nice thanks! Can you please also prepare a draft PR which provides versioning here. https://github.com/ONLYOFFICE/onlyoffice-humhub |
@luke- Could you please provide me with some test server so I will check how the module store files? I guess on edit a file it is stored into the same Also currently we don't have a context menu like on cfiles browser, should we add a button to view versions here? : |
In my example PR I would also assume that each file modification (CFiles ReUpload, OnlyOffice Edit, Text Editor Edit), In your core PR/apprach (if I understood it correctly) the "replaceWithFile" step happens automatically when An important question to clarify would be whether we want to add Versioning support for all Contents (Posts, Tasks, Wiki) Here I assumed the second, that we offer Versioning Support optionally for modules and an interface class must be implemented first to enable it. In this case, the Alternatively, we can enable versioning for all contents (not only CFiles) directly. I think it would be good to maybe start with just the What do you think? |
In my core PR https://github.com/humhub/humhub/pull/5293/files the "replaceWithFile" step happens automatically on the event If before new uploading a file with same name we have a DB like this:
then after uploading new CFile the data will be updated to this:
I.e. firstly we find ID of the previous latest version, in our case ID=3, then update the record (id=3) But I am bit confused here myself because by this logic on attaching a File to a Post all previous attached Files of the Post should become old versions of the latest uploaded, that is wrong indeed because Post should have multiple attached files, and we should not replace previous attached Files. However currently my code doesn't overwrite previous attached files, i.e. on each attaching it works like before: After debug the code I found answer why all previous attached Files stay as separate file of a Post instead of expecting converting to old versions as it works with CFiles: I.e. my current code doesn't break files of the Post model, but of course we cannot be sure that it will works with all other model, because if some model will set
As I wrote above we should implement some interface as you suggested |
@yurabakhtin Ok, then let's proceed with interface and "replaceWithFile" method. But we should always (even for modules with non versioning support) use the "replaceWithFile" method to update file contents. I like the approach that files can't be changed anymore. This opens us good chances in things like caching, CDN, Trashcan... |
The Versioning UI stuff can be moved from CFiles to Core, with a later version e.g. HumHub v1.11 or v1.12 |
@luke- Please review new changes in core PR - humhub/humhub@194a6c6, and in cfiles module - 8126753. |
@luke- I don't find any new comments in the PRs what should be changed there. |
@yurabakhtin For the core PR there is a comment here: humhub/humhub#5293 (review) We may also need a strategy to clean up older versions. I think for example the OnlyOffice module does an AutoSave every X minutes. Here some ideas for options:
We could implement a version cleanup like that later, but we should think about it. |
I answered humhub/humhub#5293 (comment). |
@yurabakhtin Looks and works great! Can you implement that someone with |
Commit c8312c5, please note the core fix humhub/humhub#5311 is required to make the deleting of versions working. |
@yurabakhtin Ok great, is there anything else to do with the issue? I have written a comment at the PR. But otherwise we can merge it? Or is something still missing? |
@luke- I found only the permissions don't work related to your written comment, please read my answer #138 (comment). |
@yurabakhtin Yes, please rewrite that, so |
@yurabakhtin Thanks! Then the PR should be ready for the time being, right? |
@luke- Yes, right, we can merge it. |
Currently, when a file with the same file name is uploaded, it is overwritten or a new file is created depending on the configuration.
An edited file (e.g. via OnlyOffice) is always overwritten.
In future, a new version of the file should always be created in these cases.
In the context menu, there should be a link "Versions", which opens a modal that allows access and restore of older versions.
A
CFile
(module) consequently has severalFile
(file) models.Also related to: #122 (comment)
The text was updated successfully, but these errors were encountered: