Skip to content

Commit

Permalink
More Bug # 277 fixes.
Browse files Browse the repository at this point in the history
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
theory committed Aug 17, 2011
1 parent 1b0d4e8 commit 73d7e5f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/Bric/App/Callback/Desk.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ sub publish : Callback {
my $param = $self->params; my $param = $self->params;
my $story_pub = $param->{story_pub} || {}; my $story_pub = $param->{story_pub} || {};
my $media_pub = $param->{media_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 # If we were passed a string instead of an object, find the object
for my $pub (\$story_pub, \$media_pub) { for my $pub (\$story_pub, \$media_pub) {
Expand Down Expand Up @@ -380,7 +384,7 @@ sub publish : Callback {
throw_error( throw_error(
error => $err, error => $err,
maketext => [$err] maketext => [$err]
) if $allow_fatal; ) if $allow_fatal || !$is_ajax;
$self->raise_conflict([$err]); $self->raise_conflict([$err]);
} else { } else {
# we are set to warn, should we add a further warning to the msg ? # we are set to warn, should we add a further warning to the msg ?
Expand Down Expand Up @@ -427,7 +431,7 @@ sub publish : Callback {
# If it was on a desk, we need to revert its workflow status. # If it was on a desk, we need to revert its workflow status.
$self->_revert_to_original_state; $self->_revert_to_original_state;
# Continue with normal error handling. # 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); $self->raise_conflict($err->maketext);
} else { } else {
# Success! Need to log the move to a desk. Yes, this is late, but # Success! Need to log the move to a desk. Yes, this is late, but
Expand All @@ -442,8 +446,7 @@ sub publish : Callback {
} }


# Don't render anything for Ajax requests. # Don't render anything for Ajax requests.
my $r = $self->apache_req or return; $self->abort if $is_ajax;
$self->abort if ($r->headers_in->{'X-Requested-With'} || '') eq 'XMLHttpRequest';
} }


sub deploy : Callback { sub deploy : Callback {
Expand Down

0 comments on commit 73d7e5f

Please sign in to comment.