Make WordPress Core

Opened 22 years ago

Closed 22 years ago

#328 closed defect (bug) (fixed)

Problem with posting and setting the category

Reported by: anonymousbugger Owned by: matt
Priority: normal Milestone:
Component: Administration Version:
Severity: major Keywords:
Cc: Focuses:

Description

I just installed the latest CVS and noticed a problem with the way the Post is assigned to a category.
In post.php on line 48 the new ID is fetched from the database. The problem is that the ID field is auto-incrementing.
Example:
If you delete three posts the highest ID in the posts table will decreace to 15 for example BUT the next value assigned to a new inserted row will be 19 (via auto_increment).
The select statement returns 16 (15+1) although it should be 19.
I fixed this problem the following way, but maybe there is an easier one.

I changed

$post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1") + 1;

to

$id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->posts'");
$post_ID = $id_result->Auto_increment;

This way I always get right ID for the post

Change History (2)

#2 @matt
22 years ago

  • fixed_in_version1.3
  • Owner changed from anonymous to matt
  • Resolution 1020
  • Status newclosed

Already fixed.

Note: See TracTickets for help on using tickets.