Project

General

Profile

Actions

Bug #29252

closed

Rewriting localconf.php endlessly expands lines with values containing two subsequent slashes ("//")

Added by Andreas Groth about 13 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2011-08-25
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.4
PHP Version:
5.2
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

When the file localconf.php gets rewritten, and an extension's configuration value contains two subsequent slashes ("//"), the part from after the slashes until rest of the line is placed at the end of the newly generated comment. This is repeated each time localconf.php is written, so the comment is extended again and again. The rewriting does not take into account that "//" can be part of a value, but thinks that everything after the first "//" is.

This is no error but more a cosmetic problem. The comment can also be cut by editing the localconf.php, but otherwise the file may bloat unnoticed over time.

As far as I have seen, the problem can be corrected in the file t3lib/class.t3lib_install.php, in the function setValueInLocalconfFile()
where it says
$subparts = explode('//', $mainparts[1], 2);
The third parameter ("2") should be increased by the number of occurrences of "//" in the value (available in $value), and the subsequent uses of $subparts[1] should be replaced by end($subparts). Alternatively, "backslashing" the "/"s could work.


Files

bug_29252.diff (2.49 KB) bug_29252.diff Andreas Groth, 2011-09-13 12:29
Actions #1

Updated by Steffen Gebert about 13 years ago

Thanks for your report!

Could you provide a patch for that?

Actions #2

Updated by Xavier Perseguers about 13 years ago

I'm not sure this is only a cosmetic problem. Actually I know of a website where localconf.php is corrupted each time something is written to localconf.php due to a breakline added in the middle of a serialized string.

Did not investigate very further but this sounds quite similar.

Actions #3

Updated by Andreas Wolf about 13 years ago

  • Category set to Backend API
  • Complexity set to medium
Actions #4

Updated by Xavier Perseguers about 13 years ago

Updating an extension breaks localconf.php:

$TYPO3_CONF_VARS['EXT']['extConf']['templavoila'] = 'a:1:{s:7:"enable.";a:3:{s:13:"oldPageModule";s:1:"0";s:19:"selectDataStructure";s:1:"0";s:15:"renderFCEHeader";s:1:"0";}}';        // Modified or inserted by TYPO3 Extension Manager.
ataStructure";s:1:"0";}}';        // Modified or inserted by TYPO3 Extension Manager.
Actions #5

Updated by Andreas Groth about 13 years ago

I attach a patch for t3lib/class.t3lib_install.php, function setValueInLocalconfFile(), and give some explanations. I'm not using git/gerrit for now...

Expected behaviour:
The function should find the line with the variable assignement, and replace it with a new line that contains assignment of the new value to the variable, and a one-line comment consisting of the note "Modified or updated by <$this->updateIdentity>" plus any previous comment text that is different from this note. This preserves update notes from a different 'updateIdentity', and user comments.

Solution:
The "rest of the line line" part (equal sign, value, comment) is extended into a valid PHP code line. token_get_all() is used to get the comment. The first element of the token array that is a comment is regarded to be our old comment. (The solution I suggested initially does not work, because the value of $value is different from the actual value in the line.) The patch may also resolve the issue in note #4, but I am not sure.

Added functions:
- If it is a single line comment (starting with '//', as produced by this routine), it's length is cut to 997 characters.
- In addition to removing any duplicates of the new note, line feed characters and PHP end markers are removed to be sure that we produce valid PHP code.

Patch:
The attached file is a patch for TYPO3 4.4.10, but should be applicable to other versions.

Actions #6

Updated by Mr. Hudson about 13 years ago

Patch set 1 of change I58d392025d88af58ea1c069fef050251da5859ee has been pushed to the review server.
It is available at http://review.typo3.org/5235

Actions #7

Updated by Mr. Hudson about 13 years ago

Patch set 2 of change I58d392025d88af58ea1c069fef050251da5859ee has been pushed to the review server.
It is available at http://review.typo3.org/5235

Actions #8

Updated by Gerrit Code Review almost 13 years ago

  • Status changed from New to Under Review

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/5235

Actions #9

Updated by Gerrit Code Review over 12 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/5235

Actions #10

Updated by Stefan Neufeind almost 12 years ago

The review for master was abandoned since 6.0 (master at that time) didn't have a localconf.php anymore.
But it still applies to 4.5 until 4.7 and is not yet fixed there! So please consider submitting it for these branches.

Actions #11

Updated by Wouter Wolters over 10 years ago

  • Status changed from Under Review to Closed
  • Is Regression set to No

Will not be done anymore for 4.5

Actions

Also available in: Atom PDF