Fixed Descriptions used in URL instead of file name after XFR import

vord

Member
I've imported from XFR user albums to Xenforo media Gallery. When I look at my own albums and click on the thumbnails I get a 400 invalid url error.

I have use friendly URLs turned on in the main Xenforo installation. The URLs include the description I added when I originally uploaded the files to XFR. In most cases the description is quite long and I have one heck of a URL which returns the 400 error.

Is there a way to fix this?
 
First time we've seen this, but indeed that field isn't appropriate to be used as a title, so we will change that in the next version.

For now, this query should set the media_title to be the same as what the filename was in XFR User Albums:

Code:
UPDATE xengallery_media AS media
INNER JOIN xf_attachment AS attachment ON
    (attachment.attachment_id = media.attachment_id)
INNER JOIN xf_attachment_data AS data ON
    (data.data_id = attachment.data_id)
SET media.media_title = data.filename
WHERE media.media_type = 'image_upload'

I have tested this query on my development board, so it should be safe; but I would still recommend taking a quick database backup; just in case it produces undesirable results.

The only thing I can think of here that may be somewhat undesirable is if there is no filename set in XFR User Albums; but we should be able to tidy those up too if that becomes an issue.
 
Good to know.

I've just made the change for the next version so that we use the filename by default for the media title.
 
In case it's of use to anyone else the descriptions disappeared after running the sql above. To copy the descriptions across I knocked up a really horrid php page. Here is the code without any safety devices or cleaning. Works apart from the htmlentities not being decoded

Code:
				// open database
				$con = mysql_connect($sqlserver,$sqlusername,$sqlpassword);
					if ($con)
				
						{
							mysql_select_db($databasename, $con);
							
						$start = $_GET ["start"];
						$end = $start + 9999 ;
									
									for ($i = $start; $i <= $end; $i++) {
									
									
									
									
												
														
														$result = mysql_query("SELECT description FROM xfr_useralbum_image_data WHERE data_id = '$i'");
														$row = mysql_fetch_array($result);
														 $DESCRIPTION = $row['description'];
														 
														 
																if ($DESCRIPTION) {
																
																		$DESCRIPTION = htmlentities($DESCRIPTION, ENT_QUOTES);
																			print ($DESCRIPTION);
																		
																	$updatequery = "UPDATE xengallery_media SET media_description = '$DESCRIPTION' WHERE media_id = '$i' ";
																									$handle = mysql_query($updatequery)
																										or die("update error ".mysql_error());
														
																}
									}		
											
											
											
		
		
		mysql_close($con);
		
		
		
		}
 
Top Bottom