Skip to main content
Topic: The database value you're trying to insert does not exist: current_topic (Read 2845 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

The database value you're trying to insert does not exist: current_topic

Hi,

1.png

2.png

everything on the edit page is normal created thumbnail image  

no thumbnails on the topic page

 "X" click

error message

The database value you're trying to insert does not exist: current_topic
sorry for my bad english

Re: The database value you're trying to insert does not exist: current_topic

Reply #1

Can you check in the log if there is some more details? (For example the file and the line.)
Bugs creator.
Features destroyer.
Template killer.

Re: The database value you're trying to insert does not exist: current_topic

Reply #2

sorry,

Error type: Critical
The database value you're trying to insert does not exist: current_topic
Function: getAttachmentFromTopic

sources/subs/Attachments.subs.php
Line: 1145



Error type: Unspecified
Notice: Undefined variable: id_topic

sources/controllers/Attachment.controller.php
Line: 347



Error type: Critical
The database value you're trying to insert does not exist: current_topic
Function: getAttachmentThumbFromTopic

sources/subs/Attachments.subs.php
Line: 1191



Error type: Unspecified
Notice: Undefined variable: id_topic

sources/controllers/Attachment.controller.php
Line: 352



forum attachment folder setting: Separate by year and month
sorry for my bad english

Re: The database value you're trying to insert does not exist: current_topic

Reply #3

@Spuds I'm a little tired and I may be reading something wrong:
Code: (Attachment.controller.php) [Select]
			if (empty($topic) && !empty($id_attach))
{
$attachPos = getAttachmentPosition($id_attach);
if ($attachPos !== false)
{
list($id_board, $id_topic) = array_values($attachPos);
}
else
{
$id_board = 0;
}
}
else
{
$id_board = $board;
$id_topic = $topic;
}

isAllowedTo('view_attachments', $id_board);

if ($this->_req->getQuery('thumb') === null)
{
347 => $attachment = getAttachmentFromTopic($id_attach, $id_topic);
}
else
{
$this->_req->query->image = true;
352 => $attachment = getAttachmentThumbFromTopic($id_attach, $id_topic);

To have $id_topic not set, the only path I see is where it sets $id_board to 0.
But, if $id_board is set to 0, then the processing should stop at the isAllowedTo... isn't it?
But if isAllowedTo doesn't stop the processing we have some nasty stuff going around... :-\

@gevv try changing in Attachment.controller.php the following line:
Code: [Select]
			isAllowedTo('view_attachments', $id_board);
to:
Code: [Select]
			try
{
isAllowedTo('view_attachments', $id_board);
}
catch (\Exception $e)
{
return $this->action_no_attach();
}
Bugs creator.
Features destroyer.
Template killer.

Re: The database value you're trying to insert does not exist: current_topic

Reply #4

I also see sometimes this error on my forum, I deleted the log yesterday and cannot give more info...
Some attachments are displayed in different topics using the bbcode "attach", could be this the cause? I only see it on my forum skoda, not on the small shark where I have the same add-ons installed but not using the bbcode to display attachments posted in different topics.

Not 100% sure about this, but IIRC I've seen once that the error was related to an avatar posted as attachment. I'll check better in the next days
sorry for my bad english

Re: The database value you're trying to insert does not exist: current_topic

Reply #5

From the code, I'd say that the only path leading to that error is when the attachment has been removed.
In that case getAttachmentPosition return false and only $id_board is set, leaving $id_topic not set (that would generate the error).
ohh... idiot I am.
Admins have allowedTo true by default, so we cannot rely on isAllowedTo to block the execution path in case of admins and so it passes that stage and arrives to an unset $id_topic. It's obvious.

Then I'd say my previously suggested change wouldn't make any difference, instead:
Code: [Select]
				else
{
$id_board = 0;
}
should be replaced with:
Code: [Select]
				else
{
$id_board = 0;
$id_topic = 0;
}
this should ensure $id_topic is set, and both getAttachmentFromTopic and getAttachmentThumbFromTopic should return an empty array making the code show an error image.
Bugs creator.
Features destroyer.
Template killer.

Re: The database value you're trying to insert does not exist: current_topic

Reply #6

Thanks @emanuele

2 changes?

      
Code: [Select]
			{
isAllowedTo('view_attachments', $id_board);
}
catch (\Exception $e)
{
return $this->action_no_attach();
}

and;



Code: [Select]
			else
{
$id_board = 0;
$id_topic = 0;
}

sorry for my bad english

Re: The database value you're trying to insert does not exist: current_topic

Reply #7

No,only the second.
Bugs creator.
Features destroyer.
Template killer.