pressbooks / pressbooks

Open publishing. Open web. Open source.
https://pressbooks.org/
GNU General Public License v3.0
416 stars 132 forks source link

Cloning: Images not stored in clone's media library if image is altered in original book #2125

Open pb-amy opened 3 years ago

pb-amy commented 3 years ago

Description

This unexpected cloning routine was identified in this client correspondence: https://pressbooks.zendesk.com/agent/tickets/3927

In the request above, the client cloned a book from an open source network (https://digitaleditions.library.dal.ca/environmentalscience/) to a Pressbooks-operated network (https://caul-cbua.pressbooks.pub/environmentalscience/). Upon doing so, the client realized that, although the images still show up on the cloned book, only thirteen images were cloned into the media library from the original and the rest were still referencing the images from the original book. All of the images which did not clone successfully appear to have been edited on the server, which adds additional info to the image URL. This issue able to be reproduced locally: https://integrations.pressbooks.network/environmentalscience/

Steel has investigated a little bit and has guessed that this may occur when the image is altered on the Pressbooks platform in the original. Here is corresponding code from the cloning routine: https://github.com/pressbooks/pressbooks/blob/fb9320e3af09ddd3373a19f5b37d2feba07736c2/inc/cloner/class-cloner.php#L741-L754

From the original book:

  1. An example of an image where its clone ended up in the media library: https://digitaleditions.library.dal.ca/environmentalscience/chapter/chapter-1/
  2. An example of an image whose clone did not end up in the media library: https://digitaleditions.library.dal.ca/environmentalscience/chapter/chapter-28-ecologically-sustainable-development/

Steps to Reproduce

  1. Clone the original book
  2. Check media library

Expected behavior: All images upon cloning should go in the media library

Actual behavior: Only certain images cloned into the media library, other images were left out.

SteelWagstaff commented 3 years ago

Check https://github.com/pressbooks/pressbooks/blob/6c46984c85984ee942aa213a313d2c017f7c98ad/inc/cloner/class-downloads.php#L84 to fix/resolve this