Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Let's decide what's actually going into 4.6
There is no official way for that. In that situation you probably don’t use the safe_ functions for the second DB and use only PHP mysql_ functions (where you specify which DB link to use), so either you keep it as is or switch to using mysqli_ functions if your hosting setup requires it.
Offline
Re: Let's decide what's actually going into 4.6
ruud wrote #294644:
switch to using mysqli_ functions if your hosting setup requires it.
What should I replace global $DB; mysql_select_db($DB->db); with to make it both 4.5 and 4.6 compatible? It’s in a plugin, so hosting-independent.
Edit: could there be a safe_ function for this?
Last edited by etc (2015-09-10 12:08:21)
Offline
Re: Let's decide what's actually going into 4.6
ruud wrote #294638:
The mysqli stuff shouldn’t break many plugins.
This is pretty much what I’m getting at – it won’t be the end of days in Pluginland (it’s a place, really) if/when mysqli stuff is brought into play, but in the absence of a reasonably up-to-date or comprehensive list of all Textpattern plugins, supported or not, it’s an unknown quantity as to how many plugins will break. The high profile/active plugin developers around here will no doubt be on the case with modifications and updates as needed, which is encouraging, but other niche plugins might cause a problem.
How about this – make a mysqli-test branch on Textpattern with the mysqli stuff and then test it against the top twenty plugins from the most active threads in the plugin forum. A few testers could divvy up the work of the top twenty, report back, and then snag some more plugins as time/energy/motivation permits.
Offline
Re: Let's decide what's actually going into 4.6
etc wrote #294645:
What should I replace
global $DB; mysql_select_db($DB->db);with to make it both 4.5 and 4.6 compatible? It’s in a plugin, so hosting-independent.
Pseudo-code:
if (version_compare(get_pref('version'), '4.6', '>=')) {
mysqli_select_db($DB, 'dbname');
} else {
mysql_select_db('dbname');
}
Edit: could there be a
safe_function for this?
No. There isn’t one.
Offline
Re: Let's decide what's actually going into 4.6
gaekwad wrote #294671:
How about this – make a
mysqli-testbranch on Textpattern with the mysqli stuff and then test it against the top twenty plugins from the most active threads in the plugin forum. A few testers could divvy up the work of the top twenty, report back, and then snag some more plugins as time/energy/motivation permits.
It’s much easier than that. Just install the plugins in your current 4.5.7 TXP install, edit the plugin, search for “mysql_” functions. If you don’t find the string “mysql_” anywhere in the plugin, it’ll probably work in 4.6 (apart from the tag registry stuff, but for now that’s just a warning in debug mode).
Offline
Offline
Re: Let's decide what's actually going into 4.6
Turns out it’s a lot easier to check this reliably:
global $DB;
if (is_object($DB->link)) {
// use mysqli_
} else {
// use mysql_
}
This works because $DB->link is a resource when using mysql_ functions, but it’s an object when using mysqli_;
Offline
Offline
Re: Let's decide what's actually going into 4.6
We’ll have to find another trick if/once we switch to PDO instead of mysqli ;)
Offline