Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Q2A Core by
edited by
I'm playing around with a new Q2A installation and when I ask a question I get these errors:
Notice: Undefined index: tags in /qa/qa-include/qa-page-ask.php on line 148
Warning: implode(): Invalid arguments passed in /qa/qa-include/qa-util-string.php on line 477
Warning: Cannot modify header information - headers already sent by (output started at /qa/qa-include/qa-util-string.php:477) in /qa/qa-include/qa-base.php on line 1366
The last error would be due to the errors already appearing (Xdebug hints at qa_redirect() so I assume this is the point when it's about to redirect to the question you just psoted). The page has just these 3 errors on it and is otherwise completely blank. However, the question does get saved. 
The problem appears to be from at the code qa_tags_to_tagstring($in['tags']) which is on line 148. This Q2A installation is set up to use Categories only for classification, so I assume the tags index does not appear due to that.
Q2A version: 1.6.2
Will check into it for 1.6.3.

2 Answers

0 votes

I can confirm your first notice and your second warning.

But I do not have your third warning ("Cannot modify header information...."), and I do not have a blank page, but the correct page is displayed (the page with the new question).

(I use display_errors = Off, and log_errors=On in my php.ini).

These log entries do not seem to be "errors", but just "warnings" about a null value at runtime..... (that I can find correctly -in my opinion- in the qa_posts table, "tags" column, when the question is inserted)

I think that checking the value of the array/variable with an "isset" these warnings will disappear....

But I'm not a php expert smiley


The third one appears because content had already started to be output to the browser, then PHP tried to modify header information (which must come before any content). That happens because display errors is on for my dev machine, so the notice gets output and the header() function can't be called.

The solution is likely going to be making sure the undefined index is actually defined, as an empty array or something.
Reporting error like the one you did here gives me the impression that it is not the time yet to migrate from 1.5.4 to 1.6.x. Do you, in overall, agree?
edited by
In my opinion it is not an *error*, it is a *warning*/*notice*. So no problem.....

Scott can correct me if I'm wrong :-)
Notices can cause bugs in the app, for example if a variable doesn't exist and you try to save it to the database, you'll get a blank entry. Instead it should be detected and nothing saved at all.

In the above case, it doesn't appear to cause any adverse effects. And it's only the notice that causes the header() error. So if display of notices is turned off, the header() function will work fine and nothing will go wrong.
0 votes

You were right about the cause. To fix it, make this change in qa-page-ask.php:


... to ...

isset($in['tags']) ? qa_tags_to_tagstring($in['tags']) : ''

This will be rolled into Q2A 1.6.3.