Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Assets Field disappears in Draft View

Status Resolved
Add-on / Version Publisher Lite 2.2.1
Severity
EE Version 3.5.2

Geoff Baumbach

Feb 20, 2017

Here is a video of the assets field emptying within a grid field if I go to view a draft on a published entry with no current draft. If I were to save this as a draft and then view, the field is populated. If no draft of an item exists, viewing a draft empties out the field.

Dropbox link to video:
https://www.dropbox.com/s/z697oaax9srzno4/ee-publisher-video.mov?dl=0

 

 

#1

BoldMinded (Brian)

You neglected to mention last time that it was inside of a Grid field… which makes a big difference 😊

I’ll try to replicate it tonight and look into it again. Thanks for the video.

#2

Geoff Baumbach

No prob, you’re welcome to use the credentials from my other ticket to access my CP if need be. The grid always complicates things–but such a powerful field.

#3

BoldMinded (Brian)

Geoff, it looks like this has been the behavior going back to Publisher for EE2. I’m uncertain how far back this goes, but I suspect for quite some time. After looking into it I’m not sure this is a quick fix sort of issue.

#4

Geoff Baumbach

Anyway to disable or hide drafts if there is no draft?

I don’t anticipate many clients to click the View > Draft button if they don’t have a draft. However, if I have the default set to view drafts so they can make incremental edits, upon publishing if someone goes to edit/view that entry in the future, I just assume it show the published entry until they make an edit and then it cycles back to viewing drafts until they publish it again. That’s how Better Workflow did it and it seemed to make sense. This way you technically avoid this bug altogether. Maybe that is easier to do, I don’t know.

Hope that makes sense 😊

#5

BoldMinded (Brian)

Yes, if you have a draft and save it 5 times as a draft, then publish it, the published version also becomes the draft. So until the draft is edited next time the two states are identical.

It appears Assets inside of Grid wasn’t a common thing in EE2, so it has worked the way it currently works for some time. Matrix on the other hand worked the way you’re expecting, so I’ll need to spend some time to update the Grid code so it behaves the same way. It could be a few days or a week or two b/c this is the tricky part of the module… getting two 3rd party add-ons with data in separate tables to play nice.

#6

Geoff Baumbach

Gotcha, no problem. Keep me posted!

#7

BoldMinded (Brian)

Update: I’ve started working on this and hope to have something done in the next week or so.

#8

Geoff Baumbach

Excellent, thanks for the update! Much appreciated.

#9

BoldMinded (Brian)

Comment has been marked private.

#10

Geoff Baumbach

Booyeah baby, we are in business. Assets fields do not empty out for me in the grid. Nice work!

#11

BoldMinded (Brian)

Sweet, good to hear 😊

#12

Geoff Baumbach

Hey Brian,

Got an error when adding a new assets field to a Channel Field Group. I attached an image. It looks like it saved the field in my group, but just a heads up.

Here is a link to the screenshot: https://www.dropbox.com/s/oznwia0y8j2ykbd/Screen Shot 2017-03-02 at 6.32.35 PM.png?dl=0

#13

BoldMinded (Brian)

Did you click the upgrade button for Publisher?

#14

Geoff Baumbach

I did, yes. I’m also on the latest EE 3.5.3. If you need any other details, let me know. I get the error when editing an assets field in the field group too.

#15

Geoff Baumbach

Actually looks like it happens anytime I add a new channel field or edit one. It saves the field information regardless of the error for both adding and editing.

#16

BoldMinded (Brian)

Comment has been marked private.

#17

Geoff Baumbach

OK updated the files, modified the SQL table and set back version, then ran EE’s Add-on update. The first time I edit any Channel Field, I get this SQL error. Whatever I update does save, and future updates to that specific channel field give me no problems. However any existing field will always spit back this error when editing.

New channel fields don’t give me any errors.

This is the error I receive when modifying an existing field for the first time as described above: https://www.dropbox.com/s/vnskyzpl3adjyb3/FireShot Capture 10 - Exception - ExpressionEngine_ - http___gcv.server297.com_admin.php.png?dl=0

#18

BoldMinded (Brian)

Something is wrong with your environment. I’ve added and edited multiple fields with no errors. The demo site has the latest build, see if it errors for you there. http://demo.boldminded.com/

Do you have a after_channel_field_update and after_channel_field_save row in your exp_extensions table?

#19

Geoff Baumbach

I do have both of those rows. In your demo I don’t think I have access to Channel Fields–I don’t see it in the dev menu.

#20

BoldMinded (Brian)

Try again you should have access to them now.

#21

Geoff Baumbach

Yeah those ones work.

On my end once I edit a field and save it (and get that error), future edits to that field go through fine so not a huge deal. Seems to correct itself so I imagine something goofy with my situation. New channel fields I add don’t spit any errors so perhaps this is isolated to me (hopefully).

I can keep trucking along so no worries.

#22

Geoff Baumbach

Hey Brian–not sure if this is due to any corruption on my end or an actual bug. Maybe you can test and verify for me.

I am providing a video link to illustrate the bug I am seeing below.

When modifying an assets field in an entry, everything works as intended now in the backend. However the front end of the site seems to be reading from drafts on the asset field, not the published entry.

So if I add an image, publish it, all good. If I go back and delete the image and save that entry as a draft, the front end registers that image as being removed, even though it still exists in published form. I only removed it from drafts. This video should illustrate the bug for you:

https://www.dropbox.com/s/416272kwoxs9nri/screen-recording.mov?dl=0

I’m just performing a simple {if masthead} conditional to see if an image exists…I also tried {if masthead == “”}. Both conditions output false even though the published entry has the image still assigned.

Thanks!

#23

BoldMinded (Brian)

I was not able to actually replicate that. Its saving drafts and published versions of the Assets field fine for me. What Publisher settings have you changed? The only thing that would come to mind that could change this behavior is Persistent Entries, which I tested with it enabled and disabled. Or maybe the Sync Drafts setting, which 99% of the time should always be set to Yes. Did you set it to No?

#24

Geoff Baumbach

Persistence settings all set to YES, and sync set to YES. The only settings I messed with are Default View settings and Default Save settings. Both are currently set to “OPEN.”

Not sure if maybe I need to completely remove the plugin and reinstall?

#25

BoldMinded (Brian)

If you try an un-install and re-install just make sure you back up your db first incase you want to go back to the current state.

#26

Geoff Baumbach

Hmm, I uninstalled the plugin, and then re-installed. Cleared the cookies but still receiving this error trying to access the control panel. Any ideas?

https://www.dropbox.com/s/dlvnzb0iwx8bv9q/Screen Shot 2017-03-05 at 10.30.15 AM.png?dl=0

#27

Geoff Baumbach

OK I was able to fix that.

I disabled the plugin via table setting in db, then uninstalled the plugin, removed the session cookies referencing Publisher, then reinstalled.

On new install (presumably?), same bug persists with the asset field being emptied out on the published entry when I remove the asset from a draft.

#28

BoldMinded (Brian)

Have you tried replicating it on demo.boldminded.com?

Would you be able to provide coverage and ftp access to a dev server for me to debug on? If so edit the ticket and use the provided fields for the credentials.

#29

Geoff Baumbach

I took a look real quick at your demo, but I don’t think I have access to create an assets field anywhere (I checked your cards, but those seem to reference a URL for the image, not an assets field).

I’ll give you access to my site and you can take a look–give me a few minutes. Thx, -G

#30

Geoff Baumbach

OK you should have access and credentials now, let me know if you run into any issues accessing. I made a backup image of the server so have at it haha.

#31

BoldMinded (Brian)

I still can’t replicate it locally, but see it happening on your site, but not sure what the difference is. You should be able to create fields on the demo site now. Would you be able to replicate it there, and note what settings you might have changed.

#32

Geoff Baumbach

I need Assets installed on your demo site to test–I don’t see it in the list of fieldtypes when trying to add a new fieldtype to your pages channel. You may need to setup a file upload directory in assets for me too if one isn’t already setup.

#33

BoldMinded (Brian)

I just installed Assets, should be good to go.

#34

Geoff Baumbach

Thanks–I’ll need access to the pages/index template in order to add my new Assets field. I also have no way to publish anything, I can only save as drafts. That may not matter with this bug, but for sure need access to the template or if you want to add the field real quick for me. The short name is {imagetest}

#35

BoldMinded (Brian)

The demo member group has access to edit the templates and save and edit entries.

#36

Geoff Baumbach

I just noticed this is not limited to assets fields..it’s with any field. My live site pulls data from the draft.

It seems to occur when the URL contains a segment (so secondary pages).

The homepage is a great example because it can be viewed 2 ways:

http://gcv.server297.com/

http://gcv.server297.com/home

the /home version is showing my draft (the 2nd banner has the title “Draft test”) and a different image for the first banner…while viewing it without /home…it shows my published page which has the original image, and original title on the 2nd banner.

So…not really sure why the URL would impact that but both of these links draw from the exact same entry.

#37

BoldMinded (Brian)

It looks like your home page entries tag is using cache, have you tried it without cache?

This doesn’t sound like anything I’ve seen happen before (in Publisher in EE2 or EE3)… e.g. statuses changing based on url segments. If this is happening to any field it sounds more like a template and/or content issue.

#38

Geoff Baumbach

It appears to be the cache causing the issue. I use the cache tag on the entries:

{exp:channel:entries channel=”home” disable=”categories|category_fields|member_data|pagination” cache=”yes” refresh=”14440”}

If I remove the [ cache=”yes” refresh=”14440” ] part, it no longer loads the draft. So that is good…however, we definitely want to leverage cache haha. Thoughts?

#39

BoldMinded (Brian)

So it sounds like an issue with the cache not getting cleared when saving an entry. If you’re using file cache can you find the file, then save the entry, and see if the file still exists or if its gone? And if it exists if its the same or if anything changed?

#40

Geoff Baumbach

I think I figured it out…

The caching appears to work–I think the problem is the combination of cache tag and the publish preview page. If I disable publish previews and save drafts like normal, no problems with caching enabled. It appears the popup preview when I save a draft, caches that page, and then the live site pulls from it. The reason the base URL isn’t impacted is because the URL in the preview uses the structure page “home” in the URL:

http://gcv.server297.com/home?publisher_status=draft&publisher_key=b7kIxqnh

So this would explain why http://gcv.server297.com isn’t impacted because the cache is for /home

Not sure if there is way to automatically strip out caching on that preview functionality page–but I’m pretty confident that is culprit 😊

#41

BoldMinded (Brian)

Try this. In ext.publisher.php go to line 420 and you should see $this->cache->delete(); After that line add this

ee()->functions->clear_caching('all');

See if that resolves the issue.

#42

Geoff Baumbach

No luck. Same issue persists. Also on the backend if I delete the draft and then click view draft (or in my case I have it by default to view draft status), it seems to still hold on to the draft.

With the new line of code in…if I publish the entry, the assets fields once again empty out in draft view. I removed that new line of code and it corrected that old error.

#43

Geoff Baumbach

Welp I take that second part back, those asset fields still seem to empty out even with that line of code removed. Not sure if you modified anything when accessing the site, but thought that had been fixed. You’re welcome to play around with it in the back end on my server.

#44

BoldMinded (Brian)

I didn’t change anything when I logged in. I just looked at the CP.

It still sounds like its an issue with your cache=“yes” and refresh=“14440” parameters though, right?

What you could do in your config is create a global variable to turn caching on or off based on the status. Take a look at https://gist.github.com/litzinger/7811577#file-config-master-php-L196

The simplest way to do it would be to add this to your config.php file: https://gist.github.com/litzinger/2518815ef7d70518253d843ffa1f748a

With that it will add your cache params normally, but for drafts it won’t, so it shouldn’t try to load the contents from cache.

#45

BoldMinded (Brian)

protip You can do the same thing for your disable param: https://gist.github.com/litzinger/7811577#file-config-master-php-L177-L179

Then your entries tag would look like this

{exp:channel:entries channel=“home” {global:disable_strict} {global:tag_cache}}

Then you don’t have to type out that whole disable param and cache params on all your tags.

#46

Geoff Baumbach

Interesting, I’ll take a look and see if that works. I’ll report back, thx!

#47

Geoff Baumbach

OK sweet–we fixed that cache issue so the front end no longer displays my drafts!

For some reason, those asset fields are emptying on the Draft view once I publish an entry again. And when I delete a draft, the draft view keeps the draft I deleted.

I think the build from comment #9 fixed that issue, but then I started getting errors which I think was specific to my situation and it corrected itself over time I think…

16 was another build as a follow up to my errors, which is what I’m currently running. Not sure what the difference between those two builds are–should I revert back to build #9 and see if that fixes things?

#48

BoldMinded (Brian)

Don’t revert to an older build. Did you try the new build in a clean EE environment to replicate the issue?

#49

Geoff Baumbach

I haven’t tried on a complete clean install of EE. My client is in the process of loading initial content in so unfortunately I need to proceed with what I have to keep the project on schedule and not hold them up. I don’t think I have access to publish on your demo site to see if I can replicate.

#50

BoldMinded (Brian)

I re-enabled the demo user to be able to create fields. It could already create and edit entries and templates.

#51

Geoff Baumbach

Could you grant me access to channels again so I can put an assets field on to one of the channels? That way I can see if I can replicate the asset field emptying out on a blank draft. Thx!

#52

BoldMinded (Brian)

That’s what I already did. You should be able to create fields.

#53

Geoff Baumbach

I think your site may have reset itself–I was able to last week, but I’m in the system now and I cannot access Channels in the dev menu, and the assets field I put into the pages channel is gone. I can access Templates and Add-ons, but just need to test out the assets field emptying out. -G

#54

BoldMinded (Brian)

Try again, it shouldn’t have reset itself since yesterday, but I think the perms are fixed now.

Login to reply