Another Import Bug

MrCaspanMrCaspan
edited March 2020 in Vanilla 3.x Help

If you look at the function getCountSQL in /application/dashboard/model/class.importmodel.php

the following line could return NULL

$result = "update :_$parentTable p
    set p.$parentColumnName = (
      select $aggregate(c.$childColumnName)
      from :_$childTable c
      where p.$parentJoinColumn = c.$childJoinColumn)";

If for some reason this returns NULL as in it has no parents (it shoudl but crap happens) it will error out the script

i have replace the code with

    $result = "update :_$parentTable p
         set p.$parentColumnName = (
           select IFNULL($aggregate(c.$childColumnName),0)
           from :_$childTable c
           where p.$parentJoinColumn = c.$childJoinColumn)";

this will test for null and if null will return 0

Comments

Sign In or Register to comment.