joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.76k stars 3.65k forks source link

"Save as Copy" creates article that is not visible in back-end #41354

Open eddiekonczal opened 1 year ago

eddiekonczal commented 1 year ago

Steps to reproduce the issue

In the Joomla! back end, edit an article, then click "Save as Copy."

Expected result

A copy of the article should be created that is visible in the Joomla! back end.

Actual result

A copy of the article is in fact created - but it is only visible if you access the database directly (e.g. through phpMyAdmin). The article is not accessible in the Joomla! back end. The new article can be seen in the front-end if there is a link to the article's category.

System information (as much as possible)

PHP Built On Linux 3.10.0-962.3.2.lve1.5.65.el6h.x86_64 #1 SMP Wed Jan 19 11:33:04 UTC 2022 x86_64 Database Type mysql Database Version 5.7.38-cll-lve Database Collation utf8mb4_general_ci Database Connection Collation utf8mb4_general_ci Database Connection Encryption None Database Server Supports Connection Encryption Yes PHP Version 8.0.29 Web Server Apache WebServer to PHP Interface cgi-fcgi Joomla! Version Joomla! 4.3.2 Stable [ Bora ] 30-May-2023 16:00 GMT User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Additional comments

Issue can usually be reproduced, but sometimes does not occur.

brianteeman commented 1 year ago

I am going to read your mind and say that this site is eityher one that has been upgraded from joomla3 unsuccessfuly or that you have copied articles directly from another site using the database. It is reproducible on articles that were created in this way but not reproducinle on any new articles created in joomla 4

Is that correct

eddiekonczal commented 1 year ago

The website has been upgraded from Joomla! 3 to Joomla! 4.

Articles are not being copied from another website; they are being copied within the website.

I have not been able to reproduce the error when creating copies of new articles created in Joomla! 4.

The error usually occurs - but does not always occur - with errors created before the website was upgraded from Joomla! 3.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41354.

brianteeman commented 1 year ago

So basicaly I have guessed correctly. The upgrade from 3 to 4 was not completed successfuly as it should have created a record for each article in the #_workflow_associations table. (even if you are not using workflows it needs a record in that table). Newly created articles in j4 have that record created automatically which is why you didnt have a problem with those.

The sql query below should create the missing records for you.

replace #_ with your own db prefix

INSERT INTO #__workflow_associations (item_id, stage_id, extension) 
SELECT c.id as item_id, '1', 'com_content.article' FROM #__content AS c 
WHERE NOT EXISTS (SELECT wa.item_id FROM #__workflow_associations AS wa WHERE wa.item_id = c.id);

After running that query it should tell you that a cumber of records were inserted.

If it says 0 records were inserted then its a different problem

eddiekonczal commented 1 year ago

Thanks for the suggestion.

I ran the following query (our prefix is j17_):

INSERT INTO j17_workflow_associations (item_id, stage_id, extension) 
SELECT c.id as item_id, '1', 'com_content.article' FROM j17_content AS c 
WHERE NOT EXISTS (SELECT wa.item_id FROM j17_workflow_associations AS wa WHERE wa.item_id = c.id);

But it had no effect:

0 rows inserted. ( Query took 0.0080 sec )

I also checked j17_workflow_associations and records do exist corresponding to the article IDs that I am unable to copy.

-Eddie


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41354.

brianteeman commented 1 year ago

ok - seemed a good guess as its a fairly common error

rbuelund commented 1 year ago

I have got the exact same problem. When saving with save as copy the new article is created in com_content, but not shown in backend. The article that I copy from HAS got an entry in the #__workflow_associations table.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41354.