Giter VIP home page Giter VIP logo

Comments (11)

YahnisElsts avatar YahnisElsts commented on June 23, 2024

The "update now" button works via AJAX. My guess would be that while WordPress is installing the update there is some unexpected output (e.g. a PHP notice) that then gets included in the AJAX response. As a result, the script that handles the update button fails to parse the response and gets stuck.

To debug something like that, the first thing I would do is look at the HTTP requests sent by the browser. As you probably already know, most modern browsers include a network monitor of some kind. Examine the request that's sent when you click "update now". Usually it will be a POST request to admin-ajax.php. What does the response look like? Or is there no response and the request just times out?

Normally, the response will be a JSON document similar to this:

{"success":true,"data":{"update":"plugin","plugin":"newsletter\/plugin.php","slug":"newsletter","oldVersion":"Version 3.7.8","newVersion":"Version 3.7.9"}}

from wp-update-server.

caraffa avatar caraffa commented on June 23, 2024

Hi, Yahnis. Thanks for your answare.
This is the JSON response I get:

{"success":true,"data":{"update":"plugin","plugin":"CkTellNotifier/plugin.php","slug":"cktellnotifier","oldVersion":"Versione 0.1","newVersion":"Versione 0.99rc1"}}

So, apparently there is nothing wrong. The only thing I'm seeing that looks different is the CapitalCase name of my plugin.

from wp-update-server.

caraffa avatar caraffa commented on June 23, 2024

Sorry. I Inadvertently hit the "Close and comment" button instead of the "Comment" one.

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on June 23, 2024

That JSON looks correct to me. Is there anything else in the response - stray whitespace, perhaps? Are there any error messages in the JS console?

The capital-cased plugin field shouldn't matter - as far as I can tell, the script that runs AJAX updates (/wp-admin/js/updates.js) doesn't actually use it. The slug is the important bit. WP uses that to find the right plugin table row and replace the "updating" message with "updated!".

Anyway, the next thing I would try is sprinkling some console.log()'s into the wp.updates.updateSuccess method in updates.js to see if it actually receives the response and where things go wrong. (Or using a JS debugger and breakpoints.)

from wp-update-server.

caraffa avatar caraffa commented on June 23, 2024

Well, I've used Firefox and Safari to monitor network traffic and both don't have a "raw" view for the JSON response. Both display a neat list of key/values, so that i cannot say if there is something wrong in the actual JSON formatting. But my guess is that if the browser is displaying the answer in such a neat way, than it is highly improbable that some form of spurious chars are in the way.
That said, I'll follow your advice, and will try the console.debug approach to see what happens.
I'll let you know. Thanks

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on June 23, 2024

Well, I've used Firefox and Safari to monitor network traffic and both don't have a "raw" view for the JSON response.

Yes, I've noticed that, too. I think Chrome has an option to display the raw response. But you're probably right - if the browser can parse the JSON, WordPress shouldn't have any problems with it either.

from wp-update-server.

caraffa avatar caraffa commented on June 23, 2024

Caught!
The problem, as suspected, was the "CamelCase" in my plugin name. For really mysterious reasons the wp_ajax_update_plugin function in the ajax-actions.ph file "sanitizes" the slug, which, among others, lowerize it (why do that in the plugins.php page and NOT in the update-core-php page? Who knows!!!!)
I've replaced the 'slug' => sanitize_key( $_POST['slug'] ), with a much more reasonable 'slug' => preg_replace( '/[^A-Za-z0-9_\-]/', '', $_POST['slug'] ), and everything is working fine.
So the culprit was Wordpress and your code is as innocent as a newborn baby ;-).
Thank you again for your valuable help.

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on June 23, 2024

Side note: Chances are that WP core developers didn't notice that issue because all plugins on wordpress.org have lowercase directory names. WordPress is not designed to support installing updates from third-party sources, so this particular scenario probably never got tested.

from wp-update-server.

caraffa avatar caraffa commented on June 23, 2024

Yes. In fact I've submitted a bug report, explaining the whole issue, along with a fix proposal.

from wp-update-server.

jrfnl avatar jrfnl commented on June 23, 2024

@caraffa I'd like to follow the bug report - could you post a link to it here ?

from wp-update-server.

jrfnl avatar jrfnl commented on June 23, 2024

Never mind - found it: https://core.trac.wordpress.org/ticket/32465

from wp-update-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.