webman-admin里基类Crud.php过滤查询参数为空值的遇到的问题修复

cncgi

问题描述

页面传递in、like等非Null/NOT NULL查询时,如果参数值为空时,Crud.php中的selectInput(Request $request)未能将空值参数过滤掉。
例如http://..../select?area[0]=like&area[1]=cat_id[0]=in&cat_id[1]=

解决方案

将Crud.php中selectInput函数中:

 foreach ($where as $column => $value) {
            if (
                $value === '' || !isset($allow_column[$column]) ||
                is_array($value) && (empty($value) || !in_array($value[0], ['null', 'not null']) && !empty($value[1]))
            ) {
                unset($where[$column]);
            }
        }

修改成:

 foreach ($where as $column => $value) {
            if (
                $value === '' || !isset($allow_column[$column]) ||
                is_array($value) && (empty($value) || !in_array($value[0], ['null', 'not null']) && empty($value[1]))
            ) {
                unset($where[$column]);
            }
        }

可以将该问题解决,目前暂时未发现造成的其他影响,不知道会不会有后续影响?

160 0 0
0个回答

×
🔝