Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major break into 20.0 : revert to fetchAll signature #30318

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,15 +1038,26 @@ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0,
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter Filter array
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] =
* @param string $filtermode Filter mode (AND or OR)
* @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
* @return int Return integer <0 if KO, >0 if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND', $showAlreadyExportMovements = 1)
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1)
{
global $conf;

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
//some part of dolibarr main code use $filter as array like $filter['t.reconciled_option'] = $search_not_reconciled
//then we use "universal search string only if exists"
if (isset($filter['uss'])) {
$filter = $filter['uss'];
}


dol_syslog(__METHOD__, LOG_DEBUG);

$sql = 'SELECT';
Expand Down Expand Up @@ -1087,6 +1098,8 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
if (is_array($filter)) { // deprecated, use $filter = USF syntax
dol_syslog(__METHOD__ . "Using deprecated filter with old array data, please update to Universal Search string syntax", LOG_NOTICE);

$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
Expand Down
12 changes: 9 additions & 3 deletions htdocs/asset/class/asset.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,21 @@ public function fetchLines()
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";


$records = array();

$sql = "SELECT ";
Expand Down
13 changes: 9 additions & 4 deletions htdocs/asset/class/assetmodel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,20 @@ public function fetchLines()
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

$records = array();

$sql = "SELECT ";
Expand All @@ -359,7 +364,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
$errormessage = '';
$sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
$sql .= forgeSQLFromUniversalSearchCriteria($filter['uss'], $errormessage);
if ($errormessage) {
$this->errors[] = $errormessage;
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
Expand Down
23 changes: 17 additions & 6 deletions htdocs/bom/class/bom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,20 @@ public function fetchLinesbytypeproduct($typeproduct = 0)
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset
* @param string $filter Filter USF
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = ''
* @param string $filtermode Filter mode (AND or OR)
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

$records = array();

$sql = 'SELECT ';
Expand Down Expand Up @@ -1268,7 +1274,7 @@ public function getLinesArray()
$this->lines = array();

$objectline = new BOMLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_bom:=:'.((int) $this->id).')');
$result = $objectline->fetchAll('ASC', 'position', 0, 0, ['uss' => '(fk_bom:=:'.((int) $this->id).')']);

if (is_numeric($result)) {
$this->error = $objectline->error;
Expand Down Expand Up @@ -1904,15 +1910,20 @@ public function fetch($id, $ref = null)
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

$records = array();

$sql = 'SELECT ';
Expand Down
13 changes: 9 additions & 4 deletions htdocs/bookcal/class/availabilities.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,20 @@ public function fetchLines()
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

$records = array();

$sql = "SELECT ";
Expand Down Expand Up @@ -929,7 +934,7 @@ public function getLinesArray()
$this->lines = array();

$objectline = new AvailabilitiesLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_availabilities:=:'.((int) $this->id).')');
$result = $objectline->fetchAll('ASC', 'position', 0, 0, ['uss' => '(fk_availabilities:=:'.((int) $this->id).')']);

if (is_numeric($result)) {
$this->error = $objectline->error;
Expand Down
13 changes: 9 additions & 4 deletions htdocs/bookcal/class/calendar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,20 @@ public function fetchLines()
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

$records = array();

$sql = "SELECT ";
Expand Down Expand Up @@ -921,7 +926,7 @@ public function getLinesArray()
$this->lines = array();

$objectline = new CalendarLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_calendar:=:'.((int) $this->id).')');
$result = $objectline->fetchAll('ASC', 'position', 0, 0, ['uss' => '(fk_calendar:=:'.((int) $this->id).')']);

if (is_numeric($result)) {
$this->setErrorsFromObject($objectline);
Expand Down
16 changes: 14 additions & 2 deletions htdocs/core/class/cgenericdic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,24 @@ public function fetch($id, $code = '', $label = '')
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset offset limit
* @param string|array $filter filter USF
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] =
* @param string $filtermode filter mode (AND or OR)
* @return int Return integer <0 if KO, >0 if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
//some part of dolibarr main code use $filter as array like $filter['t.xxxx'] =
//then we use "universal search string only if exists"
if (isset($filter['uss'])) {
$filter = $filter['uss'];
}

$fieldrowid = 'rowid';
$fieldlabel = 'label';
if ($this->table_element == 'c_stcomm') {
Expand All @@ -251,6 +261,8 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
if (is_array($filter)) {
dol_syslog(__METHOD__ . "Using deprecated filter with old array data, please update to Universal Search string syntax", LOG_NOTICE);

$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
Expand Down
15 changes: 13 additions & 2 deletions htdocs/core/class/cleadstatus.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,24 @@ public function fetch($id, $code = '')
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset
* @param string $filter Filter USF
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] =
* @param string $filtermode Filter mode (AND or OR)
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
//some part of dolibarr main code use $filter as array like $filter['t.xxxx'] =
//then we use "universal search string only if exists"
if (isset($filter['uss'])) {
$filter = $filter['uss'];
}

$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
Expand All @@ -190,6 +200,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
if (is_array($filter)) {
dol_syslog(__METHOD__ . "Using deprecated filter with old array data, please update to Universal Search string syntax", LOG_NOTICE);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
Expand Down
11 changes: 8 additions & 3 deletions htdocs/core/class/commonobjectline.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,18 @@ public function getLabelOfUnit($type = 'long')
* @param string $sortfield Sort field
* @param int $limit Limit the number of lines returned
* @param int $offset Offset
* @param string|array $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] = '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
$filter = $filter['uss'] ?? "";

return 0;
}
}
15 changes: 13 additions & 2 deletions htdocs/core/class/cproductnature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,24 @@ public function fetch($id, $code = '')
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset
* @param string $filter Filter USF
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] =
* @param string $filtermode Filter mode (AND or OR)
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
//some part of dolibarr main code use $filter as array like $filter['t.xxxx'] =
//then we use "universal search string only if exists"
if (isset($filter['uss'])) {
$filter = $filter['uss'];
}

$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
Expand All @@ -174,6 +184,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
if (is_array($filter)) {
dol_syslog(__METHOD__ . "Using deprecated filter with old array data, please update to Universal Search string syntax", LOG_NOTICE);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
Expand Down
15 changes: 13 additions & 2 deletions htdocs/core/class/ctyperesource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,24 @@ public function fetch($id, $code = '', $label = '')
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter filter array
* @param array $filter Filter as an Universal Search string.
* Example: $filter['uss'] =
* @param string $filtermode filter mode (AND or OR)
* @return int Return integer <0 if KO, >0 if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);

if (isset($filter['customsql'])) {
trigger_error(__CLASS__ .'::'.__FUNCTION__.' customsql in filter is now forbidden, please use $filter["uss"]="xx:yy:zz" with Universal Search String instead', E_USER_ERROR);
}
//some part of dolibarr main code use $filter as array like $filter['t.xxxx'] =
//then we use "universal search string only if exists"
if (isset($filter['uss'])) {
$filter = $filter['uss'];
}

$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
Expand All @@ -217,6 +227,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset =

// Manage filter
if (is_array($filter)) {
dol_syslog(__METHOD__ . "Using deprecated filter with old array data, please update to Universal Search string syntax", LOG_NOTICE);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
Expand Down
Loading
Loading