Replace_url.php script throwing Fatal Error


(Nic Hubbard) #1

Matrix Version: 5.4.3.1

We are working on moving from one site asset to another, and need to move our www.puc.edu URL to the new site asset.

I have a staging server, and using the replace_url.php script to the current site to www.puc.edu/_oldsite worked fine. However, when using the script again to move newsite.puc.edu to www.puc.edu we are getting this error:

Fatal error: Uncaught exception ‘PDOException’ with message: 'SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint “ast_lookup_pk”

DETAIL: Key (url)=(www.puc.edu/__data/assets/image/0004/133465/DSC_0192.jpg) already exists.’ in [SYSTEM_ROOT]/core/lib/DAL/DAL.inc(612): PDOStatement->execute()

#1 [SYSTEM_ROOT]/scripts/replace_url.php(195): DAL::execPdoQuery(Object(PDOStatement))

Why would changing this URL cause an error with an image? We DO link in a lot of images from the old site, since we use shared content. Could this be the problem?


(Nic Hubbard) #2

I ended up trying the add_remove_url.php script and that seemed to work.


(Marcus Fong) #3

I think you’re right, the issue here would’ve been because the __data URLs are based on the underlying system root URL corresponding to the site URL, not the site URL itself. So for the shared image asset you’ve posted, the original situation would have been:

Two system root URLs: newsite.puc.edu and www.puc.edu
Two image URLs: newsite.puc.edu/__data/assets/image/0004/133465/DSC_0192.jpg and www.puc.edu/__data/assets/image/0004/133465/DSC_0192.jpg

After renaming, you would have the following situation:

One system root URL: www.puc.edu (covering both www.puc.edu and www.puc.edu/_oldsite)
One image URL: www.puc.edu/__data/assets/image/0004/133465/DSC_0192.jpg

From what you’ve posted it looks like add_remove_url.php can handle that scenario, but replace_url.php doesn’t account for it and ends up trying to insert a second identical image URL, which fails.


(Nic Hubbard) #4

Thanks, glad to know that was the issue!