Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.3k views
in Plugins by
retagged by

While I was trying to solve an issue with the history plugin, I discovered an error in my server logs which is possibly a bug of the history plugin:

Undefined variable: anchor in /qa-include/qa-app-format.php(1452) : eval()'d code on line 287

There is no variable "anchor" in line 287:
if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath']))

Thanks @Merkus: The error is caused by line 287 in qa-history-layer.php:
$activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'),null,$anchor);

 

Q2A version: 1.5.1
by
I thought it could be the badges plugin ("Show list of source posts for each badge on user profile"), switched it off, but no changes. Error still appears.

I found a user with a history page, where - every time I load the page - the error is written to my error log: http://www.gute-mathe-fragen.de/user/Berliner?tab=history

There is nothing special about this user, 2 questions posted within last 2 weeks.

But I found out: It does not matter if you are logged in or not. Only loading the user history page leads to this error.

-> I disabled the plugin and loaded the user page, no error.

+ And this user history page brings up two times the error!
http://www.gute-mathe-fragen.de/user/youtuber?tab=history

2 Answers

0 votes
by
 
Best answer

Alright, in qa-history-layer.php I replaced $anchor with null and the error disappeard:

change line 287:
$activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'),null,$anchor);

to:
$activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'),null,null);
 

Hope that helps.

by
What is the draw-back of making that change?  What does the $anchor parameter do and why is it causing this error (which I am also seeing now)
by
The function qa_path_html (see file qa-base.php) transfers the anchor into function qa_path which adds an anchor to the page. a link anchor to jump to comment / post etc.

e.g. http://www.question2answer.org/qa/16060/history-plugin-undefined-variable-anchor-include-format-code#16060

#16060 is the anchor!
+1 vote
by

The line number 287 refers to the file calling qa-app-format.php.

You need to locate line 287 in, probably, one of the history plugin files. My guess would be the layer file.

 

by
thanks for the tip. I will check this.
...