Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Clone - Categories are not cloned (none selected) for newly cloned products #2714

Closed
Noodleyman opened this issue Dec 8, 2020 · 11 comments

Comments

@Noodleyman
Copy link

as per title, in 6.4.2 all cloned products have no categories assigned, making them invalid until manually assigned.

@bhsmither
Copy link
Contributor

Did this just start happening at CC642 for you? Will you confirm that there was not this issue for CC641?

I find no difference in code that would affect cloning.

@Noodleyman
Copy link
Author

Noodleyman commented Dec 8, 2020 via email

@bhsmither
Copy link
Contributor

I cannot duplicate. The cloned product has the same categories assigned as the source product as seen in CubeCart_category_index and CubeCart_inventory.

@Noodleyman
Copy link
Author

Noodleyman commented Dec 8, 2020 via email

@bhsmither
Copy link
Contributor

Yes and no. I pepper tracer code at points of interest. But the actual core code is not changed.

@rbosma
Copy link

rbosma commented Dec 9, 2020

On upgrade (6.4.2.) no problem here.

@Noodleyman
Copy link
Author

I just installed CubeCart again, new install. it's reproducible.

image

CubeCart_category_index isn't populated for the cloned product.

image

@bhsmither
Copy link
Contributor

bhsmither commented Dec 9, 2020

The code to clone is stupid-simple. The primary category is always cloned.

If you have debug enabled, are there queries shown on the POST portion of the debug area that relate to INSERTing new records in CubeCart_inventory, CubeCart_category_index, etc?

The difference I see is that my settings will have CubeCart auto-redirect to the cloned product.

@bhsmither
Copy link
Contributor

There is, however, a remote possibility that, if the database is not also "fresh", there could be some problem.

@bhsmither
Copy link
Contributor

bhsmither commented Dec 10, 2020

Found it (highly probable). And there are likely numerous other situations where this scenario will get triggered.

A key component is that the admin doing the tasks must have logged in for less than four times.

In DB->_clearCacheNotice(), if the admin_data['logins'] <= 3, then a message is triggered.

Following the path of code execution, ACP->adminLog() will insert a new record. We arrive at this point from numerous paths.

Relevant to #2670 and especially #2690 as an example, in products.index.inc.php, near line 529, there is code fetching a value from DB->insertid().

But as has been learned before, there could be other database work between the DB=>insert() statement above it and fetching the insertid().

In this issue's case, the $product_id is probably the value of the last inserted id of Cubecart_admin_log, a value which is likely not product_id = '1' of a fresh install.

For another case, adding a new category (line 101 of categories.index.inc.php) on a fresh install (meaning, fresh database) will mess with the SEO path.

Suggest finding every instance of DB->insertid() that follows a DB->insert() and rewrite that pair of statements to a single statement that captures the result from the DB-insert() as the inserted id.

With respect to the improved fix for 2670, that was actually necessary. But, in that code, because what immediately follows that instance of insertid(), is the _clearCacheNotice() which destroys the needed return value that any other call to DB->insertid() makes - i.e., everywhere.

@abrookbanks
Copy link
Member

I can't reproduce this and the changes for last_insert ID should stabilise this further. I will reopen if the issue persists with 6.4.6. Thanks guys. I'm so behind with maintenance but on it while I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants