Opened 8 years ago
Closed 8 years ago
#37683 closed defect (bug) (fixed)
$collate and $charset can be undefined in wpdb::init_charset()
Reported by: | robsat91 | Owned by: | pento |
---|---|---|---|
Milestone: | 4.6.1 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Database | Keywords: | has-patch fixed-major |
Focuses: | Cc: |
Description
Hello!
After updating from 5.3.1 to 4.6 i got an error:
Notice: Undefined variable: collate in /Users/robert/Nettsider/wp/ehc-wordpress/webroot/wordpress/wp-includes/wp-db.php on line 752
It seems that the reason for the error is that i did not set the constant "DB_COLLATE" in wp-config.php. This worked before, but not in 4.6.
Is there some issue with fallback values if some constants are not set maybe?
Best regards, Robert Sather.
Attachments (2)
Change History (16)
#1
@
8 years ago
- Component changed from General to Database
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.6.1
#2
@
8 years ago
Wow, that was fast.
Perfect, thanks mate! :)
Good job with 4.6 btw, noticing the speed increase already!
#3
@
8 years ago
- Summary changed from Getting "Notice: Undefined variable: collate" after update to 4.6 to $collate and $charset can be undefined in wpdb::init_charset()
Introduced in #36917.
Another report mentions that is also happens for $charset
.
#4
@
8 years ago
- Keywords has-patch added; needs-patch removed
Attached a possible fix that only runs determine_charset
when a charset and collate isset.
#5
@
8 years ago
- Owner set to pento
- Status changed from new to assigned
The patch resolves the issue for me.
@pento Leaving final review to you. Feel free to commit afterwards.
#6
@
8 years ago
- Keywords needs-refresh added
Thanks for the patch, @Frozzare!
I think a better solution would be to set $charset
and $collate
to empty strings at the start of ::init_charset()
. ::determine_charset()
should be called, even when $collate
is not set, as the collation can change based on the charset. It doesn't really matter either way if the method is called when $charset
is empty, I'm inclined to call it just to not increase code complexity.
Also, $this->charset
and $this->collate
need to be set, even when the local vars are empty, or similar warnings will occur in ::set_charset()
.
Finally, a note to committers: please don't commit any patches on this ticket without my review - #37689 may be related, which I'm currently investigating. The outcome of that ticket may have an effect on the best solution for this ticket.
Thanks for the bug report, @robsat91!
You're correct, this warning will occur if
DB_COLLATE
isn't set - we'll get this fixed up it 4.6.1.