Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 4ee39a0df56be5e1032d2d5c6dc55a4ade843ce3 1 parent 642052e
@theory theory authored committed
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 {
Please sign in to comment.
Something went wrong with that request. Please try again.