Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#1220 closed defect (bug) (fixed)

Preview results in SQL errors

Reported by: ryan's profile ryan Owned by: ryan's profile ryan
Milestone: Priority: high
Severity: major Version: 1.5
Component: Administration Keywords:
Focuses: Cc:


?preview=1 is bad mojo.

Attachments (1)

preview_draft.diff (5.6 KB) - added by ryan 19 years ago.

Download all attachments as: .zip

Change History (5)

#1 @ryan
19 years ago

  • Patch set to No

#2 @davidhouse
19 years ago

Does preview actually do anything useful? The block of code has been sitting in the get_posts() function as long as I can remember, I've always just assumed it was a hangover from the b2 days. This is the code which deals with preview:

if ($qpreview?) {

$request = 'SELECT 1-1'; dummy mysql query for the preview
little funky fix for IEwin, rawk on that code
$is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT)));
if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) {

$preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('
1',16,10).';'", $preview_content);



Now, the SQL errors comes because SELECT 1-1 doesn't return any posts, and so nothing is passed to update_post_caches() (and numerous other functions that are expecting it). But the rest of the code makes even less sense: the variable $preview_content isn't mentioned anywhere else in all of WordPress, nore $IEWin_bookmarklet_fix. In other words, this block of code simply changes $request meaning that no posts are matched (resulting in the plethora of SQL errors reported here), then operates a preg_replace on a variable that hasn't been set and is never elsewhere looked at.

Isn't it time we cut the preview code out of WordPress?

edited on: 04-09-05 12:40

#3 @ryan
19 years ago

Yes, it's going away. See attached patch which removes the old preview stuff, replacing it with a means to display draft posts.

#4 @ryan
19 years ago

  • fixed_in_version set to 1.5.1
  • Owner changed from anonymous to rboren
  • Resolution changed from 10 to 20
  • Status changed from new to closed

19 years ago

Note: See TracTickets for help on using tickets.