In fact, this is not true for any version of SMF. In SMF 1.0 and 1.1, it was only two lines. In SMF 2.0, it is four lines. In SMF 2.1 it is fourteen lines.
As a result, if repair_settings.php detects the redirection code in a copy of Settings.php, it deletes the incorrect amount of code. For SMF 1.0 and 1.1, it ends up deleting part of the path correction code, but leaves the file in a usable state. For SMF 2.0, it ends up just deleting a comment line. But for SMF 2.1, it leaves Settings.php in a mangled state.
Instead of a fixed number of lines, we should use a regular expression to find and remove all versions of this block of code. Fortunately, SMF 2.1's version of updateSettingsFile() contains a regular expression to do exactly that. So all we need to do to fix this bug is use preg_replace() with that regular expression. I will submit a PR shortly.
repair_settings.php assumes that the block of code to redirect to install.php is six lines long:
https://github.com/SimpleMachines/tools/blob/b8ff2d1f52b2e138335b47e6b1914eaab0f0fd02/repair_settings.php#L1004-L1014
In fact, this is not true for any version of SMF. In SMF 1.0 and 1.1, it was only two lines. In SMF 2.0, it is four lines. In SMF 2.1 it is fourteen lines.
As a result, if repair_settings.php detects the redirection code in a copy of Settings.php, it deletes the incorrect amount of code. For SMF 1.0 and 1.1, it ends up deleting part of the path correction code, but leaves the file in a usable state. For SMF 2.0, it ends up just deleting a comment line. But for SMF 2.1, it leaves Settings.php in a mangled state.
Instead of a fixed number of lines, we should use a regular expression to find and remove all versions of this block of code. Fortunately, SMF 2.1's version of
updateSettingsFile()
contains a regular expression to do exactly that. So all we need to do to fix this bug is usepreg_replace()
with that regular expression. I will submit a PR shortly.