Opened 21 years ago
Closed 21 years ago
#328 closed defect (bug) (fixed)
Problem with posting and setting the category
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | |
| Component: | Administration | Keywords: | |
| Focuses: | Cc: |
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
Already fixed.