Download & Extend

recursive loop when portfolio has a comma

Project:Stock
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Trying this module out and used a list of symbols with a comma delimiter (whoops). This caused the function stockapi_load in the stockapi to go into an infinite loop. In the stockapi_load function I modified this line

$stock = stockapi_load($symbol);

to

$stock = stockapi_load($stock[0]);

but perhaps the stock.module needs to clean the symbols or modified to use different delimiters? Thanks.

Comments

#1

Your suggestion didn't work for me. I'm sure there's a "correct" way to do this, but a quick and easy fix would be to just give the field a description which specifies to use spaces. The patch I have posted does just that (plus removes some trailing white space).

I am going to be doing some tweaking for my own benefit in this module. If I find a real fix for this problem, I'll post that patch also.

AttachmentSize
stock.patch.txt 422 bytes

#2

Commited instruction enhancement to HEAD and 4.7.

Leaving issue open for tracking and patches from someone else.

#3

I had the same problem and added this line.
function stock_do_quote

<?php
   
if (!empty($symbol)) {
     
$symbol = rtrim($symbol, ',');   
     
$stock = stockapi_load($symbol);
?>

Added as line 238 of stock.module (Using 5.x.1-dev).

There may need to be some regex checking against the user-inserted strings.

That might happen within stockapi_load(), as there it would be a universal fix.

#4

Version:4.7.x-1.x-dev» 5.x-1.x-dev
Status:active» needs review

I was getting the same issue.
Users will not always do as they are requested and might add commas although they are told to use spaces.
The attached patch works for me.

AttachmentSize
yh.patch 682 bytes

#5

Status:needs review» fixed

Committed. Thanks.

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.