Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Fixed SQL error when selling stock in ACP

Discussion in 'Stock Trader Resolved Bug Reports' started by SneakyDave, Mar 24, 2015.

  1. SneakyDave

    SneakyDave Member Sportsbook

    I recently upgraded to the latest release of stock trader, and noticed that the Top Portfolios list was empty unless a new stock was purchased. Is there a way to rebuild those to get the top portfolios accurate? This issue may have been present for a while actually, but I just noticed it after upgrading to

    In the admincp, I was looking at the list of stock purchasers, and go into "Portfolio Management", I noticed some of their stocks would say "Sell (invalid)" next to a stock that was no longer available. When I try to click on the "Sell" link for those, assuming that the stock would be "sold", I get this SQL error:

    Server Error
    Mysqli prepare error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE user_id = 11' at line 3

    1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    4. Zend_Db_Adapter_Abstract->query() in NFLJ/StockTrader/Model/Cash.php at line 112
    5. NFLJ_StockTrader_Model_Cash->addToCash() in NFLJ/StockTrader/DataWriter/Stock.php at line 119
    6. NFLJ_StockTrader_DataWriter_Stock->_postSave() in XenForo/DataWriter.php at line 1409
    7. XenForo_DataWriter->save() in NFLJ/StockTrader/ControllerAdmin/Stock.php at line 45
    8. NFLJ_StockTrader_ControllerAdmin_Stock->actionSell() in XenForo/FrontController.php at line 347
    9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    10. XenForo_FrontController->run() in /xxxx/admin.php at line 13

    This happens whether or not the stock purchased says "(invalid)" or not.
  2. Bob

    Bob Developer Staff Member

    Anytime the Top Portfolios is "funky", just manually run the "Rebuild User Portfolio Values" CRON (it runs every 12 hours).

    I'll have to look into this tonight. Probably due be something that I've recently changed for frontend functionality that has an effect on the backend now. If you find it before I do, let me know.
    SneakyDave likes this.
  3. Bob

    Bob Developer Staff Member

    btw, you can change the CRON to run more often, but I'd recommend no more than ever 4 hours as it is super intensive (which is why its only run every 12 hours by default).
  4. Bob

    Bob Developer Staff Member

    Found the issue. As I suspected, it was due to a frontend change. Pretty easy fix if you want to apply it manually until I have time to do a maintenance release.

    Edit the file: /library/NFLJ/StockTrader/ControllerAdmin/Stock.php

    replace this same block of code (lines 37-45) with the changes in the below (they are the same lines, I just modified the name of a variable and the KEY for the setExtraData which the KEY was the problem).

                $sharesOwned $userStockInfo['shares_owned'];  
    $newShareAmount 0;
    $payoutAmount = ($sharesOwned $currentStockInfo['lasttrade']);
    $writer XenForo_DataWriter::create('NFLJ_StockTrader_DataWriter_Stock');
    SneakyDave likes this.
  5. SneakyDave

    SneakyDave Member Sportsbook

    Got it, thanks for the quick reply Bobster
  6. Bob

    Bob Developer Staff Member

    anytime bud!
  7. andrewkm

    andrewkm Member Showcase Sportsbook

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.