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: Duplicate Matrix rows

Status Resolved
Add-on / Version Publisher 1.0.15
Severity Critical
EE Version 2.7.2

JohnDWells

Dec 04, 2013

Hi Brian,

I’ve got Publisher set up for a dual language site, and as my client is editing content, he’s finding that on occasion Matrix is generating duplicate rows. I’ll try my best to explain:

For starters, I have Persistent Matrix turned “off”.  Second, these Matrix fields are configured to have a min and max of only 1 row.  (Use case is an optional Call To Action which sits on the sidebar - there should be only one).

The workflow looks like this:

- Client is editing in the default language (Portuguese), happily editing a way creating default content. Saves his work.
- Client switches to the English language view, sees all of the default Portuguese content in his fields. He diligently goes through, translating content across the entry. Saves his work.
- When he returns to the default language, instead of 1 Matrix row, this field now has 2.  The first row is his default language version of the field contents; the second row is the English version.

At least as far as I can tell, this is not affecting other Matrix fields that I have set up without min/max restrictions. So I’m hoping that’s a clue.  Let me know what else I can provide to track this down.

Cheers,
John

p.s. this is a testing domain, I can tell the client to stay out if you’d like to have a nose under the hood.

#1

BoldMinded (Brian)

I’m unable to replicate this locally. I’m about to release 1.1 that has some Matrix fixes, maybe it’ll fix itself when you upgrade?

#2

JohnDWells

Hi Brian,

Admittedly this is an intermittent occurence - by the client’s reports it isn’t happening every time just sometimes. I’ve asked him for a more detailed sequence of events but you know how hard it is to get something like that out of a client!

I’ll keep testing while we await the 1.1 release.

Cheers, John

#3

Brian Litzinger

Just pushed 1.1 if you want to try it. One thing to ask him is what is the view status and save status set to when this happens.

#4

JohnDWells

Hi Brian,

I’m afraid Publisher 1.1 hasn’t solved this duplicate Matrix row issue.

I should specify that the duplicated rows is only on the default language - it essentially shows the default & 2nd language translations for the single Matrix row that has been created.

Could there be something corrupt in my Field definitions, anywhere I should be looking to track this down?

If you have those CP access details I provided and log in, here’s a direct link to editing one entry which has duplicate rows:

http://cristalinolodge.onedarnleyroad.com/one/admin.php?S=0&D=cp&C=content_publish&M=entry_form&channel_id=1&entry_id=13&parent_id=1&lang_id=2&publisher_status=undefined

On the Publish tab, to the bottom is the “Call to Action” Matrix fieldtype. It’s been configured to only have a min and max of 1 row; you can see however that right now, 2 rows appear when viewing the default (Portuguese) language. The first row is the Portuguese version of the row; the second row is actually the first row of the 2nd language. Hard to explain, but should be evident if you take a look.

Note that we aren’t using the “workflow” portion of Publisher, only the translations.

Cheers, John

#5

BoldMinded (Brian)

I’m going to have to login to the FTP later tonight and check it out, I still can’t reproduce this locally.

#6

Brian Litzinger

John, I logged in and took a look. I deleted the extra row, then resaved the entry in English and Portuguese about 10 times and couldn’t replicate it.

#7

Brian Litzinger

One thing to notice is you have publisher_status=undefined in that URL, which is very odd.

#8

JohnDWells

Hi Brian,

Thanks for taking a look. Unfortunately I was just able to reproduce it a few times, though I’m still nailing down a repeatable sequence of steps. I’ll let you know once I have that for you.

Three things while I notice them:

1 - the publisher_status=undefined is what I get whenever switching language views on the Publish screen. What should that status value be?

2 - When the duplication occurs, I’m always editing the non-default language, but when I hit ‘Publish’, it’s the default language that comes back. For saves that do not cause duplication, I’m brought back to the language I was editing.

3 - This is happening with a Matrix field that does not have a min/max value set, which negates that earlier theory.

Cheers, John

#9

BoldMinded (Brian)

What other add-ons do you have installed? publisher_status should be set to open or draft.

I didn’t think the min/max value had anything to do with it, thats purely a JS limitation that is in place.

I did look at the DB and it looks like its adding a duplicate row, not displaying the original row as an extra one, which leads me to believe that if publisher_status is undefined that it could be messing up the insert query?

#10

JohnDWells

Hi Brian,

I’ve just been able to replicate this issue repeatedly - boiled down to simply going to the non-default language, clicking “Publish”, and clicking “Publish” a second time. At that point, it brings back the default language, with the non-default language’s Matrix rows appended to the default language Matrix rows.

What can I do to debug the whole publisher_status thing? Should I be looking on the JS side, or PHP side?

Here’s a complete list of add-ons installed:

Assets Backup Pro(ish) CE Image CE String Custom Asset Fields devot:ee Monitor EE Debug Toolbar Freebie Freeform HTTP Header JSON encode tag Low Reorder Low Variables Matrix Minimee Mo’ Variables NSM Publish Hints Publisher QuickSave reCAPTCHA SEO Lite Single Entry Snippet Sync Structure Subscriber Custom System Messages Wygwam

#11

JohnDWells

Hi Brian,

I don’t see “Published” as one of my available Statuses (under Admin > Channel Administration > Statuses). Should there be one?

Cheers, John

#12

BoldMinded (Brian)

Yes you should. “Published” is the same as open, the language file just changes its label. You should also have a Draft status too.

#13

JohnDWells

Hi Brian,

OK, well I do have open & draft statuses - odd though that when I visit the Statuses page, the Publisher language file doesn’t manage to override the label of “open” - it still says “Open”. But when I’m actually editing entries, the Status dropdown is correctly labeled.

That said, I’m not sure how much it’s having an effect - in your sessions_start() you eventually make sure that the ee()->publisher_lib->status is one of either constants PUBLISHER_STATUS_OPEN or PUBLISHER_STATUS_DRAFT, setting it to the default status if not.

I’m surprised you weren’t able to replicate this - I can consistently do it by:

  1. Go to edit an existing entry (this is a Structure page)
  2. Switch to the non-default language (in this case English)
  3. Clicking the “Publish” button
  4. When the page reloads, click “Publish” again

The result is I’m shown the default language, and all Matrix rows from the non-default language appear after the default language ones. If I delete these extra rows, they do NOT get deleted from the non-default language.

…. OK so here’s some progress: under Publisher’s settings I had “Force default language” set to “Yes”. When I set it to “No”, the duplication seems to be avoided. Does that help isolate the issue?

Cheers, John

#14

JohnDWells

Hi Brian,

I’ve been debugging the publisher_status=undefined, and I think I’ve tracked it down. I’m only using Publisher as a multilanguage module, so I have set “Disable Drafts” to “Yes”. As a result in my publish screens I only have the language switcher select dropdown, and not the “View” or “Save As” selects, in my DOM.

In publisher.js at line 492 the start of function change(), is the following line:

var publisher_view_status = $view.val();

Where $view is set to:

$form.find('.publisher-view-status');

However this element doesn’t exist, hence why val() evaluates to undefined. If I change line 492 to read:

var publisher_view_status = $view.val() || $save.val();

This finds the correct publisher view status setting. That at least seems to resolve the URL switching - even though like I said, it appears as though due to your checks in sessions_start(), it doesn’t seem to have ill effects on things under the hood.

And I tracked down why Publisher isn’t translating the “Open” status label to “Publish” over on Admin > Channel Administration > Statuses. It’s because the Freeform module defines a language key/val of ‘open’ => ‘Open’, and this language file ends up getting loaded after Publisher’s.

Cheers, John

#15

BoldMinded (Brian)

Looking at the page source I can see the publisher_view_status hidden field.

So with that JS change does it fix the issue for you?

#16

JohnDWells

Hi Brian,

The JS change fixes the publisher_status=undefined appearing in my URL when switching languages; but the duplicate Matrix rows appears tied to the “Force default language” setting being set to “Yes”.

It seems to me the “Force default language” set as “Yes” is buggy - basically I can switch to the non-default language to edit an entry, and it returns me to that same language upon save. But if I then make more changes and save again, it saves all of those changes onto the default language.

I suppose the setting should behave one of two ways:

1 - upon save, it returns me back to the default language immediately 2 - upon save, it keeps me at the language I’m editing, and allows me to make continual edits & saves. But then if I leave that area of the CP, it forgets I was working on a particular language.

But for now I’m happy keeping it set to “No” moving forward - I hadn’t set it to “Yes” for any strong reason in particular, it’s just what I’d chosen as I ran through the settings.

Cheers, John

#17

BoldMinded (Brian)

There are to force default language settings, one for CP and one for the FE. Which one did you have set to yes?

#18

JohnDWells

Ah, sorry I wasn’t clear about that - the CP one.

#19

BoldMinded (Brian)

Ok, that makes sense. If that is set it shouldn’t allow anyone to change languages in the drop down menu, so that is the part that is broken.

#20

JohnDWells

Right, ok that does make sense.

Thanks Brian.

#21

BoldMinded (Brian)

Upon looking at this again I’m not sure how to solve this easily. It would mean touching quite a few files to make sure the Matrix rows get updated correctly. Also, I’m asking myself why I added this setting to the CP anyway… I kind of want to just get rid of it as it seems confusing and I honestly can’t remember what reason I had to add the option 😊

#22

BoldMinded (Brian)

Yea, I’m just going to remove this option. The amount of complexity it added far out weighs the benefits of the setting.

#23

JohnDWells

Hi Brian,

I only re-opened this ticket to say Merry Christmas and thanks for everything! Our Publisher-powered site should launch in the New Year, I’ll be sure to let you know. It has made us a very happy client.

Happy Holidays, John

Login to reply