summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-21 18:29:35 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-21 18:29:35 +0100
commitb7f5a1a6b354d7eefaecb828a57d9d073654ac50 (patch)
tree0ff0b366b8284fa776e3a20df80e690e4ecd7fb4
parent3f404879e72089414a5ce3282433cf5d1795b591 (diff)
downloadfisheye-b7f5a1a6b354d7eefaecb828a57d9d073654ac50.tar.gz
fisheye-b7f5a1a6b354d7eefaecb828a57d9d073654ac50.tar.bz2
fisheye-b7f5a1a6b354d7eefaecb828a57d9d073654ac50.zip
Replace getParentGalleries loop with direct getRow ancestor walk
Drop all dependency on getParentGalleries result parsing (fg.* column casing, associative key detection). Use a single simple getRow per level with explicit lowercase aliases (gid, cid, gtitle) so Firebird column name casing can't interfere. Walks up to 10 levels and builds $ret directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xincludes/classes/FisheyeBase.php40
1 files changed, 15 insertions, 25 deletions
diff --git a/includes/classes/FisheyeBase.php b/includes/classes/FisheyeBase.php
index f5f4336..0f35ad6 100755
--- a/includes/classes/FisheyeBase.php
+++ b/includes/classes/FisheyeBase.php
@@ -160,35 +160,25 @@ not ready for primetime
if( !$this->getField( 'gallery_path' ) ) {
if( $this->isValid() ) {
$ancestors = [];
- $pathIds = [];
$currentContentId = $this->mContentId;
for( $depth = 0; $depth < 10; $depth++ ) {
- $parents = $this->getParentGalleries( $currentContentId );
- if( !$parents ) break;
- $found = false;
- foreach( $parents as $galleryId => $galleryData ) {
- if( is_numeric( $galleryId ) && is_array( $galleryData ) ) {
- $ancestors[] = (int)$galleryId;
- array_unshift( $pathIds, $galleryId );
- $currentContentId = $this->mDb->getOne(
- "SELECT fg.`content_id` FROM `".BIT_DB_PREFIX."fisheye_gallery` fg WHERE fg.`gallery_id`=?",
- [(int)$galleryId]
- );
- $found = true;
- break;
- }
- }
- if( !$found ) break;
+ $parent = $this->mDb->getRow(
+ "SELECT fg.gallery_id AS gid, fg.content_id AS cid, lc.title AS gtitle
+ FROM ".BIT_DB_PREFIX."fisheye_gallery fg
+ INNER JOIN ".BIT_DB_PREFIX."liberty_content lc ON (lc.content_id=fg.content_id)
+ INNER JOIN ".BIT_DB_PREFIX."fisheye_gallery_image_map fgim ON (fgim.gallery_content_id=fg.content_id)
+ WHERE fgim.item_content_id=?",
+ [$currentContentId]
+ );
+ if( !$parent ) break;
+ array_unshift( $ancestors, $parent );
+ $currentContentId = $parent['cid'];
}
- if( $pathIds ) {
+ if( $ancestors ) {
+ $pathIds = array_column( $ancestors, 'gid' );
$this->setGalleryPath( '/'.implode( '/', $pathIds ) );
- foreach( array_reverse( $ancestors ) as $gid ) {
- $ret[$gid] = $this->mDb->getOne(
- "SELECT lc.`title` FROM `".BIT_DB_PREFIX."liberty_content` lc
- INNER JOIN `".BIT_DB_PREFIX."fisheye_gallery` fg ON (fg.`content_id`=lc.`content_id`)
- WHERE fg.`gallery_id`=?",
- [$gid]
- );
+ foreach( $ancestors as $ancestor ) {
+ $ret[$ancestor['gid']] = $ancestor['gtitle'];
}
}
}