Bug #835
MyBB, dl(), and PHP 5.3.x - no dl() in many 5.3.x releases
| Status: | Closed | Start date: | 03/30/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Ryan Gordon | % Done: | 100% |
|
| Category: | PHP | |||
| Target version: | 1.4.12 | |||
| Reproducibility: | Always | Database Type: | MySQLi | |
| Reported In MyBB Version: | 1.4.11 | Database Version: | 5.1.40 | |
| PHP Version: | 5.3.1 | SQA assignments: | ||
| Browser: | FireFox |
Description
While working on a plugin recently I was getting white pages which I traced back to dl() trying to load the mysqli extension on line 126 of init.php from 1.4.11.
Upon a little research on php.net I found the following:
"This function has been removed from some SAPI's in PHP 5.3."
Yay. So 5.3.x releases might have dl() removed? How stupid. All because of the flame.so exploit. Screw a pooch.
I guess MyBB needs to check if dl() is available and working and if not load a custom dl() function?
For now since I full control over my local server I've gone in and set enable_dl to On in my php.ini... but I've read that some hosts are turning dl() off because of the exploit I mentioned above.
Related issues
Associated revisions
Fixes MyBB, dl(), and PHP 5.3.x - no dl() in many 5.3.x releases (fixes:835)
History
#1 Updated by Andreas Klauer about 2 years ago
I guess MyBB needs to check if dl() is available
If you want a proper error message about the missing extension instead of a white page, yes.
if not load a custom dl() function?
It's not possible to emulate dl(), so a custom function would serve no purpose.
For now since I full control over my local server I've gone in and set enable_dl to On in my php.ini...
But that's wrong. MyBB shouldn't have to use dl() in the first place. It only does it as an attempt to save your ass when you're on a badly configured hosting. Your PHP should be configured to load the required extensions automatically. So if you are for example using mysqli and xcache, configure your PHP installation accordingly.
#2 Updated by Dylan Myers about 2 years ago
Yup, I made a mistake and it was trying to load mysqli instead of plain mysql when I didn't have the mysqli extension installed. So you're right, it shouldn't have been trying to use dl() at all. But it was. This is what I get for trying to access a remote db without making sure I'm set up to do so. My mistake and I fully admit it ;)
As for not being able to emulate dl() sure you can, there is even code for a local_dl() function on the php.net site that seems to work pretty well. Though I wouldn't call it perfect. Of course, this is a less than optimal solution as well.
But as with many things that have been deprecated perhaps we should just have a simple version check and only try to load if the version is prior to 5.3.0 and if its 5.3.0 it'll fail over to not being able to load.
ie. Wrap lines 119 to 127 in a version compare if statement. Which would pass over that block of code directly to the fail & error message below it. This is even more important for PHP6 if it ever gets here, since dl() will be completely removed. Perhaps it isn't critical for the 1.4.x tree, but I would hope the 1.6.x tree implements some kind of check for this.
#3 Updated by Andreas Klauer about 2 years ago
As for not being able to emulate dl() sure you can, there is even code for a local_dl() function on the php.net site that seems to work pretty well.
I couldn't find a local_dl(). Do you mean dl_local() from the comment section? If you look closely, it contains this:
//now we execute dl() to actually load the module
if( !dl( $finalExtPath ) ) { die(); }
So it's just a wrapper that won't work without dl(). It can't be emulated.
Even if it was possible, there should be no need to go that far for something that should not be necessary in the first place.
If an extension is missing, it's the PHP configuration that's broken, not MyBB. All MyBB should do in such a case is show an error message, as a white page is kind of hard to debug...
#4 Updated by Dylan Myers about 2 years ago
Andreas Klauer wrote:
As for not being able to emulate dl() sure you can, there is even code for a local_dl() function on the php.net site that seems to work pretty well.
I couldn't find a local_dl(). Do you mean dl_local() from the comment section? If you look closely, it contains this:
[...]
So it's just a wrapper that won't work without dl(). It can't be emulated.
Even if it was possible, there should be no need to go that far for something that should not be necessary in the first place.
If an extension is missing, it's the PHP configuration that's broken, not MyBB. All MyBB should do in such a case is show an error message, as a white page is kind of hard to debug...
Yes, that is what I was referring to. There was a couple different versions in it, and I didn't see that in the one I looked at. I guess I misunderstood, I thought the person posting was suggesting it as an alternative to dl() because of the issues with dl(). So we come back to the error message. Which is fine. Better than a white page. :)
#5 Updated by Ryan Gordon about 2 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Applied in changeset r4852.
#6 Updated by Ryan Gordon about 2 years ago
- Assignee set to Ryan Gordon
- Target version set to 1.4.12
#7 Updated by Ryan Gordon about 2 years ago
We shouldn't be using dl anyway to makeup for hosts lack of ability
#8 Updated by Stefan T. about 2 years ago
- Status changed from Resolved to Closed