Make WordPress Core

Opened 16 years ago

Closed 11 years ago

#8420 closed enhancement (duplicate)

Disable error redirects when in DOING_AJAX

Reported by: janbrasna's profile janbrasna Owned by: kapeels's profile kapeels
Milestone: Priority: low
Severity: minor Version: 2.7
Component: Administration Keywords: has-patch 3.2-early gci
Focuses: Cc:

Description

If a DB/install error occurs in admin during ajax requests (like autosave), the response shouldn't return the whole redirected page, see $ATT (admin-ajax-install-trigger.png). If something goes awry and we're DOING_AJAX, an error message that could fit inline would be better.

Attachments (8)

admin-ajax-install-trigger.png (105.3 KB) - added by janbrasna 16 years ago.
wp-db.diff (1.2 KB) - added by kapeels 14 years ago.
wp.patch (1.1 KB) - added by kapeels 14 years ago.
temp-patch.diff (1.4 KB) - added by kapeels 14 years ago.
wp.2.patch (1.8 KB) - added by kapeels 14 years ago.
8420.diff (1.9 KB) - added by kapeels 14 years ago.
func.diff (2.7 KB) - added by kapeels 14 years ago.
final.diff (2.5 KB) - added by kapeels 14 years ago.
Hope this IS the final one.

Download all attachments as: .zip

Change History (21)

#1 @janbrasna
16 years ago

  • Priority changed from lowest to low
  • Severity changed from trivial to minor

Maybe something like the logged-out inline alert could do.

#2 @FFEMTcJ
16 years ago

  • Milestone changed from 2.8 to Future Release

#3 @kapeels
14 years ago

  • Owner changed from anonymous to kapeels
  • Status changed from new to accepted

@kapeels
14 years ago

#4 @kapeels
14 years ago

  • Keywords has-patch 2nd-opinion added; ajax error redirect removed

Needs to have a nice message than the current dumb one.

Does anything in the code need to be changed?

#5 @westi
14 years ago

This is a good first pass at fixing this issue but I think it is worth seeing if we can resolve this generically for all calls to wp_die duing AJAX requests.

At the moment your message is very specific to the autosave scenario and will not make much sense in other scenarios.

Please could you look at implementing a different wp_die handler for AJAX requests - hint look at wp_die and _default_wp_die_handler to make a generic solution and also look at changing the AJAX code so that it recognises these error messages as responses

#6 @westi
14 years ago

  • Cc westi added
  • Keywords gci added

@kapeels
14 years ago

@kapeels
14 years ago

@kapeels
14 years ago

#7 @westi
14 years ago

This looks like it is starting to come together well.

It would be good to get a patch up here of all your changes as at the moment you are only generating patches for individual files which makes it much harder to review.

We have some tips on generating patches linked from the front page which might help.

https://core.trac.wordpress.org/#HowtoSubmitPatches

@kapeels
14 years ago

#8 @westi
14 years ago

This latest patch is look great.

The next step on this will probably be not to return with 'what' => 'autosave', but with 'what' => 'error', .

This will mean that the autosave js would need changing to handle this different response correctly probably.

You can add: define( 'SCRIPT_DEBUG', true); to your wp-config.php and then just edit and patch the .dev.js files to test this out.

#9 @kapeels
14 years ago

I changed the function to use the core wordpress error handling system. And it works good now. But, it isn't shown in the form of error when the error is loaded in the UI. It is left-aligned, and doesn't has the red theme.

I found that this happens because of the issue I have posted here - http://stackoverflow.com/questions/4279657/somethings-wrong-with-this-jquery-code-in-wordpress

The wp_error tag is not being recognized by jQuery('wp_error', child) ....

Anybody?

@kapeels
14 years ago

#10 @westi
14 years ago

The current patch doesn't apply to trunk very well - I get some rejects.

Even then it doesn't seem to actually send anything back in an error scenario from my testing.

@kapeels
14 years ago

Hope this IS the final one.

#11 @kapeels
14 years ago

The above patch's for 3.0 branch.

#12 @westi
14 years ago

  • Keywords 3.2-early added; 2nd-opinion removed

Well done for persevering with this!

#13 @jeremyfelt
11 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from accepted to closed

It looks like this was resolved in #15327, see [19801] for _ajax_wp_die_handler().

Note: See TracTickets for help on using tickets.