View Issue Details

IDProjectCategoryView StatusLast Update
0002081OXID eShop (all versions)1.01. Products (product, categories, manufacturer, promotions etc.)public2012-12-07 14:27
ReporterMoehlis Assigned To 
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionwon't fix 
Product Version4.4.0 revision 28699 
Summary0002081: getPictureGallery creates wrong array index if a previous pic is missing
Descriptionesample:

an article with following pictures set:
pic1: none
pic2: image.jpg

the output of oxarticles::getPictureGallery() will be something like:

Array (
 ZoomPic => 1
 ZoomPics => Array
  1 => Array
    id => 1
    file => image.jpg
)

The important thing is the id - it is "1". Seems ok, but causes problems if you have a special treatment for the first zoom pic (you cannot rely on the index, because its not the first zoompic, its the second one)

Steps To Reproduceold:
core/oxarticle.php:2178 EE 4.4.0 rev28699
oxarticles::getPictureGallery():
        for ( $j = 1,$c = 1; $j <= $iZoomPicCount; $j++) {
            $sVal = $this->getZoomPictureUrl($j);

            if ( !$oStr->strstr($sVal, 'nopic.jpg')) {
                if ($this->getConfig()->getConfigParam('blFormerTplSupport')) {
                    $sVal = $this->_sDynImageDir."/".$sVal;
                }
                $blZoomPic = true;
                $aZoomPics[$c]['id'] = $c;
                $aZoomPics[$c]['file'] = $sVal;
                //anything is better than empty name, because <img src=""> calls shop once more = x2 SLOW.
                if (!$sVal) {
                    $aZoomPics[$c]['file'] = "nopic.jpg";
                }
                $c++;
            }
        }

solution:
        for ( $j = 1,$c = 1; $j <= $iZoomPicCount; $j++) {
            $sVal = $this->getZoomPictureUrl($j);

            if ( !$oStr->strstr($sVal, 'nopic.jpg')) {
                if ($this->getConfig()->getConfigParam('blFormerTplSupport')) {
                    $sVal = $this->_sDynImageDir."/".$sVal;
                }
                $blZoomPic = true;
                $aZoomPics[$c]['id'] = $c;
                $aZoomPics[$c]['file'] = $sVal;
                //anything is better than empty name, because <img src=""> calls shop once more = x2 SLOW.
                if (!$sVal) {
                    $aZoomPics[$c]['file'] = "nopic.jpg";
                }
            }
            $c++; // <- !
        }
TagsProducts
ThemeBoth
BrowserAll
PHP Versionany
Database Versionany

Activities

Moehlis

2010-09-02 16:39

reporter   ~0003473

using $j instead of $c seems to be more efficiently

dainius.bigelis

2010-09-07 09:00

reporter   ~0003481

@Developers: please check from the source code side if it is like described. Please consider suggested code snippet.

arturas.sevcenko

2012-06-19 09:05

reporter   ~0006919

getPictureGallery() method returns only array of available pictures. If someone needs to rely on actual ID's of pictures, including the missing ones, you need to change the code for your needs, cause that's how this picture gallery works and shop functioning correctly.