pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
307 stars 447 forks source link

Adding a new article to a published issue does not specifically set sequence #8998

Open jnugent opened 1 year ago

jnugent commented 1 year ago

Describe the bug When a submission is first created, the publication record associated with it gets a seq value of 0, which makes sense since it isn't in an issue yet. When the submission is ultimately assigned to an issue and the issue is published, these 0 seq values are not re-sequenced into incrementing integers. This results in the articles within a section randomly ordering the articles and this order will change from page load to page load. The only way around this is to specify a sort order within the issue's table of contents. That's probably fine. However, when new articles are added to an issue with an already set sort order, the 0 seq values cause these articles to appear at the top of the section, and they will flip randomly around each time the page is loaded.

The Quick Submit plugin will increment the seq value on submissions as it builds an issue so perhaps there is some code here that can be reused. At the least, maybe the query builder for fetching submissions can also sort according to submission_id so at least there is a unique value in case the sequence values are the same.

Our clients who use this workaround for continuous publication have also asked us to examine sorting by the date_published field within the publication object, but since this field does not contain minutes and seconds it results in the same behaviour when more than one article is published on the same day.

To Reproduce Steps to reproduce the behavior:

  1. Create several submissions
  2. Add these submissions to an issue without sorting the table of contents
  3. publish the issue, and reload the TOC.
  4. Specifically sort the issue, the TOC is now locked.
  5. Add several more articles to the issue without sorting them.
  6. Load the TOC, they should flip around.

What application are you using? OJS 3.3.0.14

Additional information Issue TOC ordering and sorting is related to this other issue: https://github.com/pkp/pkp-lib/issues/8564

ewhanson commented 8 months ago

@jnugent, is this issue still present when you stop after step 3 above, i.e. when you keep the unsorted table of contents but do not add any more items?

jnugent commented 8 months ago

@ewhanson Yes, it is. I just tested in a 3.3.0.16 install and if I add two articles to an issue and schedule for publication, they both go in with seq of 0 in the publications table. If I then publish this issue, I end up with a TOC that has two articles that flip back and forth on each reload (or nearly every reload).

The database records look like:

Screenshot from 2024-02-22 15-15-37

and the two TOCs look like:

Screenshot from 2024-02-22 15-16-32

or Screenshot from 2024-02-22 15-16-44

ewhanson commented 8 months ago

@jnugent, thanks for the details. This came up with some of the Coalition Publica work as well so I'm going to dive into it. I haven't done any testing yet, but do you know if this is also a problem in 3.4 and later? (I'm assuming if it wasn't fixed in 3.3, it's still present, but want to know what I'm getting myself into).

jnugent commented 8 months ago

Hi @ewhanson I just tested this in our 3.4 testdrive. If I schedule a submission for publication in an empty issue, it gets a seq of 0. If add a second article to that same issue, it gets a seq of 1. So this might not be a problem in 3.4. I think @jonasraoni may have worked on this.

aupress commented 6 months ago

Hi @jnugent and @jonasraoni. Is there any update on the status of this bug fix? Will it be released with 3.4 update? Any information is greatly appreciated. Thank you.

Sergiy

PS I see OJS 3.4 was released on June 9, 2023 and OJS 3.4.05 on February 23, 2024. But I cannot tell from release notes if this bug was addressed. Thanks.

ewhanson commented 5 months ago

@aupress I'm currently investigating the status of this. Will provide an update here once a fix has been made.

@jnugent, I'm testing it locally on stable-3_4_0 and still seeing all publications assigned to a seq of 0. Do you know at which point in the publication process the second article was getting a seq of 1?

jnugent commented 5 months ago

@ewhanson you're right, it's not incrementing. I am not sure what I was looking at before.

  1. The record in the publications table is created when the submission is created. At that time the seq is 0.
  2. When you assign a submission to an issue, the issueId setting_name record in publication_settings is created, but the seq in the publications table is not updated.

Upon specifically ordering articles in the Issue table of contents, the seq values get set correctly.

ewhanson commented 5 months ago

Thanks @jnugent, that's helpful (and glad I'm not going crazy). I'm working on a fix to set the seq when it's assigned to an issue and will see how that behaves.