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.