Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
2.9k views
in Q2A Core by
I've looked everywhere (I think) but I nor my users can find a delete button... Is this a known issue?

1 Answer

+6 votes
by
selected by
 
Best answer

It is great that people use the v1.7 alpha code. The delete button has been added on July 23rd, so I guess you've downloaded the 1.7 version before that day. Most likely, if you download the latest code you should see the button: https://github.com/q2a/question2answer/archive/dev.zip

Also bear in mind that an index was created and then removed: https://github.com/q2a/question2answer/commit/cde60dbb2f90ee048a0855353c50ba30ee36e781 which means you should drop the previously created index:

DROP INDEX fromhidden on qa_messages
 
And then recreate it:
 
ALTER TABLE qa_messages ADD KEY fromhidden (fromhidden), ADD KEY tohidden (tohidden)
 
Note this would only apply to you if you've downloaded the code betwen May 16th and July 23rd. If you don't remember when you've download then run those SQL statements only if you have this exact line in your qa-db-install.php:
 
qa_db_upgrade_query('ALTER TABLE ^messages ADD KEY fromhidden (fromhidden, tohidden)');
 
EDIT:
 
Extending my answer on how to fix this the easy way:
 
For those who are caught in this same situation these are some steps to get this fixed.
 
1. Open qa-page-admin-categories.php
 
2. Locate line:
require_once QA_INCLUDE_DIR.'qa-db-admin.php';
 
3. After it copy and paste the following code (gist here)
 
$query = "SHOW INDEX FROM ^messages WHERE key_name = 'tohidden'";
$result = qa_db_read_one_value(qa_db_query_sub($query), true);
$shouldRun = !isset($result) && qa_opt('db_version') == 57;
if ($shouldRun) {
    echo "Running the update...<br>";
    qa_db_query_sub('DROP INDEX fromhidden on ^messages');
    qa_db_query_sub('ALTER TABLE ^messages ADD KEY fromhidden (fromhidden), ADD KEY tohidden (tohidden)');
    echo "Update done!!<br>";
} else {
    echo "You should not run the update. Remove the text from the file.<br>";
}
 
4. Navigate to the admin/categories section: http://yoursite.com/admin/categories
 
5. You should see some text above stating whether the update has run or whether it is not necessary for it to be run
 
6. If it has run, then refresh the page to make sure it will not run again (the text will state it is not necessary to run it)
 
7. Remove all the lines you've added and forget about this :)

 

by
Thanks for getting back to me pupi... I downloaded the dev version only a few days ago from github via the link on the right hand side of the page there. Presumably, that 'is' the latest version? Could you confirm that for me please, before I try making sense of and applying the above.
by
edited by
Sure. The thing is that the Download ZIP link is VERY tricky. EG:
https://github.com/q2a/question2answer/tree/130339cb665428af510542a31d18b9600e4f2a69
https://github.com/q2a/question2answer/tree/dev

As you can see, the button is the same, but the downloaded code is different. It would be better if you make that check by comparing the code. The line I gave you for the comparison should help to see if you have to run those SQL statements. If, apart from that, you want to check you have the latest version (as of today) see this https://github.com/q2a/question2answer/commit/22095853d0532142b8cdb7f1a8f02d6b2607e519

If line 153 is the qa-app-cookies.php then you have the latest version... which would be very weird because it HAS the delete button (I'm seing it in my environment right now).
by
Ok thanks again... I'll check it all out then.
by
The last link throws a 404 page error.
by
Fixed. It has a period that is interpreted as part of the URL... hat happens for respecting punctuation marks when writing URLs :)
by
edited by
I really don't think I have the skill for this. So, here's what I am assuming.

The qa-includes folder files in the dev version i installed. Are all dated 16/05/2014 I guess that means I can't have the latest version after all and that would suggest errors in the database quite beyond me to fix.

The above would suggest I maybe need to delete and reinstall a new database on the server and if needs be then I'll do that... Can you give me a link to a 'user' level latest version I can download and install please. Or confirm that the first link relating to dev2 is it? i.e:

https://github.com/q2a/question2answer/archive/dev.zip
by
Waaaaaaait. There is not need to delete anything. I've added simple step by step instructions on how to fix it. And yes, the URL ending in dev.zip will always get you the last version.
by
Wow... I'm so glad I didn't rush into it headlong. Thanks again pupi... I need to get some shuteye now, but I'll try your 'walk-through' tomorrow and post the results here.

Thanks for your help with this. I so appreciate it.
by
Hi Pupi... Just to let you know. I followed your qa-page-admin-categories.php edited code process and on completion. The missing 'delete' option was visible However, clicking it still would not delete PM's for me or my test users. In the end. I cleaned the database and fresh installed the 1.7dev2 link you provided. (Many thanks)

PM's can now be deleted but. It isn't a straight forward process... I have to go into recieved and sent items respectively and delete from both places to actually clear them completely? It's far better than the previous situation. But I wondered if you might have any thoughts on that?

My test site is hosted on a free hosting service for now and I mention it just in case that's a possible reason for the above behaviour.
by
It is weird that you couldn't delete the messages after that; I was in the same situation as you and it perfectly worked for me. Actually, the DB update has nothing to do with being able to delete posts or not... maybe you haven't updated all files when replacing the files with most up-to-date version. Hard to tell.

Well, I don't really know the WHY of things, I just know the WHAT by looking at the code. You are right: in order to fully delete a message from the database you have to delete it from both inboxes (the from and the to). Actually, the first one in deleting it just hides it from their own inbox, rather than deleting it, so that the one who still hasn't deleted it yet is still able to see it. Once that other user deletes the message it gets actually deleted from the database.

Now, I think it makes sense. I mean, I understand you'd like it to be simpler, something like: the first user in deleting the message actually deletes it from the DB. The issue with this approach is that the first user in deleting the message is "controlling" the other users' inbox by deleting a message there. It is like sending an email to a user, then regretting, deleting the message from your sent items, and then expecting it to be deleted from the recipient's inbox. If this was a democracy, I would vote for this to be the way it is right now :)

By the way, it has nothing to do with the hosting service, this is by design. Anyway, I don't know if core developers will make changes to this in the future. If you have a better approach you could post it to the v1.7 requests... but with 100 answers I hardly believe it will be herd :(
by
Paragraph one of yours aside. 2 and 3 make sense the way you've explained it and so. I/we have got as good as can be expected re; the PMing facility. And in the end, it was thanks to the version link you provided and so I'm grateful to you for that.

Re; your closing paragraph. I didn't really think the hosting service was a likely cause for concern but on the basis of 'But what do I know' I supplied the info.

As to adding to v1.7 requests? I think it prudent to pass on that one... But I appreciate you mentioning it.

Thanks again for your help.
by
hello, i use 1.6.3 and i just download the qa-dev files. How do i update my database and files to this 1.7? So it can work smoothly with problem.

Please some help.
by
This post is not exactly related to how to upgrade from 1.6.3 to 1.7alpha1 but rather about an issue that very few users could have encountered when upgrading. If you are upgrading now, you won't fall in this situation. Btw, upgrade process is the same as always http://www.question2answer.org/install.php . If you have further questions then ask them in a different thread. Thanks
...