Make WordPress Core

Opened 8 years ago

Last modified 14 months ago

#46555 new defect (bug)

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

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

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
8 years ago

  • Component General → 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
8 years ago

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

#3 @rweil55
8 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.


14 months ago

#5 @SirLouen
14 months ago

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

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
14 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.