Skip to content

Conversation

@bramley
Copy link
Contributor

@bramley bramley commented Jul 31, 2021

Currently the config.php file can be read more than once, which causes php notices about multiple definitions, e.g.

 PHP Notice: Constant UPLOADIMAGES_DIR already defined in /opt/lampp/htdocs/tiedotteet/config/config.php on line 28

This can cause the response to the browser to be corrupted when display errors is enabled. This was reported in the user forum https://discuss.phplist.org/t/automatic-update-from-3-6-2-to-3-6-3-fails/7546 and a GitHub issue phpList/phplist3#783

This change is to read config.php once in the constructor and store the few settings that are needed.

A second commit is to correct the handling of the result of PDO fetch() to avoid another php warning.

PHP Notice: Undefined index: update_in_progress in /opt/lampp/htdocs/tiedotteet/updater/index.php on line 360

Currently the wrong column name is being referenced.

@michield
Copy link
Member

michield commented Aug 2, 2021

You could also just change all "include" lines to "include_once"

@bramley
Copy link
Contributor Author

bramley commented Aug 2, 2021

Currently the include statements are within functions, which means that the variables are visible only within the function. Using include_once would mean that the variables would not exist for the second and subsequent calls.

We could move the include statement to be at global scope, outside of the class. Doing that though would need changing the code to refer to the global variables instead of the local variables, so a similar number of changes to this one.

@michield
Copy link
Member

michield commented Aug 6, 2021

Ah, true, it's all in the scope, makes sense.

@michield michield merged commit 0c05dfa into phpList:master Aug 6, 2021
@bramley bramley deleted the read_config_file branch March 11, 2022 08:26
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