N°2555 action_rule performance

* do not execute scope_oql that have no conditions
* pick the first result only
This commit is contained in:
Pierre Goiffon
2019-10-24 10:54:30 +02:00
parent 9aeba1df9b
commit 5c483efd15
4 changed files with 67 additions and 42 deletions

View File

@@ -1077,16 +1077,16 @@ abstract class DBSearch
* @param array $aSearchParams
*
* @return null|\DBObject query result
* @throws \CoreOqlMultipleResultsFoundException if multiple results found and parameter enforce the check
* @throws \CoreOqlMultipleResultsForbiddenException if multiple results found and parameter enforce the check
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function GetFirstResult($bMustHaveOneResultMax = true, $aOrderBy = array(), $aSearchParams = array())
{
$oSet = new DBObjectSet($this, array(), $aSearchParams);
$oSet = new DBObjectSet($this, array(), $aSearchParams, null, 2);
$oFirstResult = $oSet->Fetch();
if ($oFirstResult === null)
if ($oFirstResult === null) // useless but here for readability ;)
{
return null;
}
@@ -1094,9 +1094,10 @@ abstract class DBSearch
if ($bMustHaveOneResultMax)
{
$oSecondResult = $oSet->Fetch();
if ($oSecondResult != null)
if ($oSecondResult !== null)
{
throw new CoreOqlMultipleResultsFoundException('TODO');
throw new CoreOqlMultipleResultsForbiddenException(
'Search returned multiple results, this is forbidden. Query was: '.$this->ToOQL());
}
}