Zen Cart Logo
Forums / General Questions / Excel Populate gives 500 server error for Populate from file

Excel Populate gives 500 server error for Populate from file

Views: 936

Results 1 to 9 of 9
25 Feb 2016, 3:47 PM
#1
hp09 avatar

hp09

New Zenner

Join Date:
Feb 2016
Location:
Colorado
Posts:
34
Plugin Contributions:
0

Excel Populate gives 500 server error for Populate from file

I just installed Zencart 1.54 (fresh install using the test db) and wanted to try the plugin Excel Populate. Does it work with 1.54? It installs ok and exports an Excel file, but if I try to "populate from file", I get a 500 server error. My server is unsing PHP 5.6. I set the Excel file permissions to 777.
Any ideas?
Thanks.

26 Feb 2016, 6:33 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Excel Populate gives 500 server error for Populate from file

Excel file permissions to 777
You can try "755"

26 Feb 2016, 10:47 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Excel Populate gives 500 server error for Populate from file

Many servers may not like/allow other than 644.

26 Feb 2016, 2:20 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Excel Populate gives 500 server error for Populate from file

Check your store's /logs folder for any myDEBUG-adm-*.log file that identifies the details of the error. Remember, though, if you post that log-file's contents, that your secret admin folder name will be "called out" in that information so you'll want to xxx-it-out before posting.

2 Mar 2016, 11:33 PM
#5
hp09 avatar

hp09

New Zenner

Join Date:
Feb 2016
Location:
Colorado
Posts:
34
Plugin Contributions:
0

Re: Excel Populate gives 500 server error for Populate from file

The log file shows:
[25-Feb-2016 20:14:06 America/Los_Angeles] PHP Notice: Undefined index: in .../includes/excel/oleread.inc on line 138

Line 138 is:
$sbdBlock = $this->bigBlockChain[$sbdBlock];

What does this mean?

20 Feb 2019, 12:01 AM
#6
jsimoes1997 avatar

jsimoes1997

New Zenner

Join Date:
Feb 2019
Location:
Portugal
Posts:
5
Plugin Contributions:
0

Re: Excel Populate gives 500 server error for Populate from file

I have had the same problem, that when I try to populate an excel file it is giving me 500 error, in the debug file the error it gives me is the following:

[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Notice: Undefined index: in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 138
[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Notice: Undefined index: in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 138
[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 27

[18-Feb-2019 15:59:46 America/Los_Angeles] Request URI: /store/Admin/excel.php?action=populate&filename=products_20190218152224.xls, IP address: 176.79.128.18
--> PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 27.

line 27 of my file is where the return is:

function GetInt4d($data, $pos) {
        return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); 
}

line 138 of my file is:

while ($sbdBlock != -2) {
	      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
	
	      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
	        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
	        $pos += 4;
	        $index++;
	      }
	
	      $sbdBlock = $this->bigBlockChain[$sbdBlock]; // line 138
}

I would like to know how to fix the problem.
Thanks.

22 Feb 2019, 5:34 AM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Excel Populate gives 500 server error for Populate from file

jsimoes1997:

I have had the same problem, that when I try to populate an excel file it is giving me 500 error, in the debug file the error it gives me is the following:

[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Notice: Undefined index: in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 138
[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Notice: Undefined index: in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 138
[18-Feb-2019 15:59:46 America/Los_Angeles] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 27

[18-Feb-2019 15:59:46 America/Los_Angeles] Request URI: /store/Admin/excel.php?action=populate&filename=products_20190218152224.xls, IP address: 176.79.128.18
--> PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 27.

line 27 of my file is where the return is:

function GetInt4d($data, $pos) {
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
}

> line 138 of my file is:
> 
> ```
while ($sbdBlock != -2) {
	      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
	
	      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
	        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
	        $pos += 4;
	        $index++;
	      }
	
	      $sbdBlock = $this->bigBlockChain[$sbdBlock]; // line 138
}

I would like to know how to fix the problem.
Thanks.
Looks like during execution data being sent to or available from the GetInt4d function is not "neatly" always 4 characters at the end of the data to be processed. Not sure if this will resolve the issue; however, suggest trying:

function GetInt4d($data, $pos) {
        for ($i = 0; $i < 4; $i++) {
            if (!isset($data[$pos + $i])) {
              $data[$pos + $i] = '';
            }
        }
        return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); 
}

line 138 of my file is:

while ($sbdBlock != -2) {
	      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
	
	      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
	        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
	        $pos += 4;
	        $index++;
	      }
	
              if (!(isset($this->bigBlockChain[$sbdBlock]) || in_array($sbdBlock, $this->bigBlockChain))) {
                  break; // Leave the loop if the array key does not exist testing against first if the location has a value other than null then if it is null to see if the specific key is in the array allowing operation to continue if the key exists.
              }
	      $sbdBlock = $this->bigBlockChain[$sbdBlock]; // line 138
}

Perhaps could try the change to the first code block before applying the change to the second code block. Not sure the impact of operation downstream from this change as there appears to be an expectation that $sbdBlock is equal to -2 at the completion of this loop by modifying other variables. I also haven't downloaded and reviewed the previously provided zip file to see what is affected downstream. It may be that the code had been written to try to take advantage of earlier php style execution that treated missing array keys in a particular way instead of ensuring that all data was present for processing.

22 Feb 2019, 10:51 PM
#8
jsimoes1997 avatar

jsimoes1997

New Zenner

Join Date:
Feb 2019
Location:
Portugal
Posts:
5
Plugin Contributions:
0

Re: Excel Populate gives 500 server error for Populate from file

mc12345678:

Looks like during execution data being sent to or available from the GetInt4d function is not "neatly" always 4 characters at the end of the data to be processed. Not sure if this will resolve the issue; however, suggest trying:

function GetInt4d($data, $pos) {
for ($i = 0; $i < 4; $i++) {
if (!isset($data[$pos + $i])) {
$data[$pos + $i] = '';
}
}
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
}

> line 138 of my file is:
> 
> ```
while ($sbdBlock != -2) {
	      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
	
	      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
	        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
	        $pos += 4;
	        $index++;
	      }
	
              if (!(isset($this->bigBlockChain[$sbdBlock]) || in_array($sbdBlock, $this->bigBlockChain))) {
                  break; // Leave the loop if the array key does not exist testing against first if the location has a value other than null then if it is null to see if the specific key is in the array allowing operation to continue if the key exists.
              }
	      $sbdBlock = $this->bigBlockChain[$sbdBlock]; // line 138
}

Perhaps could try the change to the first code block before applying the change to the second code block. Not sure the impact of operation downstream from this change as there appears to be an expectation that $sbdBlock is equal to -2 at the completion of this loop by modifying other variables. I also haven't downloaded and reviewed the previously provided zip file to see what is affected downstream. It may be that the code had been written to try to take advantage of earlier php style execution that treated missing array keys in a particular way instead of ensuring that all data was present for processing.

In the debug file gives me this error:

[22-Feb-2019 14:42:18 America/Los_Angeles] PHP Notice:  Undefined index:  in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 175
[22-Feb-2019 14:42:18 America/Los_Angeles] PHP Notice:  Undefined index:  in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 175
[22-Feb-2019 14:42:18 America/Los_Angeles] PHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 65798145 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 173

[22-Feb-2019 14:42:18 America/Los_Angeles] Request URI: /store/Admin/excel.php?action=populate&filename=products_20190218152224.xls, IP address: 176.79.128.18
--> PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 65798145 bytes) in /opt/bitnami/apache2/htdocs/store/Admin/includes/excel/oleread.inc on line 173.

I made the changes and now it's the error on line 173.

     function __readData($bl) {
        $block = $bl;
        $pos = 0;
        $data = '';
        
        while ($block != -2)  {
            $pos = ($block + 1) * BIG_BLOCK_SIZE;
            $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
            //echo "pos = $pos data=$data\n";	
	    $block = $this->bigBlockChain[$block];
        }
		return $data;
     }

If it is possible to send the file with which it is not giving an error.

Thank you

23 Feb 2019, 1:15 AM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Excel Populate gives 500 server error for Populate from file

Assuming that the file being processed is properly formatted for this plugin including whatever line endings may be expected or other information, then I would suggest doing in this while loop, the same thing that was done in the second set of code provided a few pages back. Thing is I'm not familiar with this code and have no idea if these changes are going to result in a successful run or not.

So, would suggest, right or wrong, for this section of code to be similar to the following:

     function __readData($bl) {
        $block = $bl;
        $pos = 0;
        $data = '';
        
        while ($block != -2)  {
            $pos = ($block + 1) * BIG_BLOCK_SIZE;
            $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
            //echo "pos = $pos data=$data\n";
            if (!(isset($this->bigBlockChain[$block]) || in_array($block, $this->bigBlockChain))) {
              break;
            } 	
	    $block = $this->bigBlockChain[$block];
        }
		return $data;
     }

Apologies if the above code has "#"s in it. I copied and pasted the code which may result in them being present where a space would be expected.

So, something that still seems a little off is that it almost seems as if the code is expecting a particular sequence of information that would be or resolve to -2. I don't know what that is/was supposed to be, but sometime after the code was written, something is not quite right. This effort may resolve to nothing legible.