tractorcow-farm / silverstripe-fluent

Multi-language translate module for Silverstripe, without having to manage separate site trees.
BSD 3-Clause "New" or "Revised" License
91 stars 109 forks source link

Data objects not publishing #853

Open jesscostello opened 3 months ago

jesscostello commented 3 months ago

Module version(s) affected

7.1.1

Description

I have a dataobject which has the versioned extension (versioning only, no staging) and FluentVersionedExtension applied. No matter how I create/save the object it always seems to remain in draft format. I have simplified down my dataobject for the purposes of replication and to rule out anything from the class itself but am still seeing issues. Not sure if this is definitely a bug or if I'm missing something

How to reproduce

Using Silverstripe 5.2

PHP Class

```php 'Varchar(255)', ]; private static $has_one = [ 'PhoneLink' => Link::class, ]; private static $many_many = [ 'Images' => Image::class, ]; private static $owns = [ 'Images', 'PhoneLink', ]; private static $cascade_duplicates = [ 'Images', 'PhoneLink', ]; private static $cascade_deletes = [ 'Images', 'PhoneLink', ]; public function getCMSFields() { $this->beforeUpdateCMSFields( function ($fields) { $fields->removeByName(['Images']); $uploadField = UploadField::create('Images') ->setAllowedExtensions(['png', 'jpg', 'jpeg']) ->setIsMultiUpload(true); $fields->addFieldToTab( 'Root.Main', $uploadField, ); } ); return parent::getCMSFields(); } } ```

YML Config

File 1 ```yml --- Name: app-config --- TPNT\Website\Models\TestObject: extensions: - SilverStripe\Versioned\Versioned.versioned ``` File 2 ```yml --- Name: fluent-config After: - '#app-config' - '#versionedfiles' --- TractorCow\Fluent\Model\Locale: default_records: en: Title: English Locale: en_NZ URLSegment: en IsGlobalDefault: 1 mi: Title: Te Reo Māori Locale: mi_NZ URLSegment: mi TractorCow\Fluent\Extension\FluentExtension: frontend_publish_required: any SilverStripe\LinkField\Models\Link: extensions: - TractorCow\Fluent\Extension\FluentVersionedExtension Name\Website\Models\TestObject: extensions: - TractorCow\Fluent\Extension\FluentVersionedExtension ```

When first creating an object there is only a create button, clicking this results in the following Screenshot 2024-05-24 at 8 57 56 AM

It also does not publish the image as I would expect (Image relationship appears in $owns).

I then have the localisation menu and click 'save and publish (all locales)'. This does publish the image but not the object

Screenshot 2024-05-24 at 8 58 24 AM

Clicking 'publish in this locale' in the localisation table also does not publish and leaves the record in draft state.

Any help would be much appreciated!

jesscostello commented 2 months ago

@tractorcow just wondering if there's any chance you could offer some assistance with my issue please?

tractorcow commented 2 months ago

I've not used versioned without stages for a long time, and I haven't actually used ss 5.x in any case. Is there something changed in ss5 with regards to versioning without stages? Sorry I've been out of the Silverstripe game for a bit too long.

I don't know if versioning without stages is a working use case in fluent. FluentVersionedExtension is designed around the standard publishing model, which is draft + live stages. If you see at https://github.com/tractorcow-farm/silverstripe-fluent/blob/7/src/Extension/FluentVersionedExtension.php#L132-L137 you can see that the live / draft stages are assumed as fixed in here.

My suggestion is to keep the Versioned extension, but try removing FluentVersionedExtension (using FluentExtension on its own), due to the lack of stages. It may be sufficient for your admin interface to work.

If you run into issues with this, is removing versioning from your record an option?

If I were to spend the time to fix this in fluent, I would look at FluentVersionedExtension and add some more intelligent logic for checking the list of active stages.