style: apply php-lint

pull/376/head
Raymond Huang 2023-01-26 08:48:17 +08:00
parent 80a433a874
commit ea8d08eba7
3 changed files with 30 additions and 35 deletions

View File

@ -248,10 +248,6 @@ class LocationsController extends ApiBase
* @param array $days the days array * @param array $days the days array
* @param string $uid User ID or blank for public shares * @param string $uid User ID or blank for public shares
* @param TimelineRoot $root the root folder * @param TimelineRoot $root the root folder
* @param string $minLat
* @param string $maxLat
* @param string $minLng
* @param string $maxLng
*/ */
private function preloadDaysWithBounds(array &$days, string $uid, TimelineRoot &$root, string $minLat, string $maxLat, string $minLng, string $maxLng) private function preloadDaysWithBounds(array &$days, string $uid, TimelineRoot &$root, string $minLat, string $maxLat, string $minLng, string $maxLng)
{ {
@ -266,7 +262,7 @@ class LocationsController extends ApiBase
$preloaded += $day['count']; $preloaded += $day['count'];
$preloadDayIds[] = $day['dayid']; $preloadDayIds[] = $day['dayid'];
$preloadDays[] = & $day; $preloadDays[] = &$day;
if ($preloaded >= 50 || \count($preloadDayIds) > 5) { // should be enough if ($preloaded >= 50 || \count($preloadDayIds) > 5) { // should be enough
break; break;
@ -290,7 +286,7 @@ class LocationsController extends ApiBase
// Group into dayid // Group into dayid
$detailMap = []; $detailMap = [];
foreach ($allDetails as &$detail) { foreach ($allDetails as &$detail) {
$detailMap[$detail['dayid']][] = & $detail; $detailMap[$detail['dayid']][] = &$detail;
} }
foreach ($preloadDays as &$day) { foreach ($preloadDays as &$day) {
$m = $detailMap[$day['dayid']]; $m = $detailMap[$day['dayid']];
@ -300,4 +296,4 @@ class LocationsController extends ApiBase
} }
} }
} }
} }

View File

@ -34,8 +34,7 @@ class PageController extends Controller
IInitialState $initialState, IInitialState $initialState,
IUserSession $userSession, IUserSession $userSession,
IConfig $config IConfig $config
) ) {
{
parent::__construct($AppName, $request); parent::__construct($AppName, $request);
$this->userId = $UserId; $this->userId = $UserId;
$this->appName = $AppName; $this->appName = $AppName;
@ -64,21 +63,27 @@ class PageController extends Controller
// Configuration // Configuration
$uid = $user->getUID(); $uid = $user->getUID();
$this->initialState->provideInitialState('timelinePath', $this->config->getUserValue( $this->initialState->provideInitialState(
'timelinePath',
$this->config->getUserValue(
$uid, $uid,
Application::APPNAME, Application::APPNAME,
'timelinePath', 'timelinePath',
'EMPTY' 'EMPTY'
) )
); );
$this->initialState->provideInitialState('foldersPath', $this->config->getUserValue( $this->initialState->provideInitialState(
'foldersPath',
$this->config->getUserValue(
$uid, $uid,
Application::APPNAME, Application::APPNAME,
'foldersPath', 'foldersPath',
'/' '/'
) )
); );
$this->initialState->provideInitialState('showHidden', $this->config->getUserValue( $this->initialState->provideInitialState(
'showHidden',
$this->config->getUserValue(
$uid, $uid,
Application::APPNAME, Application::APPNAME,
'showHidden', 'showHidden',
@ -238,4 +243,4 @@ class PageController extends Controller
{ {
return $this->main(); return $this->main();
} }
} }

View File

@ -99,8 +99,7 @@ trait TimelineQueryDays
bool $recursive, bool $recursive,
bool $archive, bool $archive,
array $queryTransforms = [] array $queryTransforms = []
): array ): array {
{
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
// Get all entries also present in filecache // Get all entries also present in filecache
@ -136,7 +135,7 @@ trait TimelineQueryDays
* @param string $maxLat The maximum latitude * @param string $maxLat The maximum latitude
* @param string $minLng The minimum longitude * @param string $minLng The minimum longitude
* @param string $maxLng The maximum longitude * @param string $maxLng The maximum longitude
* *
* @return array The days response * @return array The days response
*/ */
public function getDaysWithBounds( public function getDaysWithBounds(
@ -144,13 +143,12 @@ trait TimelineQueryDays
string $uid, string $uid,
bool $recursive, bool $recursive,
bool $archive, bool $archive,
array $queryTransforms = [], array $queryTransforms,
string $minLat, string $minLat,
string $maxLat, string $maxLat,
string $minLng, string $minLng,
string $maxLng string $maxLng
): array ): array {
{
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
// Get all entries also present in filecache // Get all entries also present in filecache
@ -203,8 +201,7 @@ trait TimelineQueryDays
bool $recursive, bool $recursive,
bool $archive, bool $archive,
array $queryTransforms = [] array $queryTransforms = []
): array ): array {
{
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
// Get all entries also present in filecache // Get all entries also present in filecache
@ -265,27 +262,25 @@ trait TimelineQueryDays
* @param bool $archive If the query should include only the archive folder * @param bool $archive If the query should include only the archive folder
* @param array $queryTransforms The query transformations to apply * @param array $queryTransforms The query transformations to apply
* @param mixed $day_ids * @param mixed $day_ids
* @param string $minLat The minimum latitude * @param string $minLat The minimum latitude
* @param string $maxLat The maximum latitude * @param string $maxLat The maximum latitude
* @param string $minLng The minimum longitude * @param string $minLng The minimum longitude
* @param string $maxLng The maximum longitude * @param string $maxLng The maximum longitude
* *
* @return array An array of day responses * @return array An array of day responses
*/ */
public function getDayWithBounds( public function getDayWithBounds(
TimelineRoot &$root, TimelineRoot &$root,
string $uid, string $uid,
?array $day_ids, ?array $day_ids,
bool $recursive, bool $recursive,
bool $archive, bool $archive,
array $queryTransforms = [], array $queryTransforms,
string $minLat, string $minLat,
string $maxLat, string $maxLat,
string $minLng, string $minLng,
string $maxLng string $maxLng
): array ): array {
{
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
// Get all entries also present in filecache // Get all entries also present in filecache
@ -408,7 +403,7 @@ trait TimelineQueryDays
$actualPath[1] = $actualPath[2]; $actualPath[1] = $actualPath[2];
$actualPath[2] = $tmp; $actualPath[2] = $tmp;
$davPath = implode('/', $actualPath); $davPath = implode('/', $actualPath);
$davPaths[$fileid] = Exif::removeExtraSlash('/' . $davPath . '/'); $davPaths[$fileid] = Exif::removeExtraSlash('/'.$davPath.'/');
} }
} }
} }
@ -441,7 +436,7 @@ trait TimelineQueryDays
if (0 === strpos($row['path'], $basePath)) { if (0 === strpos($row['path'], $basePath)) {
$rpath = substr($row['path'], \strlen($basePath)); $rpath = substr($row['path'], \strlen($basePath));
$row['filename'] = Exif::removeExtraSlash($davPath . $rpath); $row['filename'] = Exif::removeExtraSlash($davPath.$rpath);
} }
unset($row['path']); unset($row['path']);
@ -471,7 +466,7 @@ trait TimelineQueryDays
// Add WITH clause if needed // Add WITH clause if needed
if (false !== strpos($sql, 'cte_folders')) { if (false !== strpos($sql, 'cte_folders')) {
$sql = $CTE_SQL . ' ' . $sql; $sql = $CTE_SQL.' '.$sql;
} }
return $this->connection->executeQuery($sql, $params, $types); return $this->connection->executeQuery($sql, $params, $types);
@ -484,8 +479,7 @@ trait TimelineQueryDays
IQueryBuilder &$query, IQueryBuilder &$query,
TimelineRoot &$root, TimelineRoot &$root,
bool $archive bool $archive
) ) {
{
// Add query parameters // Add query parameters
$query->setParameter('topFolderIds', $root->getIds(), IQueryBuilder::PARAM_INT_ARRAY); $query->setParameter('topFolderIds', $root->getIds(), IQueryBuilder::PARAM_INT_ARRAY);
$query->setParameter('cteFoldersArchive', $archive, IQueryBuilder::PARAM_BOOL); $query->setParameter('cteFoldersArchive', $archive, IQueryBuilder::PARAM_BOOL);
@ -504,8 +498,7 @@ trait TimelineQueryDays
TimelineRoot &$root, TimelineRoot &$root,
bool $recursive, bool $recursive,
bool $archive bool $archive
) ) {
{
// Join with memories // Join with memories
$baseOp = $query->expr()->eq('f.fileid', 'm.fileid'); $baseOp = $query->expr()->eq('f.fileid', 'm.fileid');
if ($root->isEmpty()) { if ($root->isEmpty()) {
@ -526,10 +519,11 @@ trait TimelineQueryDays
return $query->innerJoin( return $query->innerJoin(
'm', 'm',
'filecache', 'filecache',
'f', $query->expr()->andX( 'f',
$query->expr()->andX(
$baseOp, $baseOp,
$pathOp, $pathOp,
) )
); );
} }
} }