Skip to content

Switched to the mysqli API#5

Merged
fplanque merged 2 commits intob2evolution:masterfrom
keithbowes:mysqli
Jun 29, 2015
Merged

Switched to the mysqli API#5
fplanque merged 2 commits intob2evolution:masterfrom
keithbowes:mysqli

Conversation

@keithbowes
Copy link
Contributor

A patch to switch from the legacy mysql API (which will be removed from future versions of PHP) to the new mysqli API.

@fplanque
Copy link
Contributor

Ah great! This is definitely something we want :)

How long have you tested this?
How confident are you about the stability of this?
I'm asking because we're close to releasing v6 stable and it's a delicate time to introduce important changes ;)

Thanks!

@keithbowes
Copy link
Contributor Author

I've been using it on my local server for a couple months. Reading and writing posts and comments, changing settings, etc. work just fine. I was assuming you'd want to put this in the i8 branch, but if you want it for v6, I suppose you could create a new branch, pull this into the new branch, and do whatever testing needs to be done before merging it with master.

In general, this was just replacing mysql_ with mysqli_ and MYSQL_ with MYSQLI_. The other two man things were:

  1. The database handle goes as the first argument instead of the last in the mysqli_* functions.
  2. The database handle is an object instead of a resource ($obj = mysqli_connect(...) and $obj = mysqli_init() are just procedural wrappers around $obj = new mysqli(...) and $obj = mysqli::init()). This meant changing checks of is_resource() to is_object().

fplanque added a commit that referenced this pull request Jun 29, 2015
Switching to the mysqli API contributed by keithbowes
@fplanque fplanque merged commit af38a01 into b2evolution:master Jun 29, 2015
@keithbowes
Copy link
Contributor Author

I suppose mysqli_kill() couldn't hurt. I wasn't familiar with it. The original DB class didn't close the MySQL connections at all. I suppose that was part of the limitation of the PHP 4-style classes that didn't allow destructors. I added mysql_close() hoping that that would reduce the frequency of exceeding the maximum database connections and I just changed that to mysqli_close() in the mysqli conversion. It would probably be best to only use mysqli_kill() for non-persistent connections. IIRC, mysqli_close() only reduces the reference count of persistent connections.

@keithbowes keithbowes deleted the mysqli branch July 29, 2015 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants