Bug report: Phoca Gallery 3.1.2 - external links of images

NekaraNef
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 15 Feb 2012, 13:54

Bug report: Phoca Gallery 3.1.2 - external links of images

Post by NekaraNef »

Problem: The external links of images were displayed (category view), even though no external links were given. I've dived into the scripts and ran into the following 'problems':

File: /administrator/components/com_phocagallery/models/phocagalleryimg.php (line 190+)

Code: Select all

if ($data['extlink1link'] != '') {...
		} else {
			$data['extlink1'] 	= $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon'];
		}
		
		if ($data['extlink2link'] != '') {...
		} else {
			$data['extlink2'] 	= $data['extlink2link'] . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon'];
		}
The code in itself doesn't "need" to be a problem. I'm not sure why you want to store any external link information when no external link ($data['extlink2link'] and $data['extlink2link']) is given, but it's not necessarily "wrong". The problem arises in the next piece:

File: /components/com_phocagallery/views/category/view.html.php (line 1502+)

Code: Select all

			$items[$iS]->displayiconextlink1	= 0;
			if (isset($items[$iS]->extlink1)) {
				$items[$iS]->extlink1	= explode("|", $items[$iS]->extlink1, 4);
				if (isset($items[$iS]->extlink1[0]) && isset($items[$iS]->extlink1[1])) {
					...
					}
				} else {
					$items[$iS]->displayiconextlink1		= 0;
				}
			}
			
			$items[$iS]->displayiconextlink2		= 0;
			if (isset($items[$iS]->extlink2)) {
				$items[$iS]->extlink2	= explode("|", $items[$iS]->extlink2, 4);
				if (isset($items[$iS]->extlink2[0]) && isset($items[$iS]->extlink2[1])) {
					...
					}else {
						$items[$iS]->extlink2[4] = $items[$iS]->extlink2[1];
						$items[$iS]->extlink2[5] = 'style="text-decoration:underline"';
					}
				} else {
					$items[$iS]->displayiconextlink2		= 0;
				}
			}
The problem here is the use of isset():

if (isset($items[$iS]->extlink1[0]) && isset($items[$iS]->extlink1[1]))

... because you already FORCING those variables to always exist:

else { $data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon']; }

You need to do one of two things: drop all external link information if no external link url is given: else { $data['extlink1'] =""} , or use !empty() either instead of isset() or along side of isset().

NOTE: The external links are used in a variety of scripts. I haven't checked the other scripts, but they are most likely facing the same problem; no external link was given, but because the variable still exists as an empty variable, it still tries to display the external links.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47916
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Bug report: Phoca Gallery 3.1.2 - external links of imag

Post by Jan »

Hi, do you get this problem in latest 3.2.0 version?

Jan
If you find Phoca extensions useful, please support the project
NekaraNef
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 15 Feb 2012, 13:54

Re: Bug report: Phoca Gallery 3.1.2 - external links of imag

Post by NekaraNef »

Hi Jan,
Sorry for the late reply. I didn't have a chance to test it out until today, but I finally had another gallery to install. And no, I didn't run into the same problem using the latest version; 3.2.0. Thank you very much for fixing it.

NekaraNef
Post Reply