Jump to content

Recommended Posts

We know that soon, a number of functions will be removed from PHP. There are Deprecation Warnings.

 

I would like to make experiments with functions that have already been removed, and that have suitable substitutes. For example, the ereg() family of functions and the split() function have a suitable substitute in the preg_*() family of functions.

 

Was there a simple, common function that was available in the core PHP build that is now actually removed as of PHP 5.4 (PHP 5.5, perhaps?), where another function can be used to simulate it?

 

I was thinking of the mysql_*() functions, but these functions, although deprecated, are made available by simply including the extension in the PHP.INI file (as I understand it). That is, I have the mysqli extension and not the mysql extension loaded. Thus, the mysql_*() family of functions is not available. So I would experiment to see what would happen if I created a 'wrapper' function named mysql_connect() with mysqli_connect() inside.

 

I am wanting to make this kind of experiment with a core function, like split(), that is already removed.

 

 

Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/
Share on other sites

The experiment is to create a "bridge" of functions. Said bridge will allow obfuscated scripts to continue functioning for a while longer.

 

Examine the following scenario (and not an invitation to berate the wisdom of maintaining the usage of such scripts):

 

An expensive plugin to an established PHP application fulfills a highly desirable necessity. Certain parts of the scripts are obfuscated or encoded (ionCube/Zend). The publisher has been abducted by aliens. It will be required that the servers be maintained, in part, by upgrading PHP to the most recent versions.

 

Instead of the costly process of "re-inventing the wheel", these experiments will want to show that for the removed functions, the ereg() family of functions for a specific example, which are present in the encoded scripts and are still required, a wrapper function having the same name, but actually executing the suggested replacement function (preg_*() family), will allow the application to continue to use the plugin scripts unabated.

 

I have searched the change log and have not found a function that has been removed for which there is a suggested replacement.

 

"Should just update to mysqli, is not that difficult."

 

I fear you have entirely missed my point. PHP will be using the mysqli extension, but the expensive, encoded/obfuscated scripts will not be converted.

Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500238
Share on other sites

I totally get what you are saying, for the people stuck at a server that won't upgrade, bought an expensive script which now has outdated functions. No longer supported and will not be a newer version.

 

I looked into the same thing like a year ago, I was pulling in all the functions included in a script, determine php version and have a list all available functions, for ones no longer there make a substitute function same name that can do a similar task.

 

It seemed like too much work to me covering every possible version and the multitude of functions along with extensions that could or not be supported.

Maybe if there was a few less versions and extensions be a bit easier, is like a mangled web the way it is.

Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500240
Share on other sites

Instead of the costly process of "re-inventing the wheel", these experiments will want to show that for the removed functions, the ereg() family of functions for a specific example, which are present in the encoded scripts and are still required, a wrapper function having the same name, but actually executing the suggested replacement function (preg_*() family), will allow the application to continue to use the plugin scripts unabated.

Note that the recommended replacement is not always a simple "just use this instead" type of replacement. For example, ereg and split used an entirely different regex engine with different conventions compared to preg. You can't just pass in whatever regex was given to ereg into preg_match and call it a day. You'd have to parse the expression and convert it into a valid preg expression.

 

In general PHP has not really removed much to day, rather just deprecated the functions. The few functions that have been removed are ones that probably nobody used anyway, such as the functions to obtain the logo GUIDs

 

As far as I am aware, probably the only ones currently that are gone that an old script might used would be the session_is_registered/session_register/session_unregister functions.

 

In all honesty, if you have to maintain a script that requires an older version of PHP, you just have to run an older version of PHP. Either fix the script, or don't upgrade.

Edited by kicken
Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500244
Share on other sites

Another thing: there's more to it than just the functions. Like INI settings have changed, and functions have different sets of arguments. You can't really do anything to protect yourself from that.

 

Honestly, the best thing is to just stay on an old version of PHP until the code is ready to upgrade.

Edited by requinix
Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500247
Share on other sites

"is not always a simple 'just use this instead'"

 

Hence the experiments of using a wrapper.

 

"Either fix the script, or don't upgrade."

 

Can't fix the script, must upgrade. Hence the experiments.

 

"Honestly, the best thing..."

 

Thank you for your comments, responses, and replies. But I was looking for an actual answer.

 

And so, since I can't find a function that's already been removed for which there is a suitable substitute (even when some massaging of the passed parameters is expected for the actual function or short algorithm), nor is anyone else able to actually make mention of such a function, I will have to experiment with the mysql functions. Not ideal as I was looking for a core function.

Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500266
Share on other sites

must upgrade.

Why? What is forcing you to upgrade? If this code is so important, there should be no reason why you're forced to do something which would potentially make it non functional.

 

 

And so, since I can't find a function that's already been removed for which there is a suitable substitute

You've already been given a few.

 

like import_request_variables() or session_register().

would be the session_is_registered/session_register/session_unregister functions.

They do not have replacement functions, but they do have compatibility code that can be written (to a point).

Link to comment
https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500284
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.