-1

Whenever i add an extension to Magento following error occurs:

Fatal error: Call-time pass-by-reference has been removed in C:\xampp1\htdocs\magento\app\code\community\Bricks\Xmlbrowser\Helper\Data.php on line 39

I am using Magento 1.8.00-alpha1

public function searchFiles($dir, $str, $filesList = array()) {
    $dir = rtrim($dir, '\\\/').DS;
    $files = scandir($dir);
    foreach ($files as $file) {
        if (is_dir($dir.$file)) {
            if (($file != '.') && ($file != '..')) {
                $this->searchFiles($dir.$file, $str, &$filesList);
            }
        }
        else {
            $needToSearch = true;
            if ($this->_file_types && is_array($this->_file_types)) {
                $needToSearch = in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), $this->_file_types);
            }
            if ($needToSearch) {
                $fileContent = file_get_contents($dir.$file);
                if ($needToSearch) {
                    $fileContent = file_get_contents($dir.$file);
                    $result = $this->_case_sensitive? strpos($fileContent, $str) : stripos($fileContent, $str);
                    if ($result !== FALSE) {
                        $filesList[] = $dir.$file;
                    }
                }
            }
        }
        return $filesList;
    }
}
Jürgen Thelen
  • 12,745
  • 7
  • 52
  • 71
  • 1
    possible duplicate of [PHP 5.4 Call-time pass-by-reference - Easy fix available?](http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available) – Jürgen Thelen Sep 18 '13 at 10:15
  • it didn't solved the problem – user2496863 Sep 22 '13 at 11:01
  • My guess would be, that you're running PHP 5.4 or higher, but are using extensions which are not PHP 5.4 compatible, because they still are passing variables by-reference in a call, which is deprecated since PHP 5.0 and raises fatal errors since PHP 5.4. Please post the code around line 39 of this 3rd party extension. Additionally post the declaration of the function, which is gonna be called in line 39. – Jürgen Thelen Sep 22 '13 at 16:19
  • So much thanks to you for showing interest in solving my problem. Since I am a newbie let me know the file whose line no.39 is to be changed. And also send it's location. – user2496863 Sep 24 '13 at 12:36
  • Edit your question and post the code of the file `C:\xampp1\htdocs\magento\app\code\community\Bricks\Xmlbrowser\Helper\Data.php`. Then insert a comment into your posted code indicating which line is line 39. – Jürgen Thelen Sep 24 '13 at 15:10
  • $this->searchFiles($dir.$file, $str, &$filesList); // This line is 39 – user2496863 Sep 24 '13 at 15:49
  • If you could send me the email I will send you the complete file. – user2496863 Sep 24 '13 at 15:56
  • Please post the code of the `searchFiles()` method here on stackoverflow. Your problem probably is the `&` in the 3rd param `&$filesList` of the call. This is a pass-by-reference. Remove the `&` from the 3rd param in the call. Then go to the declaration of `searchFiles()` and change its 3rd param to contain a leading `&` if it's missing. The result should be a valid pass-by-value then. – Jürgen Thelen Sep 25 '13 at 07:00
  • _file_types = array_map('strtolower', $types); return $this; } public function setCaseSensitive($var) { $this->_case_sensitive = (bool)$var; return $this; } – user2496863 Sep 25 '13 at 10:24
  • public function searchFiles($dir, $str, $filesList = array()) { $dir = rtrim($dir, '\\\/').DS; $files = scandir($dir); foreach ($files as $file) { if (is_dir($dir.$file)) { if (($file != '.') && ($file != '..')) { $this->searchFiles($dir.$file, $str, &$filesList); } } else { $needToSearch = true; if ($this->_file_types && is_array($this->_file_types)) { $needToSearch = in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), $this->_file_types); }if ($needToSearch) { $fileContent = file_get_contents($dir.$file); – user2496863 Sep 25 '13 at 10:27
  • if ($needToSearch) { $fileContent = file_get_contents($dir.$file); $result = $this->_case_sensitive? strpos($fileContent, $str) : stripos($fileContent, $str); if ($result !== FALSE) { $filesList[] = $dir.$file; } } } } return $filesList; } – user2496863 Sep 25 '13 at 10:27
  • public function getSearchPlaces() { return array( array( 'label'=>'Core code', 'path'=>Mage::getBaseDir('code').DS.'core' ), array( 'label'=>'Local code', 'path'=>Mage::getBaseDir('code').DS.'local' ), array( 'label'=>'Community code', 'path'=>Mage::getBaseDir('code').DS.'community' ), array( 'label'=>'Frontend views', 'path'=>Mage::getBaseDir('design').DS.'frontend' ), array( 'label'=>'Admin views', 'path'=>Mage::getBaseDir('design').DS.'adminhtml' ) ); } – user2496863 Sep 25 '13 at 10:28
  • public function getFileTypes() { return array( array( 'label'=>'PHP Scripts (*.php)', 'extension'=>'php'), array( 'label'=>'View templaes (*.phtml)', 'extension'=>'phtml'), array( 'label'=>'Config files (*.xml)', 'extension'=>'xml'), array( 'label'=>'MySQL installers (*.sql)', 'extension'=>'sql') ); } } – user2496863 Sep 25 '13 at 10:29
  • The whole file is send in portions. – user2496863 Sep 25 '13 at 10:29
  • I copied the relevant method `searchFiles()` into your post. Please use the `edit` link of your question next time, since long code in comments is nearly unreadable. – Jürgen Thelen Sep 25 '13 at 14:49

1 Answers1

0

First, change

$this->searchFiles($dir.$file, $str, &$filesList); // This line is 39 

to

$this->searchFiles($dir.$file, $str, $filesList); // This line is 39 

Second, change

public function searchFiles($dir, $str, $filesList = array()) {

to

public function searchFiles($dir, $str, &$filesList = array()) {

Third, change the 6th line within the method searchFiles()

$this->searchFiles($dir.$file, $str, &$filesList);

to

$this->searchFiles($dir.$file, $str, $filesList);

This should fix the specific fatal error that you're asking about here.

But...

...even if fixed, most probably just the next fatal error will popup.

Like I aready wrote in the comments, my guess is you're running a PHP 5.4 system, but use Magento 3rd party extensions, which are not PHP 5.4 compatible.

If PHP 5.4 is a must on your target system, I'd recommend to contact the authors of the extensions and ask for 5.4 compatible versions of their extensions, or patches to make them 5.4 compatible. You can of course also try to fix them all by yourself, or hire a developer to do it.

If PHP 5.4 is not mandatory, I'd probably check whether downgrading the system to PHP 5.3.latest won't be the better/cheaper/less time consuming option.

Jürgen Thelen
  • 12,745
  • 7
  • 52
  • 71
  • Ok , What's safe way to convert PHP 5.4 into PHP 5.3 in Magento 1.8.00-alpha1 and XAMPP ver.1.8.3.1. – user2496863 Sep 25 '13 at 15:41
  • Also, note that I am using PHP 5.5.3. – user2496863 Sep 25 '13 at 15:46
  • How did the fix workout for you? Was your issue solved? If so, please consider voting/accepting the answer. – Jürgen Thelen Sep 26 '13 at 07:17
  • Re your new question: you cannot convert 5.4 to 5.3, you need to uninstall XAMPP 1.8.3.1 and install a XAMPP version containing PHP 5.3. I don't know for sure, but if iirc XAMPP 1.7.7 was the last XAMPP version using PHP 5.3.x. Questions about installing software are off-topic here, though. Probably http://superuser.com or http://serverfault.com are better places to ask questions like this. – Jürgen Thelen Sep 26 '13 at 07:18
  • Re PHP 5.5.3: yeah, PHP 5.5.3 won't work either, that's why I wrote PHP 5.4 *or higher*. PHP 5.5.3 also does _not_ allow passing variables pass-by-reference to a call. Solution is the same. Get or make PHP 5.5 compatible versions of the Magento extensions, or downgrade to PHP 5.3. – Jürgen Thelen Sep 26 '13 at 07:23
  • You're still seeing the same fatal error message after changing the source code as advised? Or do you see a new error message? If so, what error message do you see now? – Jürgen Thelen Sep 26 '13 at 14:24
  • Error log record number:250908824 – user2496863 Sep 26 '13 at 15:59
  • That means the specific error you posted here seems to be fixed and now you get a new, different error message. Please open a new question and post that new error message. In case you don't know how to get the new error message: check Magento's `var/report` folder. It should contain a file named `250908824`. Open a new question on stackoverflow, open the report file and copy/paste its error message into your new question. – Jürgen Thelen Sep 27 '13 at 07:02