Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0]: Config quirks #8293

Open
sbulen opened this issue Jul 17, 2024 · 9 comments
Open

[3.0]: Config quirks #8293

sbulen opened this issue Jul 17, 2024 · 9 comments

Comments

@sbulen
Copy link
Contributor

sbulen commented Jul 17, 2024

Basic Information

  1. In Windows, Settings.php is being reloaded constantly, mainly due to it's not being found in a get_included_files() check. This is due to the different DIRECTORY_SEPARATORs between Windows & linux.
  2. eval returns null, which can result in null being assigned to a setting under some circumstances. E.g., attempting an upgrade, received the following error:

image

Steps to reproduce

  1. Install 2.1.4
  2. Upgrade to 3.0

Expected result

A 3.0 forum

Actual result

WSOD error

Version/Git revision

4.0 Alpha 2 - current GH

Database Engine

All

Database Version

8.4.0

PHP Version

8.3.8

Logs

Fatal error: Uncaught TypeError: Cannot assign null to property SMF\Config::$languagesdir of type string in D:\wamp64\www\84van30\Sources\Config.php:915 Stack trace: #0 D:\wamp64\www\84van30\Sources\Config.php(886): SMF\Config::set(Array) #1 D:\wamp64\www\84van30\upgrade.php(188): SMF\Config::load() #2 {main} thrown in D:\wamp64\www\84van30\Sources\Config.php on line 915

Additional Information

No response

@sbulen
Copy link
Contributor Author

sbulen commented Jul 17, 2024

I'm using my WAMP...

I think at least part of the problem is directory separators... It keeps thinking things aren't loaded...
image

@sbulen
Copy link
Contributor Author

sbulen commented Jul 17, 2024

I believe the rest of the issue is that eval() is used in Config.php against the definition default value strings.
But... eval() RETURNS NULL unless there is an explicit return in the eval'd code...

self::${$var} = eval($default . ';');

Using double quotes, ", will likely work better.

@sbulen
Copy link
Contributor Author

sbulen commented Jul 17, 2024

Lots of options on the DIRECTORY_SEPARATOR question...

Option 1: Bite the bullet & use DIRECTORY SEPARATOR consistently throughout; never hardcode '/' again... Ensure folder settings are OS-appropriate.

Proper solution. Least fun. Like having a paladin on the team.

Option 2: At runtime, normalize important paths to unix '/', but the OS-sensitive functions, e.g., get_included_files(), won't work. We'd have to write our own wrappers around them. Note that Windows honors '/' in paths, but uses '\' in return calls like get_included_files(). Least effort, feels almost clean. Most consistent with past SMF behavior.

Option 3: At runtime, normalize important paths to DIRECTORY_SEPARATOR so they work better with OS-sensitive functions. Feels a bit more hackish, though to be honest, likely cleaner than option 2.

Implications here with repair_settings.php also. Likely other utilities.

@sbulen
Copy link
Contributor Author

sbulen commented Jul 18, 2024

I've confirmed the following works to fix the eval issue:
self::${$var} = eval('return ' . "$default;");

@sbulen sbulen changed the title [3.0]: Upgrader: Uncaught TypeError: Cannot assign null to property [3.0]: Windows quirks Jul 18, 2024
@sbulen sbulen changed the title [3.0]: Windows quirks [3.0]: Config quirks Jul 18, 2024
@jdarwood007
Copy link
Member

In Windows, Settings.php is being reloaded constantly, mainly due to it's not being found in a get_included_files() check. This is due to the different DIRECTORY_SEPARATORs between Windows & linux.

Should we stop using the hard-coded / and replace all instances with DIRECTORY_SEPARATOR?

@Sesquipedalian
Copy link
Member

Should we stop using the hard-coded / and replace all instances with DIRECTORY_SEPARATOR?

Yes, we should.

@sbulen
Copy link
Contributor Author

sbulen commented Jul 18, 2024

So it's confirmed we have a paladin on the team.

Now, or after the installer/upgrader rewrite gets merged?

@Sesquipedalian
Copy link
Member

After.

@live627
Copy link
Contributor

live627 commented Jul 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants