|
|
@@ -22,6 +22,8 @@ class AclQueryFeatures {
|
|
|
public $_legacyMode;
|
|
|
public $_selectLocalFields; // TODO: leave here or move to AclQueryBuilder? use join for perf?
|
|
|
public $_selectRemote; // TODO: ...
|
|
|
+ public $_dbgExecTime;
|
|
|
+ public $_instanceID;
|
|
|
|
|
|
public function __construct($acl, $params, $legacyMode = false) {
|
|
|
$this->_acl = $acl;
|
|
|
@@ -32,6 +34,29 @@ class AclQueryFeatures {
|
|
|
// TODO: _legacyMode = ($from instanceof simple schema or another programmed objects)
|
|
|
$this->_selectLocalFields = null;
|
|
|
$this->_selectRemote = null;
|
|
|
+
|
|
|
+ $DBG_LOG_TO_FILE = true; // TODO: read from ENV or REQUEST
|
|
|
+ if ($DBG_LOG_TO_FILE) {
|
|
|
+ Lib::loadClass('DebugExecutionTime');
|
|
|
+ $this->_dbgExecTime = new DebugExecutionTime();
|
|
|
+ $this->_dbgExecTime->setLogFile('/tmp/se-dbg-exec-time--AclQueryFeatures.csv', $format = 'csv'); // $format: 'csv', 'json'
|
|
|
+ $this->_logToFile("from: '" . $this->_acl->getNamespace() . "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _logToFile($msg) {
|
|
|
+ if ($this->_dbgExecTime) {
|
|
|
+ $idInstance = $this->_getInstanceID();
|
|
|
+ $this->_dbgExecTime->logToFile("#{$idInstance}: {$msg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function _getInstanceID() {
|
|
|
+ static $_INSTANCE_ID = 0;
|
|
|
+ if (!$this->_instanceID) {
|
|
|
+ $_INSTANCE_ID += 1;
|
|
|
+ $this->_instanceID = $_INSTANCE_ID;
|
|
|
+ }
|
|
|
+ return $this->_instanceID;
|
|
|
}
|
|
|
|
|
|
public function parseQueryValue($fieldName, $searchQuery, $fieldType = 'xsd:string') {
|
|
|
@@ -429,6 +454,7 @@ class AclQueryFeatures {
|
|
|
public function getParam($key) { return V::get($key, '', $this->_params); }
|
|
|
|
|
|
public function getItems() {
|
|
|
+ $this->_logToFile('getItems() ...');
|
|
|
if ($this->_legacyMode) return $this->_acl->getItems($this->_params);// TODO: array_map( $r => (array)$r )
|
|
|
// 'limit' => 10,
|
|
|
// 'limitstart' => 0,
|
|
|
@@ -453,7 +479,7 @@ class AclQueryFeatures {
|
|
|
DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
|
// DBG::log($this->getQuery(), 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).") \$this->getQuery()");
|
|
|
|
|
|
- return $this->fetchRowsRefs(
|
|
|
+ $items = $this->fetchRowsRefs(
|
|
|
$this->getQuery()
|
|
|
->select($select)
|
|
|
->limit($limit)
|
|
|
@@ -461,6 +487,8 @@ class AclQueryFeatures {
|
|
|
->orderBy($sortBy)
|
|
|
->fetchAll()
|
|
|
);
|
|
|
+ $this->_logToFile('getItems() fetched.');
|
|
|
+ return $items;
|
|
|
}
|
|
|
|
|
|
public function getItem($primaryKey) { // TODO: throw exception if not found?
|