Commit c6bce760 by pupi1985

Avoid throwing an error on non-existent posts

parent b74d7099
......@@ -649,9 +649,50 @@ function qa_admin_single_click_array($entityid, $action)
} else { // something to do with a post
require_once QA_INCLUDE_DIR . 'app/posts.php';
$post = qa_post_get_full($entityid);
$post = qa_db_single_select(qa_db_full_post_selectspec(null, $entityid));
// Handle non-existent posts
if ($post === null) {
switch ($action) {
case 'approve':
case 'reject':
$entityCount = (int)qa_opt('cache_queuedcount');
$selector = '.qa-nav-sub-counter-moderate';
break;
case 'reshow':
case 'delete':
$entityCount = (int)qa_opt('cache_hiddencount');
$selector = '.qa-nav-sub-counter-hidden';
break;
case 'hide':
case 'clearflags':
$entityCount = (int)qa_opt('cache_flaggedcount');
$selector = '.qa-nav-sub-counter-flagged';
break;
default:
$selector = '';
$entityCount = 0;
}
return array(
'result' => 'error',
'error' => array(
'type' => 'post-not-found',
'message' => qa_lang_html('main/general_error'),
),
'domUpdates' => array(
array(
'selector' => $selector,
'html' => $entityCount,
),
array(
'selector' => '#p' . $entityid,
'action' => 'conceal',
),
),
);
}
if (isset($post)) {
$queued = (substr($post['type'], 1) == '_QUEUED');
switch ($action) {
......@@ -665,7 +706,7 @@ function qa_admin_single_click_array($entityid, $action)
$response['domUpdates'] = array(
array(
'selector' => '.qa-nav-sub-counter-moderate',
'html' => max($entityCount, 0),
'html' => $entityCount,
),
array(
'selector' => '#p' . $entityid,
......@@ -707,7 +748,7 @@ function qa_admin_single_click_array($entityid, $action)
$response['domUpdates'] = array(
array(
'selector' => '.qa-nav-sub-counter-hidden',
'html' => max($entityCount, 0),
'html' => $entityCount,
),
array(
'selector' => '#p' . $entityid,
......@@ -750,7 +791,7 @@ function qa_admin_single_click_array($entityid, $action)
$response['domUpdates'] = array(
array(
'selector' => '.qa-nav-sub-counter-flagged',
'html' => max($entityCount, 0),
'html' => $entityCount,
),
array(
'selector' => '#p' . $entityid,
......@@ -788,7 +829,6 @@ function qa_admin_single_click_array($entityid, $action)
default:
}
}
}
return $response;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment