fix posts clauses and php warnings