Permalink
Browse files

More Bug # 277 fixes.

This time, always die on non-ajax requests. This allows the "publish later" option on the Publish desk to throw an error and return to the same page, rather than load the scheduling page and show the error there.
  • Loading branch information...
1 parent 1b0d4e8 commit 73d7e5f0f2991204efd17e0492c461468fde877a @theory theory committed Aug 17, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/Bric/App/Callback/Desk.pm
View
11 lib/Bric/App/Callback/Desk.pm
@@ -219,6 +219,10 @@ sub publish : Callback {
my $param = $self->params;
my $story_pub = $param->{story_pub} || {};
my $media_pub = $param->{media_pub} || {};
+ my $is_ajax = do {
+ my $r = $self->apache_req;
+ $r && ($r->headers_in->{'X-Requested-With'} || '') eq 'XMLHttpRequest';
+ };
# If we were passed a string instead of an object, find the object
for my $pub (\$story_pub, \$media_pub) {
@@ -380,7 +384,7 @@ sub publish : Callback {
throw_error(
error => $err,
maketext => [$err]
- ) if $allow_fatal;
+ ) if $allow_fatal || !$is_ajax;
$self->raise_conflict([$err]);
} else {
# we are set to warn, should we add a further warning to the msg ?
@@ -427,7 +431,7 @@ sub publish : Callback {
# If it was on a desk, we need to revert its workflow status.
$self->_revert_to_original_state;
# Continue with normal error handling.
- die $err if $allow_fatal;# || !isa_bric_exception $err, 'Error';
+ die $err if $allow_fatal || !$is_ajax;
$self->raise_conflict($err->maketext);
} else {
# Success! Need to log the move to a desk. Yes, this is late, but
@@ -442,8 +446,7 @@ sub publish : Callback {
}
# Don't render anything for Ajax requests.
- my $r = $self->apache_req or return;
- $self->abort if ($r->headers_in->{'X-Requested-With'} || '') eq 'XMLHttpRequest';
+ $self->abort if $is_ajax;
}
sub deploy : Callback {

0 comments on commit 73d7e5f

Please sign in to comment.