Opened 14 years ago
Closed 11 years ago
#16756 closed enhancement (fixed)
PHP5-port - Access Violations on wpdb::$prefix
Reported by: | hakre | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Database | Keywords: | has-patch |
Focuses: | Cc: |
Description
The to be accessed privately member wpdb::$prefix
is accessed publicly in multiple places.
This would do fatal errors if the property would be ported to PHP 5 with the documented behavior.
The errorneous usage in the places in question might reveal that implementation details were missed because the prefix can differ on multi-site setups which is not technically guaranteed when accessing the private member.
The private member was only used "read-only" inside the class. Probably this is a documentation issue. It's set set_prefix()
and set_blog_id()
functions (only) and always to the result of wpdb::get_blog_prefix()
.
Attachments (2)
Change History (19)
#1
@
14 years ago
The second one is just for the case that it might be argued that this is issue with documentation (instead with the code). However I do not recommend to use it.
#8
@
11 years ago
- Keywords close added; has-patch removed
- Resolution set to maybelater
- Status changed from reviewing to closed
Closing as maybe later. See: http://make.wordpress.org/core/2011/03/23/code-refactoring/
#11
@
11 years ago
- Keywords has-patch added
- Milestone set to 3.7
- Resolution maybelater deleted
- Status changed from closed to reopened
16756.2.patch looks like a valid inline documentation fix to me.
#13
follow-up:
↓ 14
@
11 years ago
We also have $wpdb->get_blog_prefix() (with no arguments). Maybe all usage of $wpdb->prefix should start wrapping that function — potentially even having it set via a magic getter. (They essentially are already linked, any methods that change the prefix sets $wpdb->prefix.)
At that point, should $wpdb->prefix even be recommended? I'd wonder if keeping it as @access private (as in, "please don't use it") is OK.
I dunno, maybe ryan has an opinion as the two of us shaped a lot of this back in 3.0.
Use of get_blog_prefix()