## $file kills setup script It is possible to change important and used variables inside the setup model while installing I implemented a data-setup script today. It starts with defining a variable: $file = 'var/import/sample.csv';


# The error

When magento was called, I got this error:

[message:protected] => Warning: Illegal string offset 'toVersion'  in app/code/core/Mage/Core/Model/Resource/Setup.php on line 641
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => app/code/core/Mage/Core/functions.php
[line:protected] => 245
[trace:Exception:private] => Array
[...]


I opened the Setup model and found this code snippet:

foreach ($files as$file) {
[...]
try {
switch ($fileType) { case 'php':$conn   = $this->getConnection();$result = include $fileName; break; [...] } if ($result) {
$this->_setResourceVersion($actionType, $file['toVersion']); } } catch (Exception$e) {
[...]
}
[...]
}


# Conclusion

Be careful with defining variables in setup scripts. I wanted to write a "bugfix" but thinking 10 minutes about the problem didn't develope a solution for the problem. There is no possibility in PHP to prevend the overwrite of this variable.

HAH! There is. I thought about changing the scope but didn't find a simple solution. but just implementing a method should do it!

Blog writing brings solutions. Thanks audience for help.

Hopefully you all know, what Rubber ducking is?