Make WordPress Core

Opened 7 years ago

Last modified 4 months ago

#46555 new defect (bug)

update fails when I have a print statement in my code.

Reported by: rweil55's profile rweil55 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: dev-feedback
Focuses: Cc:

Description

I get the the pink bar message "update failed", when I attempt to update a page that has an executed print statement in the code.
The file saves/updates, even though there is an error message.

Can the message be changed to "update returned unexpected characters" or some such.

running wordpress 5.1.1

Change History (6)

#1 @subrataemfluence
7 years ago

  • Component changed from General to Posts, Post Types
  • Keywords reporter-feedback added

Hi, can you please let me know the exact steps to reproduce the issue?

I was unable to clearly understand "...page that has an executed print statement in the code..."

#2 @mukesh27
7 years ago

Does the issue still happen with all plugins disabled and a default theme (Twenty Nineteen) activated?

#3 @rweil55
7 years ago

I had some shortcode code that instead of returning output for wordpress to display, it had a "print" statement to send some debugging text to the browser. i.e sending output directly to the browser rather than through wordpress.

Obviously a no-no, but it took me a while to figure out that was what was causing the "update failed" message.

Here is a short code function that will cause the message. Remove the print statement, and no message.
function dothework($atts) {

print "hello world - should not do this";
return "this is the right way";

}

Hope this helps
Roy

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


4 months ago

#5 @SirLouen
4 months ago

  • Component changed from Posts, Post Types to Editor
  • Keywords dev-feedback added; reporter-feedback removed
  • Severity changed from minor to normal
  • Version 5.1 deleted

Reproduction Report

Description

✅ This report validates that the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Seventeen 3.9
  • MU Plugins: None activated
  • Plugins:
    • BBB Testing Dolly
    • Test Reports 1.2.0

Testing Instructions

  1. Add, for example, a shortcode that prints and returns anything you want (some strings for example)
  2. Add this shortcode to any page
  3. 🐞 On save, post will be saved but error will still appear on the top

Actual Results

  1. ✅ Error condition occurs (reproduced).

Additional Notes

  • Although this is not the right thing, not having proper control structures may lead to this conflicts when dealing with the rest API as reported here. Maybe this behavior was expected, I leave this for a second opinion.

#6 @rweil55
4 months ago

As mentioned in my first report, the message "update failed" is incorrect. The update did save.

A more suitable error message would be "update returned unexpected characters," which is a message that is used elsewhere and better explains the response.

Note: See TracTickets for help on using tickets.