News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Undefined array key "href"

Started by DeadMan..., April 07, 2023, 05:04:36 PM

Previous topic - Next topic

DeadMan...

Quoteindex.php?action=post;msg=1264;topic=805.0
Sources/Subs.php (Line 1809)

Type of error: Undefined
Error message
2: Undefined array key "href"

Happens whenever go to edit a post.
The post does have attachments.
So, when look at that area, I found this:

// No image. Show a link.
else
$returnContext .= '<a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a>';
I tell it how I see it... Don't like it? Hit Alt+F4!

Sir Osis of Liver

Doesn't happen in 2.1.3 core install, and that's core code.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

DeadMan...

Only seems to happen with some posts.
Wonder if it may have something to do with certain file types?

That particular post has a .exe, some .png's and 2 .cfg files attached.
One image file is inserted into the post.
I tell it how I see it... Don't like it? Hit Alt+F4!

Sir Osis of Liver

You can remove the attachments one at a time and see if it clears the error.  Don't see how it can cause that error.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

DeadMan...

Quote from: Sir Osis of Liver on April 07, 2023, 08:58:35 PMYou can remove the attachments one at a time and see if it clears the error.  Don't see how it can cause that error.

Does not seem to be that, as I did the same post on a test forum, no error.
Will try it again after enabling TinyPortal, to see if something there might be the issue.

EDIT: Yep, something with TP is causing the issue.
I tell it how I see it... Don't like it? Hit Alt+F4!

Steve

Since you know the drill then, I'll mark this solved just for 'team scanning topics to look at' sake.
DO NOT pm me for support!

@rjen

Quote from: Steve on April 08, 2023, 09:07:12 AMSince you know the drill then, I'll mark this solved just for 'team scanning topics to look at' sake.

Hmmm , maybe reconsider that?

https://www.simplemachines.org/community/index.php?msg=4150101
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

DeadMan...

Seems the fix is not as we expected:

Quote from: Bugo on April 08, 2023, 09:34:44 AMThis has nothing to do with TinyPortal, but is triggered during the editing of a post with images inserted using the attach tag in the text, when on the page calls ssi_recentTopics.

Possible fix, in Post.php find

        
// Load up 'em attachments!
        
foreach ($temp as $attachment)
        {
            
$context['current_attachments'][$attachment['id_attach']] = array(
                
'name' => $smcFunc['htmlspecialchars']($attachment['filename']),
                
'size' => $attachment['filesize'],
                
'attachID' => $attachment['id_attach'],
                
'approved' => $attachment['attachment_approved'],
                
'mime_type' => $attachment['mime_type'],
                
'thumb' => $attachment['id_thumb'],
            );
        }

and replace with

        
// Load up 'em attachments!
        
foreach ($temp as $attachment)
        {
            
$context['current_attachments'][$attachment['id_attach']] = array(
                
'name' => $smcFunc['htmlspecialchars']($attachment['filename']),
                
'size' => $attachment['filesize'],
                
'attachID' => $attachment['id_attach'],
                
'href' => $scripturl '?action=dlattach;attach=' $attachment['id_attach'],
                
'approved' => $attachment['attachment_approved'],
                
'mime_type' => $attachment['mime_type'],
                
'thumb' => $attachment['id_thumb'],
            );
        }


I tell it how I see it... Don't like it? Hit Alt+F4!

Steve

@rjen - apparently I was a bit hasty as you pointed out. Thank you for that. I'll be more careful in the future. :)

If I read the two posts right, the problem is fixed with the code change above but if it's not, @DeadMan... can mark it not solved.
DO NOT pm me for support!

@rjen

Well it is solved, I would like the team to maybe check it though: it seems this is bug when standard SMF functions are used I a std SMF post.

Accidentally portals seem to bring it to light, but perhaps the fix should be included in SMF itself?
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Arantor

Of course they should; anyone who uses that SSI function - not just portals - will have the same problem. Should be reported to GitHub so it can be included in a future version.

@rjen

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Advertisement: