Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Uhura! on March 26, 2024, 03:55:16 PM

Title: Help please! Call to undefined function create_function()
Post by: Uhura! on March 26, 2024, 03:55:16 PM
I get this error when attempting to access Admin on my site: Call to undefined function create_function()

Any advice?

Title: Re: Help please! Call to undefined function create_function()
Post by: Aleksi "Lex" Kilpinen on March 26, 2024, 04:00:08 PM
Your host has updated PHP, and you are not fully compatible with it. If that's the only issue that came up, this might help https://custom.simplemachines.org/index.php?mod=4300

Since you can't get to admin, this might take some maneuvering though.
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 26, 2024, 04:03:37 PM
Hello & thank you, Lex! are you willing to do a quick zoom and screen share with me to show me how to do this?

Is anyone available? I do not want to mess this up. Just 10 mins of your time.
Title: Re: Help please! Call to undefined function create_function()
Post by: vbgamer45 on March 26, 2024, 04:19:22 PM
If not just attach your sources/subs.php
And just need to add it to end of file
before ?>

if (!function_exists('create_function'))
{
function create_function($args, $code)
{
return eval(sprintf('return function(%s) {%s};', $args, $code));
}
}
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 26, 2024, 04:27:20 PM
I could really use a quick lesson on this via zoom & screen share on my end.
Title: Re: Help please! Call to undefined function create_function()
Post by: Aleksi "Lex" Kilpinen on March 27, 2024, 03:59:27 AM
We generally don't do 1 on 1 like that, someone might but most of the team likely will not.
What vbgamer45 suggested, should be fairly easy though - Even easier if you just take a copy of the file from your server, and attach it to your next post so someone else here can do the edits for you.
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 27, 2024, 06:40:23 PM
I am following the directions but I cannot find the board directory. Any advice?
Title: Re: Help please! Call to undefined function create_function()
Post by: Kindred on March 27, 2024, 06:57:04 PM
What board directory?

Go to the location of your forum.
Go into the Sources directory
Find the file named  Subs.php
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 27, 2024, 07:42:19 PM
This one (from the directions)

Manual Installation
This is for if you lose access to the package manager due to an error from a missing create_function():

Copy Subs-CreateFunction.php into your sources directory
Copy install.php to the board directory and execute it (remember to delete it afterwards!)
Equivalent to running the following PHP code
add_integration_function(
    'integrate_pre_include',
    '$sourcedir/Subs-CreateFunction.php
');
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 27, 2024, 07:49:15 PM
Quote from: Aleksi "Lex" Kilpinen on March 27, 2024, 03:59:27 AMWe generally don't do 1 on 1 like that, someone might but most of the team likely will not.
What vbgamer45 suggested, should be fairly easy though - Even easier if you just take a copy of the file from your server, and attach it to your next post so someone else here can do the edits for you.

I cannot locate the Board directory referenced at the link. Any advice?
Title: Re: Help please! Call to undefined function create_function()
Post by: Kindred on March 27, 2024, 08:45:53 PM
It means the base forum directory
Title: Re: Help please! Call to undefined function create_function()
Post by: Sir Osis of Liver on March 27, 2024, 09:53:33 PM
You don't have to mess with code, just downgrade php version to 8.0 in your host control panel.
Title: Re: Help please! Call to undefined function create_function()
Post by: Diego Andrés on March 27, 2024, 10:30:36 PM
create_function was removed in 8.0, so would still have issues.
It would be easier and faster if he just installs the MOD using the Package Manager (https://wiki.simplemachines.org/smf/SMF2.1:Package_manager)
Title: Re: Help please! Call to undefined function create_function()
Post by: Sir Osis of Liver on March 27, 2024, 10:44:30 PM
Hmm, OP has links to two sites in sig, one doesn't load, other is 2.0.19 install.  Shouldn't be having create_function errors in latter, unless from mod.  2.0.19 action=admin loads normally in php 8.0, 8.1, 8.2, 8.3.
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 28, 2024, 03:22:06 PM
Quote from: Sir Osis of Liver on March 27, 2024, 09:53:33 PMYou don't have to mess with code, just downgrade php version to 8.0 in your host control panel.


This may be helpful. I will give it a try
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 28, 2024, 03:22:40 PM
Quote from: Kindred on March 27, 2024, 08:45:53 PMIt means the base forum directory

"Community"?
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 28, 2024, 03:23:22 PM
Quote from: Sir Osis of Liver on March 27, 2024, 10:44:30 PMHmm, OP has links to two sites in sig, one doesn't load, other is 2.0.19 install.  Shouldn't be having create_function errors in latter, unless from mod.  2.0.19 action=admin loads normally in php 8.0, 8.1, 8.2, 8.3.


Untrue & unhelpful
Title: Re: Help please! Call to undefined function create_function()
Post by: Uhura! on March 28, 2024, 03:25:04 PM
Quote from: Sir Osis of Liver on March 27, 2024, 09:53:33 PMYou don't have to mess with code, just downgrade php version to 8.0 in your host control panel.


Darn it!

Lowest avl is 8.1
Title: Re: Help please! Call to undefined function create_function()
Post by: Aleksi "Lex" Kilpinen on March 28, 2024, 03:56:27 PM
Downgrading to 8.0 will not fix this.

If you can go to your hosting control panel and download a copy of your Sources/Subs.php from the forum files to attach to your next post here, I'm sure someone can edit it for you like vbgamer45 suggested.

Quote from: vbgamer45 on March 26, 2024, 04:19:22 PMIf not just attach your sources/subs.php
And just need to add it to end of file
before ?>

if (!function_exists('create_function'))
{
function create_function($args, $code)
{
return eval(sprintf('return function(%s) {%s};', $args, $code));
}
}

Do note though, that 2.0 is officially only supporting PHP versions up to 8.0 - So you should really consider upgrading SMF.
Title: Re: Help please! Call to undefined function create_function()
Post by: Sir Osis of Liver on March 28, 2024, 05:04:03 PM
Quote from: Uhura! on March 28, 2024, 03:23:22 PM
Quote from: Sir Osis of Liver on March 27, 2024, 10:44:30 PMHmm, OP has links to two sites in sig, one doesn't load, other is 2.0.19 install.  Shouldn't be having create_function errors in latter, unless from mod.  2.0.19 action=admin loads normally in php 8.0, 8.1, 8.2, 8.3.


Untrue & unhelpful

Not sure what you're objecting to.  https://ourmomspot.net/community/ loads a 2.0.19 forum.  https://www.ourparentingspot.net/ fails to load.

Just to clarify, there's only one call to create_function in 2.0.19 core, it's an error handler in Errors.php.  The error you're getting when accessing Admin is not being caused by core code, so it must be from a mod or manual edit.

But do what Lex and vbgamer suggested, attach the file and someone will fix it.

Title: Re: Help please! Call to undefined function create_function()
Post by: Steve on March 28, 2024, 06:59:18 PM
@Uhura! - We really don't need back-to-back-to-back-to-back posts in the space of 3 minutes. Posts have an edit button, please use it.