Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 5318e7b

Browse files
committed
Chasing Strict Standard issues
1 parent a8a6034 commit 5318e7b

File tree

10 files changed

+59
-32
lines changed

10 files changed

+59
-32
lines changed

core/src/core/classes/class.AJXP_Controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public static function findRestActionAndApply($actionName, $path)
8383
}
8484
$restPath = $restPathList->item(0)->nodeValue;
8585
$paramNames = explode("/", trim($restPath, "/"));
86-
$path = array_shift(explode("?", $path));
86+
$exploded = explode("?", $path);
87+
$path = array_shift($exploded);
8788
$paramValues = array_map("urldecode", explode("/", trim($path, "/"), count($paramNames)));
8889
foreach ($paramNames as $i => $pName) {
8990
if (strpos($pName, "+") !== false) {

core/src/core/classes/class.AJXP_Utils.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ public static function parseApplicationGetParameters($parameters, &$output, &$se
378378

379379
if (isSet($parameters["repository_id"]) && isSet($parameters["folder"]) || isSet($parameters["goto"])) {
380380
if (isSet($parameters["goto"])) {
381-
$repoId = array_shift(explode("/", ltrim($parameters["goto"], "/")));
381+
$explode = explode("/", ltrim($parameters["goto"], "/"));
382+
$repoId = array_shift($explode);
382383
$parameters["folder"] = str_replace($repoId, "", ltrim($parameters["goto"], "/"));
383384
} else {
384385
$repoId = $parameters["repository_id"];
@@ -885,7 +886,8 @@ public static function detectServerURL($withURI = false)
885886
$api = ConfService::currentContextIsRestAPI();
886887
if(!empty($api)){
887888
// Keep only before api base
888-
$uri = array_shift(explode("/".$api."/", $uri));
889+
$explode = explode("/".$api."/", $uri);
890+
$uri = array_shift($explode);
889891
}
890892
return "$protocol://$name$port".$uri;
891893
}
@@ -1775,7 +1777,8 @@ public static function cleanDibiDriverParameters($params)
17751777
unset($params["group_switch_value"]);
17761778
}
17771779
foreach ($params as $k => $v) {
1778-
$params[array_pop(explode("_", $k, 2))] = AJXP_VarsFilter::filter($v);
1780+
$explode = explode("_", $k, 2);
1781+
$params[array_pop($explode)] = AJXP_VarsFilter::filter($v);
17791782
unset($params[$k]);
17801783
}
17811784
}
@@ -1821,7 +1824,8 @@ public static function runCreateTablesQuery($p, $file)
18211824
$allParts = array();
18221825

18231826
foreach($separators as $sep){
1824-
$firstLine = array_shift(explode("\n", trim($sep)));
1827+
$explode = explode("\n", trim($sep));
1828+
$firstLine = array_shift($explode);
18251829
if($firstLine == "/** BLOCK **/"){
18261830
$allParts[] = $sep;
18271831
}else{

core/src/core/classes/class.ConfService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ public function getCurrentRepositoryIdInst()
685685
}
686686
}
687687
$currentRepos = $this->getLoadedRepositories();
688-
return array_shift(array_keys($currentRepos));
688+
$keys = array_keys($currentRepos);
689+
return array_shift($keys);
689690
}
690691
/**
691692
* Get the current repo label

core/src/plugins/access.ftp/class.ftpAccessDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function isWriteable($path, $type="dir")
225225

226226
}
227227

228-
public function deldir($location)
228+
public function deldir($location, $repoData)
229229
{
230230
if (is_dir($location)) {
231231
$dirsToRecurse = array();
@@ -242,7 +242,7 @@ public function deldir($location)
242242
}
243243
closedir($all);
244244
foreach ($dirsToRecurse as $recurse) {
245-
$this->deldir($recurse);
245+
$this->deldir($recurse, $repoData);
246246
}
247247
rmdir($location);
248248
} else {
@@ -251,7 +251,7 @@ public function deldir($location)
251251
if(!$test) throw new Exception("Cannot delete file ".$location);
252252
}
253253
}
254-
if (basename(dirname($location)) == $this->repository->getOption("RECYCLE_BIN")) {
254+
if (isSet($repoData["recycle"]) && basename(dirname($location)) == $repoData["recycle"]) {
255255
// DELETING FROM RECYCLE
256256
RecycleBinManager::deleteFromRecycle($location);
257257
}

core/src/plugins/access.swift/class.swiftAccessDriver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ public function isWriteable($dir, $type="dir")
9898
return true;
9999
}
100100

101-
public function loadNodeInfo(AJXP_Node &$node, $parentNode = false, $details = false)
101+
/**
102+
* @param AJXP_Node $node See parent function
103+
* @param bool|false $parentNode
104+
* @param bool|false $details
105+
*/
106+
public function loadNodeInfo(&$node, $parentNode = false, $details = false)
102107
{
103108
parent::loadNodeInfo($node, $parentNode, $details);
104109
if (!$node->isLeaf()) {

core/src/plugins/auth.sql/class.sqlAuthDriver.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ public function listUsersPaginated($baseGroup, $regexp, $offset, $limit, $recurs
7676
return $pairs;
7777
}
7878

79-
public function findUserPage($baseGroup, $userLogin, $usersPerPage, $offset){
79+
/**
80+
* See parent method
81+
* @param string $baseGroup
82+
* @param string $userLogin
83+
* @param int $usersPerPage
84+
* @param int $offset
85+
* @return float
86+
*/
87+
public function findUserPage($baseGroup, $userLogin, $usersPerPage, $offset = 0){
8088

8189
$res = dibi::query("SELECT COUNT(*) FROM [ajxp_users] WHERE [login] <= %s", $userLogin);
8290
$count = $res->fetchSingle();
@@ -129,7 +137,13 @@ public function getUsersCount($baseGroup = "/", $regexp = "", $filterProperty =
129137
return $res->fetchSingle();
130138
}
131139

132-
public function listUsers($baseGroup="/")
140+
/**
141+
* See parent method
142+
* @param string $baseGroup
143+
* @param bool|true $recursive
144+
* @return array
145+
*/
146+
public function listUsers($baseGroup="/", $recursive = true)
133147
{
134148
$pairs = array();
135149
$ignoreHiddens = "NOT EXISTS (SELECT * FROM [ajxp_user_rights] AS c WHERE [c.login]=[u.login] AND [c.repo_uuid] = 'ajxp.hidden')";

core/src/plugins/authfront.keystore/class.KeystoreAuthFrontend.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ function tryToLogUser(&$httpVars, $isLast = false){
5757
//$this->logDebug(__FUNCTION__, "Found token in keystore");
5858
$userId = $data["USER_ID"];
5959
$private = $data["PRIVATE"];
60-
$server_uri = rtrim(array_shift(explode("?", $_SERVER["REQUEST_URI"])), "/");
60+
$explode = explode("?", $_SERVER["REQUEST_URI"]);
61+
$server_uri = rtrim(array_shift($explode), "/");
6162
$server_uri = implode("/", array_map("rawurlencode", array_map("urldecode", explode("/", $server_uri))));
6263
$server_uri = str_replace("~", "%7E", $server_uri);
6364
//$this->logDebug(__FUNCTION__, "Decoded URI is ".$server_uri);

core/src/plugins/core.conf/class.AbstractAjxpUser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ public function recomputeMergedRole()
462462
throw new Exception("Empty role, this is not normal");
463463
}
464464
uksort($this->roles, array($this, "orderRoles"));
465-
$this->mergedRole = clone $this->roles[array_shift(array_keys($this->roles))];
465+
$keys = array_keys($this->roles);
466+
$this->mergedRole = clone $this->roles[array_shift($keys)];
466467
if (count($this->roles) > 1) {
467468
$this->parentRole = $this->mergedRole;
468469
}

core/src/plugins/core.index/class.CoreIndexer.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class CoreIndexer extends AJXP_Plugin {
2525
private $verboseIndexation = false;
2626

2727

28-
public function logDebug($message = ""){
29-
parent::logDebug("core.indexer", $message);
28+
public function debug($message = ""){
29+
$this->logDebug("core.indexer", $message);
3030
if($this->verboseIndexation && ConfService::currentContextIsCommandLine()){
3131
print($message."\n");
3232
}
@@ -69,16 +69,16 @@ public function applyAction($actionName, $httpVars, $fileVars)
6969
// SIMPLE FILE
7070
if(!$dir){
7171
try{
72-
$this->logDebug("Indexing - node.index ".$node->getUrl());
72+
$this->debug("Indexing - node.index ".$node->getUrl());
7373
AJXP_Controller::applyHook("node.index", array($node));
7474
}catch (Exception $e){
75-
$this->logDebug("Error Indexing Node ".$node->getUrl()." (".$e->getMessage().")");
75+
$this->debug("Error Indexing Node ".$node->getUrl()." (".$e->getMessage().")");
7676
}
7777
}else{
7878
try{
7979
$this->recursiveIndexation($node);
8080
}catch (Exception $e){
81-
$this->logDebug("Indexation of ".$node->getUrl()." interrupted by error: (".$e->getMessage().")");
81+
$this->debug("Indexation of ".$node->getUrl()." interrupted by error: (".$e->getMessage().")");
8282
}
8383
}
8484

@@ -113,12 +113,12 @@ public function recursiveIndexation($node, $depth = 0)
113113
$messages = ConfService::getMessages();
114114
if($user == null && AuthService::usersEnabled()) $user = AuthService::getLoggedUser();
115115
if($depth == 0){
116-
$this->logDebug("Starting indexation - node.index.recursive.start - ". memory_get_usage(true) ." - ". $node->getUrl());
116+
$this->debug("Starting indexation - node.index.recursive.start - ". memory_get_usage(true) ." - ". $node->getUrl());
117117
$this->setIndexStatus("RUNNING", str_replace("%s", $node->getPath(), $messages["core.index.8"]), $repository, $user);
118118
AJXP_Controller::applyHook("node.index.recursive.start", array($node));
119119
}else{
120120
if($this->isInterruptRequired($repository, $user)){
121-
$this->logDebug("Interrupting indexation! - node.index.recursive.end - ". $node->getUrl());
121+
$this->debug("Interrupting indexation! - node.index.recursive.end - ". $node->getUrl());
122122
AJXP_Controller::applyHook("node.index.recursive.end", array($node));
123123
$this->releaseStatus($repository, $user);
124124
throw new Exception("User interrupted");
@@ -127,13 +127,13 @@ public function recursiveIndexation($node, $depth = 0)
127127

128128
if(!ConfService::currentContextIsCommandLine()) @set_time_limit(120);
129129
$url = $node->getUrl();
130-
$this->logDebug("Indexing Node parent node ".$url);
130+
$this->debug("Indexing Node parent node ".$url);
131131
$this->setIndexStatus("RUNNING", str_replace("%s", $node->getPath(), $messages["core.index.8"]), $repository, $user);
132132
if($node->getPath() != "/"){
133133
try {
134134
AJXP_Controller::applyHook("node.index", array($node));
135135
} catch (Exception $e) {
136-
$this->logDebug("Error Indexing Node ".$url." (".$e->getMessage().")");
136+
$this->debug("Error Indexing Node ".$url." (".$e->getMessage().")");
137137
}
138138
}
139139

@@ -144,27 +144,27 @@ public function recursiveIndexation($node, $depth = 0)
144144
$childNode = new AJXP_Node(rtrim($url, "/")."/".$child);
145145
$childUrl = $childNode->getUrl();
146146
if(is_dir($childUrl)){
147-
$this->logDebug("Entering recursive indexation for ".$childUrl);
147+
$this->debug("Entering recursive indexation for ".$childUrl);
148148
$this->recursiveIndexation($childNode, $depth + 1);
149149
}else{
150150
try {
151-
$this->logDebug("Indexing Node ".$childUrl);
151+
$this->debug("Indexing Node ".$childUrl);
152152
AJXP_Controller::applyHook("node.index", array($childNode));
153153
} catch (Exception $e) {
154-
$this->logDebug("Error Indexing Node ".$childUrl." (".$e->getMessage().")");
154+
$this->debug("Error Indexing Node ".$childUrl." (".$e->getMessage().")");
155155
}
156156
}
157157
}
158158
closedir($handle);
159159
} else {
160-
$this->logDebug("Cannot open $url!!");
160+
$this->debug("Cannot open $url!!");
161161
}
162162
if($depth == 0){
163-
$this->logDebug("End indexation - node.index.recursive.end - ". memory_get_usage(true) ." - ". $node->getUrl());
163+
$this->debug("End indexation - node.index.recursive.end - ". memory_get_usage(true) ." - ". $node->getUrl());
164164
$this->setIndexStatus("RUNNING", "Indexation finished, cleaning...", $repository, $user);
165165
AJXP_Controller::applyHook("node.index.recursive.end", array($node));
166166
$this->releaseStatus($repository, $user);
167-
$this->logDebug("End indexation - After node.index.recursive.end - ". memory_get_usage(true) ." - ". $node->getUrl());
167+
$this->debug("End indexation - After node.index.recursive.end - ". memory_get_usage(true) ." - ". $node->getUrl());
168168
}
169169
}
170170

@@ -197,7 +197,7 @@ protected function setIndexStatus($status, $message, $repository, $user)
197197
$iPath = (defined('AJXP_SHARED_CACHE_DIR')?AJXP_SHARED_CACHE_DIR:AJXP_CACHE_DIR)."/indexes";
198198
if(!is_dir($iPath)) mkdir($iPath,0755, true);
199199
$f = $iPath."/.indexation_status-".$this->buildIndexLockKey($repository, $user);
200-
$this->logDebug("Updating file ".$f." with status $status - $message");
200+
$this->debug("Updating file ".$f." with status $status - $message");
201201
file_put_contents($f, strtoupper($status).":".$message);
202202
}
203203

@@ -223,7 +223,7 @@ protected function getIndexStatus($repository, $user)
223223
protected function releaseStatus($repository, $user)
224224
{
225225
$f = (defined('AJXP_SHARED_CACHE_DIR')?AJXP_SHARED_CACHE_DIR:AJXP_CACHE_DIR)."/indexes/.indexation_status-".$this->buildIndexLockKey($repository, $user);
226-
$this->logDebug("Removing file ".$f);
226+
$this->debug("Removing file ".$f);
227227
@unlink($f);
228228
}
229229

core/src/rest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
ConfService::switchRootDir();
6363
$repo = ConfService::getRepository();
6464
}else{
65-
$repo = &ConfService::findRepositoryByIdOrAlias($repoID);
65+
$repo = ConfService::findRepositoryByIdOrAlias($repoID);
6666
if ($repo == null) {
6767
die("Cannot find repository with ID ".$repoID);
6868
}

0 commit comments

Comments
 (0)