Changed and/or to &&/||
This commit is contained in:
parent
ed833bf7b1
commit
77983d8e20
30 changed files with 51 additions and 51 deletions
|
@ -46,7 +46,7 @@ final class AuthController extends AbstractController
|
||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
if (isset($this->inputReader->userNameOrEmail) and isset($this->inputReader->password))
|
if (isset($this->inputReader->userNameOrEmail) && isset($this->inputReader->password))
|
||||||
{
|
{
|
||||||
$formData = new LoginFormData($this->inputReader);
|
$formData = new LoginFormData($this->inputReader);
|
||||||
$this->authService->loginFromCredentials($formData);
|
$this->authService->loginFromCredentials($formData);
|
||||||
|
|
|
@ -125,7 +125,7 @@ final class CommentController extends AbstractController
|
||||||
$comment = $this->commentService->getById($commentId);
|
$comment = $this->commentService->getById($commentId);
|
||||||
|
|
||||||
$this->privilegeService->assertPrivilege(
|
$this->privilegeService->assertPrivilege(
|
||||||
($comment->getUser() and $this->privilegeService->isLoggedIn($comment->getUser()))
|
($comment->getUser() && $this->privilegeService->isLoggedIn($comment->getUser()))
|
||||||
? Privilege::EDIT_OWN_COMMENTS
|
? Privilege::EDIT_OWN_COMMENTS
|
||||||
: Privilege::EDIT_ALL_COMMENTS);
|
: Privilege::EDIT_ALL_COMMENTS);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CommentViewProxy extends AbstractViewProxy
|
||||||
$result->user = $this->userViewProxy->fromEntity($comment->getUser());
|
$result->user = $this->userViewProxy->fromEntity($comment->getUser());
|
||||||
$result->score = $comment->getScore();
|
$result->score = $comment->getScore();
|
||||||
|
|
||||||
if (!empty($config[self::FETCH_OWN_SCORE]) and $this->authService->isLoggedIn())
|
if (!empty($config[self::FETCH_OWN_SCORE]) && $this->authService->isLoggedIn())
|
||||||
$result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $comment);
|
$result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $comment);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -107,7 +107,7 @@ class PostViewProxy extends AbstractViewProxy
|
||||||
$result->history = [];
|
$result->history = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($config[self::FETCH_OWN_SCORE]) and $this->authService->isLoggedIn())
|
if (!empty($config[self::FETCH_OWN_SCORE]) && $this->authService->isLoggedIn())
|
||||||
$result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $post);
|
$result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $post);
|
||||||
|
|
||||||
if (!empty($config[self::FETCH_FAVORITES]))
|
if (!empty($config[self::FETCH_FAVORITES]))
|
||||||
|
|
|
@ -154,7 +154,7 @@ abstract class AbstractDao implements ICrudDao, IBatchDao
|
||||||
|
|
||||||
protected function findBy($columnName, $value)
|
protected function findBy($columnName, $value)
|
||||||
{
|
{
|
||||||
if (is_array($value) and empty($value))
|
if (is_array($value) && empty($value))
|
||||||
return [];
|
return [];
|
||||||
$query = $this->pdo->from($this->tableName)->where($columnName, $value);
|
$query = $this->pdo->from($this->tableName)->where($columnName, $value);
|
||||||
$arrayEntities = iterator_to_array($query);
|
$arrayEntities = iterator_to_array($query);
|
||||||
|
@ -210,7 +210,7 @@ abstract class AbstractDao implements ICrudDao, IBatchDao
|
||||||
|
|
||||||
else if ($value instanceof RequirementRangedValue)
|
else if ($value instanceof RequirementRangedValue)
|
||||||
{
|
{
|
||||||
if ($value->getMinValue() and $value->getMaxValue())
|
if ($value->getMinValue() && $value->getMaxValue())
|
||||||
{
|
{
|
||||||
$sql = $sqlColumn . ' >= ? AND ' . $sqlColumn . ' <= ?';
|
$sql = $sqlColumn . ' >= ? AND ' . $sqlColumn . ' <= ?';
|
||||||
$bindings = [$value->getMinValue(), $value->getMaxValue()];
|
$bindings = [$value->getMinValue(), $value->getMaxValue()];
|
||||||
|
|
|
@ -103,7 +103,7 @@ class TagDao extends AbstractDao implements ICrudDao
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!isset($exported[$key1]) or !isset($exported[$key2]))
|
if (!isset($exported[$key1]) || !isset($exported[$key2]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!isset($exported[$key1][$target]))
|
if (!isset($exported[$key1][$target]))
|
||||||
|
|
|
@ -25,7 +25,7 @@ class TokenDao extends AbstractDao
|
||||||
->where('purpose', $purpose);
|
->where('purpose', $purpose);
|
||||||
$arrayEntities = iterator_to_array($query);
|
$arrayEntities = iterator_to_array($query);
|
||||||
$entities = $this->arrayToEntities($arrayEntities);
|
$entities = $this->arrayToEntities($arrayEntities);
|
||||||
if (!$entities or !count($entities))
|
if (!$entities || !count($entities))
|
||||||
return null;
|
return null;
|
||||||
$entity = array_shift($entities);
|
$entity = array_shift($entities);
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class UserDao extends AbstractDao implements ICrudDao
|
||||||
public function findByEmail($userEmail, $allowUnconfirmed = false)
|
public function findByEmail($userEmail, $allowUnconfirmed = false)
|
||||||
{
|
{
|
||||||
$result = $this->findOneBy('email', $userEmail);
|
$result = $this->findOneBy('email', $userEmail);
|
||||||
if (!$result and $allowUnconfirmed)
|
if (!$result && $allowUnconfirmed)
|
||||||
{
|
{
|
||||||
$result = $this->findOneBy('emailUnconfirmed', $userEmail);
|
$result = $this->findOneBy('emailUnconfirmed', $userEmail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class UploadFormData implements IValidatable
|
||||||
|
|
||||||
public function validate(Validator $validator)
|
public function validate(Validator $validator)
|
||||||
{
|
{
|
||||||
if ($this->content === null and $this->url === null)
|
if ($this->content === null && $this->url === null)
|
||||||
throw new \DomainException('Neither data or URL provided.');
|
throw new \DomainException('Neither data or URL provided.');
|
||||||
|
|
||||||
$validator->validatePostTags($this->tags);
|
$validator->validatePostTags($this->tags);
|
||||||
|
|
|
@ -8,7 +8,7 @@ final class InputReader extends \ArrayObject
|
||||||
parent::setFlags(parent::ARRAY_AS_PROPS | parent::STD_PROP_LIST);
|
parent::setFlags(parent::ARRAY_AS_PROPS | parent::STD_PROP_LIST);
|
||||||
|
|
||||||
$_PUT = [];
|
$_PUT = [];
|
||||||
if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] === 'PUT')
|
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT')
|
||||||
parse_str(file_get_contents('php://input'), $_PUT);
|
parse_str(file_get_contents('php://input'), $_PUT);
|
||||||
|
|
||||||
foreach ([$_GET, $_POST, $_PUT] as $source)
|
foreach ([$_GET, $_POST, $_PUT] as $source)
|
||||||
|
|
|
@ -25,7 +25,7 @@ class MimeHelper
|
||||||
|
|
||||||
public static function isVideo($mime)
|
public static function isVideo($mime)
|
||||||
{
|
{
|
||||||
return strtolower($mime) === 'application/ogg' or preg_match('/video\//i', $mime);
|
return strtolower($mime) === 'application/ogg' || preg_match('/video\//i', $mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isImage($mime)
|
public static function isImage($mime)
|
||||||
|
@ -59,7 +59,7 @@ class MimeHelper
|
||||||
if ($bytes === false)
|
if ($bytes === false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strncmp($bytes, 'CWS', 3) === 0 or strncmp($bytes, 'FWS', 3) === 0 or strncmp($bytes, 'ZWS', 3) === 0)
|
if (strncmp($bytes, 'CWS', 3) === 0 || strncmp($bytes, 'FWS', 3) === 0 || strncmp($bytes, 'ZWS', 3) === 0)
|
||||||
return 'application/x-shockwave-flash';
|
return 'application/x-shockwave-flash';
|
||||||
|
|
||||||
if (strncmp($bytes, "\xff\xd8\xff", 3) === 0)
|
if (strncmp($bytes, "\xff\xd8\xff", 3) === 0)
|
||||||
|
@ -68,13 +68,13 @@ class MimeHelper
|
||||||
if (strncmp($bytes, "\x89PNG\x0d\x0a", 6) === 0)
|
if (strncmp($bytes, "\x89PNG\x0d\x0a", 6) === 0)
|
||||||
return 'image/png';
|
return 'image/png';
|
||||||
|
|
||||||
if (strncmp($bytes, 'GIF87a', 6) === 0 or strncmp($bytes, 'GIF89a', 6) === 0)
|
if (strncmp($bytes, 'GIF87a', 6) === 0 || strncmp($bytes, 'GIF89a', 6) === 0)
|
||||||
return 'image/gif';
|
return 'image/gif';
|
||||||
|
|
||||||
if (strncmp($bytes, "\x1a\x45\xdf\xa3", 4) === 0)
|
if (strncmp($bytes, "\x1a\x45\xdf\xa3", 4) === 0)
|
||||||
return 'video/webm';
|
return 'video/webm';
|
||||||
|
|
||||||
if (strncmp(substr($bytes, 4), 'ftypisom', 8) === 0 or strncmp(substr($bytes, 4), 'ftypmp42', 8) === 0)
|
if (strncmp(substr($bytes, 4), 'ftypisom', 8) === 0 || strncmp(substr($bytes, 4), 'ftypmp42', 8) === 0)
|
||||||
return 'video/mp4';
|
return 'video/mp4';
|
||||||
|
|
||||||
if (strncmp($bytes, "\x46\x4c\x56\x01", 4) === 0)
|
if (strncmp($bytes, "\x46\x4c\x56\x01", 4) === 0)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class TypeHelper
|
||||||
return false;
|
return false;
|
||||||
if ($value === false)
|
if ($value === false)
|
||||||
return false;
|
return false;
|
||||||
if (is_array($value) and count($value) === 1)
|
if (is_array($value) && count($value) === 1)
|
||||||
return false;
|
return false;
|
||||||
if ($value === null)
|
if ($value === null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -10,7 +10,7 @@ class SelectQuery extends BaseQuery implements \Countable
|
||||||
|
|
||||||
public function limit($limit)
|
public function limit($limit)
|
||||||
{
|
{
|
||||||
if ($limit === null or $limit === false)
|
if ($limit === null || $limit === false)
|
||||||
$this->limit = null;
|
$this->limit = null;
|
||||||
else
|
else
|
||||||
$this->limit = intval($limit);
|
$this->limit = intval($limit);
|
||||||
|
@ -87,7 +87,7 @@ class SelectQuery extends BaseQuery implements \Countable
|
||||||
if ($this->limit !== null)
|
if ($this->limit !== null)
|
||||||
{
|
{
|
||||||
$sql .= 'LIMIT ' . $this->limit;
|
$sql .= 'LIMIT ' . $this->limit;
|
||||||
if ($this->offset !== null and $this->offset !== 0)
|
if ($this->offset !== null && $this->offset !== 0)
|
||||||
$sql .= ' OFFSET ' . intval($this->offset);
|
$sql .= ' OFFSET ' . intval($this->offset);
|
||||||
}
|
}
|
||||||
$this->clauses[self::CLAUSE_LIMIT] = $sql;
|
$this->clauses[self::CLAUSE_LIMIT] = $sql;
|
||||||
|
|
|
@ -63,7 +63,7 @@ abstract class AbstractSearchParser
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((($flags & self::ALLOW_RANGES) === self::ALLOW_RANGES) and substr_count($text, '..') === 1)
|
if ((($flags & self::ALLOW_RANGES) === self::ALLOW_RANGES) && substr_count($text, '..') === 1)
|
||||||
{
|
{
|
||||||
list ($minValue, $maxValue) = explode('..', $text);
|
list ($minValue, $maxValue) = explode('..', $text);
|
||||||
$minValue = $valueDecorator($minValue);
|
$minValue = $valueDecorator($minValue);
|
||||||
|
@ -73,7 +73,7 @@ abstract class AbstractSearchParser
|
||||||
$tokenValue->setMaxValue($maxValue);
|
$tokenValue->setMaxValue($maxValue);
|
||||||
return $tokenValue;
|
return $tokenValue;
|
||||||
}
|
}
|
||||||
else if ((($flags & self::ALLOW_COMPOSITE) === self::ALLOW_COMPOSITE) and strpos($text, ',') !== false)
|
else if ((($flags & self::ALLOW_COMPOSITE) === self::ALLOW_COMPOSITE) && strpos($text, ',') !== false)
|
||||||
{
|
{
|
||||||
$values = explode(',', $text);
|
$values = explode(',', $text);
|
||||||
$values = array_map($valueDecorator, $values);
|
$values = array_map($valueDecorator, $values);
|
||||||
|
@ -145,7 +145,7 @@ abstract class AbstractSearchParser
|
||||||
}
|
}
|
||||||
|
|
||||||
$colonPosition = strpos($tokenText, ':');
|
$colonPosition = strpos($tokenText, ':');
|
||||||
if (($colonPosition !== false) and ($colonPosition > 0))
|
if (($colonPosition !== false) && ($colonPosition > 0))
|
||||||
{
|
{
|
||||||
$searchToken = new NamedSearchToken();
|
$searchToken = new NamedSearchToken();
|
||||||
list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2);
|
list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2);
|
||||||
|
|
|
@ -76,19 +76,19 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($token->getKey() === 'comment')
|
elseif ($token->getKey() === 'comment')
|
||||||
$this->addCommentRequirement($filter, $token);
|
$this->addCommentRequirement($filter, $token);
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'liked')
|
elseif ($token->getKey() === 'special' && $token->getValue() === 'liked')
|
||||||
{
|
{
|
||||||
$this->privilegeService->assertLoggedIn();
|
$this->privilegeService->assertLoggedIn();
|
||||||
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'disliked')
|
elseif ($token->getKey() === 'special' && $token->getValue() === 'disliked')
|
||||||
{
|
{
|
||||||
$this->privilegeService->assertLoggedIn();
|
$this->privilegeService->assertLoggedIn();
|
||||||
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), -1, $token->isNegated());
|
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), -1, $token->isNegated());
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'fav')
|
elseif ($token->getKey() === 'special' && $token->getValue() === 'fav')
|
||||||
{
|
{
|
||||||
$this->privilegeService->assertLoggedIn();
|
$this->privilegeService->assertLoggedIn();
|
||||||
$token = new NamedSearchToken();
|
$token = new NamedSearchToken();
|
||||||
|
@ -109,7 +109,7 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($tokenText === 'id')
|
elseif ($tokenText === 'id')
|
||||||
return PostFilter::ORDER_ID;
|
return PostFilter::ORDER_ID;
|
||||||
|
|
||||||
elseif ($tokenText === 'time' or $tokenText === 'date')
|
elseif ($tokenText === 'time' || $tokenText === 'date')
|
||||||
return PostFilter::ORDER_LAST_EDIT_TIME;
|
return PostFilter::ORDER_LAST_EDIT_TIME;
|
||||||
|
|
||||||
elseif ($tokenText === 'score')
|
elseif ($tokenText === 'score')
|
||||||
|
@ -127,13 +127,13 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($tokenText === 'comment_count')
|
elseif ($tokenText === 'comment_count')
|
||||||
return PostFilter::ORDER_COMMENT_COUNT;
|
return PostFilter::ORDER_COMMENT_COUNT;
|
||||||
|
|
||||||
elseif ($tokenText === 'fav_time' or $tokenText === 'fav_date')
|
elseif ($tokenText === 'fav_time' || $tokenText === 'fav_date')
|
||||||
return PostFilter::ORDER_LAST_FAV_TIME;
|
return PostFilter::ORDER_LAST_FAV_TIME;
|
||||||
|
|
||||||
elseif ($tokenText === 'comment_time' or $tokenText === 'comment_date')
|
elseif ($tokenText === 'comment_time' || $tokenText === 'comment_date')
|
||||||
return PostFilter::ORDER_LAST_COMMENT_TIME;
|
return PostFilter::ORDER_LAST_COMMENT_TIME;
|
||||||
|
|
||||||
elseif ($tokenText === 'feature_time' or $tokenText === 'feature_date')
|
elseif ($tokenText === 'feature_time' || $tokenText === 'feature_date')
|
||||||
return PostFilter::ORDER_LAST_FEATURE_TIME;
|
return PostFilter::ORDER_LAST_FEATURE_TIME;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -47,7 +47,7 @@ class TagSearchParser extends AbstractSearchParser
|
||||||
elseif ($tokenText === 'name')
|
elseif ($tokenText === 'name')
|
||||||
return TagFilter::ORDER_NAME;
|
return TagFilter::ORDER_NAME;
|
||||||
|
|
||||||
elseif ($tokenText === 'creation_time' or $tokenText === 'creation_date')
|
elseif ($tokenText === 'creation_time' || $tokenText === 'creation_date')
|
||||||
return TagFilter::ORDER_CREATION_TIME;
|
return TagFilter::ORDER_CREATION_TIME;
|
||||||
|
|
||||||
elseif ($tokenText === 'usage_count')
|
elseif ($tokenText === 'usage_count')
|
||||||
|
|
|
@ -28,7 +28,7 @@ class UserSearchParser extends AbstractSearchParser
|
||||||
if ($tokenText === 'name')
|
if ($tokenText === 'name')
|
||||||
return UserFilter::ORDER_NAME;
|
return UserFilter::ORDER_NAME;
|
||||||
|
|
||||||
elseif ($tokenText === 'registration_time' or $tokenText === 'registration_date')
|
elseif ($tokenText === 'registration_time' || $tokenText === 'registration_date')
|
||||||
return UserFilter::ORDER_REGISTRATION_TIME;
|
return UserFilter::ORDER_REGISTRATION_TIME;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,7 +110,7 @@ class AuthService
|
||||||
|
|
||||||
private function doFinalChecksOnUser($user)
|
private function doFinalChecksOnUser($user)
|
||||||
{
|
{
|
||||||
if (!$user->isAccountConfirmed() and $this->config->security->needEmailActivationToRegister)
|
if (!$user->isAccountConfirmed() && $this->config->security->needEmailActivationToRegister)
|
||||||
throw new \DomainException('User didn\'t confirm account yet.');
|
throw new \DomainException('User didn\'t confirm account yet.');
|
||||||
|
|
||||||
if ($user->isBanned())
|
if ($user->isBanned())
|
||||||
|
|
|
@ -73,11 +73,11 @@ class HistoryService
|
||||||
{
|
{
|
||||||
foreach ($base[$key] as $subValue)
|
foreach ($base[$key] as $subValue)
|
||||||
{
|
{
|
||||||
if (!isset($other[$key]) or !in_array($subValue, $other[$key]))
|
if (!isset($other[$key]) || !in_array($subValue, $other[$key]))
|
||||||
$result[] = [$key, $subValue];
|
$result[] = [$key, $subValue];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (!isset($other[$key]) or $base[$key] !== $other[$key])
|
elseif (!isset($other[$key]) || $base[$key] !== $other[$key])
|
||||||
{
|
{
|
||||||
$result[] = [$key, $value];
|
$result[] = [$key, $value];
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ImageConverter
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($targetPath) and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_SWFRENDER))
|
if (!file_exists($targetPath) && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_SWFRENDER))
|
||||||
{
|
{
|
||||||
ProgramExecutor::run(
|
ProgramExecutor::run(
|
||||||
self::PROGRAM_NAME_SWFRENDER,
|
self::PROGRAM_NAME_SWFRENDER,
|
||||||
|
@ -100,7 +100,7 @@ class ImageConverter
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($targetPath) and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_FFMPEG))
|
if (!file_exists($targetPath) && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_FFMPEG))
|
||||||
{
|
{
|
||||||
ProgramExecutor::run(self::PROGRAM_NAME_FFMEPG,
|
ProgramExecutor::run(self::PROGRAM_NAME_FFMEPG,
|
||||||
[
|
[
|
||||||
|
|
|
@ -37,7 +37,7 @@ class NetworkingService
|
||||||
if ($customFileName)
|
if ($customFileName)
|
||||||
$this->httpHelper->setHeader('Content-Disposition', 'inline; filename="' . $customFileName . '"');
|
$this->httpHelper->setHeader('Content-Disposition', 'inline; filename="' . $customFileName . '"');
|
||||||
|
|
||||||
if (strtotime($ifModifiedSince) === $lastModified or $eTagHeader === $eTag)
|
if (strtotime($ifModifiedSince) === $lastModified || $eTagHeader === $eTag)
|
||||||
{
|
{
|
||||||
$this->httpHelper->setResponseCode(304);
|
$this->httpHelper->setResponseCode(304);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class NetworkingService
|
||||||
while (!feof($srcHandle))
|
while (!feof($srcHandle))
|
||||||
{
|
{
|
||||||
$buffer = fread($srcHandle, 4 * 1024);
|
$buffer = fread($srcHandle, 4 * 1024);
|
||||||
if ($maxBytes !== null and strlen($result) > $maxBytes)
|
if ($maxBytes !== null && strlen($result) > $maxBytes)
|
||||||
{
|
{
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
'File is too big (maximum size: %s)',
|
'File is too big (maximum size: %s)',
|
||||||
|
|
|
@ -69,7 +69,7 @@ class PostFeatureService
|
||||||
{
|
{
|
||||||
$previousFeaturedPost = $this->getFeaturedPost();
|
$previousFeaturedPost = $this->getFeaturedPost();
|
||||||
|
|
||||||
if (($previousFeaturedPost === null) or ($previousFeaturedPost->getId() !== $post->getId()))
|
if (($previousFeaturedPost === null) || ($previousFeaturedPost->getId() !== $post->getId()))
|
||||||
{
|
{
|
||||||
$post->setLastFeatureTime($this->timeService->getCurrentTime());
|
$post->setLastFeatureTime($this->timeService->getCurrentTime());
|
||||||
$post->setFeatureCount($post->getFeatureCount() + 1);
|
$post->setFeatureCount($post->getFeatureCount() + 1);
|
||||||
|
|
|
@ -342,7 +342,7 @@ class PostService
|
||||||
if (!$userSettings)
|
if (!$userSettings)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!empty($userSettings->listPosts) and !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_SAFETY)))
|
if (!empty($userSettings->listPosts) && !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_SAFETY)))
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
if (!TypeHelper::toBool($userSettings->listPosts->safe))
|
if (!TypeHelper::toBool($userSettings->listPosts->safe))
|
||||||
|
@ -363,7 +363,7 @@ class PostService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($userSettings->hideDownvoted) and !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_USER_SCORE)))
|
if (!empty($userSettings->hideDownvoted) && !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_USER_SCORE)))
|
||||||
{
|
{
|
||||||
$requirementValue = new RequirementCompositeValue();
|
$requirementValue = new RequirementCompositeValue();
|
||||||
$requirementValue->setValues([$currentUser->getName(), -1]);
|
$requirementValue->setValues([$currentUser->getName(), -1]);
|
||||||
|
@ -379,7 +379,7 @@ class PostService
|
||||||
{
|
{
|
||||||
$checksumToCheck = $parent->getContentChecksum();
|
$checksumToCheck = $parent->getContentChecksum();
|
||||||
$postWithThisChecksum = $this->postDao->findByContentChecksum($checksumToCheck);
|
$postWithThisChecksum = $this->postDao->findByContentChecksum($checksumToCheck);
|
||||||
if ($postWithThisChecksum and $postWithThisChecksum->getId() !== $parent->getId())
|
if ($postWithThisChecksum && $postWithThisChecksum->getId() !== $parent->getId())
|
||||||
throw new \DomainException('Duplicate post: ' . $postWithThisChecksum->getIdMarkdown());
|
throw new \DomainException('Duplicate post: ' . $postWithThisChecksum->getIdMarkdown());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class PostSnapshotProvider implements ISnapshotProvider
|
||||||
static $featuredPostParam = null;
|
static $featuredPostParam = null;
|
||||||
if ($featuredPostParam === null)
|
if ($featuredPostParam === null)
|
||||||
$featuredPostParam = $this->globalParamDao->findByKey(GlobalParam::KEY_FEATURED_POST);
|
$featuredPostParam = $this->globalParamDao->findByKey(GlobalParam::KEY_FEATURED_POST);
|
||||||
$isFeatured = ($featuredPostParam and intval($featuredPostParam->getValue()) === $post->getId());
|
$isFeatured = ($featuredPostParam && intval($featuredPostParam->getValue()) === $post->getId());
|
||||||
|
|
||||||
$flags = [];
|
$flags = [];
|
||||||
if ($post->getFlags() & Post::FLAG_LOOP)
|
if ($post->getFlags() & Post::FLAG_LOOP)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PrivilegeService
|
||||||
$loggedInUser = $this->authService->getLoggedInUser();
|
$loggedInUser = $this->authService->getLoggedInUser();
|
||||||
if ($userIdentifier instanceof User)
|
if ($userIdentifier instanceof User)
|
||||||
{
|
{
|
||||||
return $loggedInUser->getId() and ($loggedInUser->getId() === $userIdentifier->getId());
|
return $loggedInUser->getId() && ($loggedInUser->getId() === $userIdentifier->getId());
|
||||||
}
|
}
|
||||||
elseif (is_string($userIdentifier))
|
elseif (is_string($userIdentifier))
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,12 +59,12 @@ class ScoreService
|
||||||
|
|
||||||
public function setUserScore(User $user, Entity $entity, $scoreValue)
|
public function setUserScore(User $user, Entity $entity, $scoreValue)
|
||||||
{
|
{
|
||||||
if ($scoreValue !== 1 and $scoreValue !== 0 and $scoreValue !== -1)
|
if ($scoreValue !== 1 && $scoreValue !== 0 && $scoreValue !== -1)
|
||||||
throw new \DomainException('Bad score');
|
throw new \DomainException('Bad score');
|
||||||
|
|
||||||
$transactionFunc = function() use ($user, $entity, $scoreValue)
|
$transactionFunc = function() use ($user, $entity, $scoreValue)
|
||||||
{
|
{
|
||||||
if (($scoreValue !== 1) and ($entity instanceof Post))
|
if (($scoreValue !== 1) && ($entity instanceof Post))
|
||||||
$this->favoritesDao->delete($user, $entity);
|
$this->favoritesDao->delete($user, $entity);
|
||||||
|
|
||||||
return $this->scoreDao->setUserScore($user, $entity, $scoreValue);
|
return $this->scoreDao->setUserScore($user, $entity, $scoreValue);
|
||||||
|
|
|
@ -212,7 +212,7 @@ class TagService
|
||||||
private function updateTagName(Tag $tag, $newName)
|
private function updateTagName(Tag $tag, $newName)
|
||||||
{
|
{
|
||||||
$otherTag = $this->tagDao->findByName($newName);
|
$otherTag = $this->tagDao->findByName($newName);
|
||||||
if ($otherTag and $otherTag->getId() !== $tag->getId())
|
if ($otherTag && $otherTag->getId() !== $tag->getId())
|
||||||
throw new \DomainException('Tag with this name already exists.');
|
throw new \DomainException('Tag with this name already exists.');
|
||||||
$tag->setName($newName);
|
$tag->setName($newName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ class ThumbnailService
|
||||||
{
|
{
|
||||||
$sourcePath = $this->fileDao->getFullPath($sourceName);
|
$sourcePath = $this->fileDao->getFullPath($sourceName);
|
||||||
|
|
||||||
if ($format === IImageManipulator::FORMAT_JPEG and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_JPEGOPTIM))
|
if ($format === IImageManipulator::FORMAT_JPEG && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_JPEGOPTIM))
|
||||||
{
|
{
|
||||||
ProgramExecutor::run(
|
ProgramExecutor::run(
|
||||||
self::PROGRAM_NAME_JPEGOPTIM,
|
self::PROGRAM_NAME_JPEGOPTIM,
|
||||||
|
@ -125,7 +125,7 @@ class ThumbnailService
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($format === IImageManipulator::FORMAT_PNG and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_OPTIPNG))
|
elseif ($format === IImageManipulator::FORMAT_PNG && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_OPTIPNG))
|
||||||
{
|
{
|
||||||
ProgramExecutor::run(
|
ProgramExecutor::run(
|
||||||
self::PROGRAM_NAME_OPTIPNG,
|
self::PROGRAM_NAME_OPTIPNG,
|
||||||
|
|
|
@ -313,7 +313,7 @@ class UserService
|
||||||
private function assertNoUserWithThisName(User $owner, $nameToCheck)
|
private function assertNoUserWithThisName(User $owner, $nameToCheck)
|
||||||
{
|
{
|
||||||
$userWithThisName = $this->userDao->findByName($nameToCheck);
|
$userWithThisName = $this->userDao->findByName($nameToCheck);
|
||||||
if ($userWithThisName and $userWithThisName->getId() !== $owner->getId())
|
if ($userWithThisName && $userWithThisName->getId() !== $owner->getId())
|
||||||
throw new \DomainException('User with this name already exists.');
|
throw new \DomainException('User with this name already exists.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ class UserService
|
||||||
if (!$emailToCheck)
|
if (!$emailToCheck)
|
||||||
return;
|
return;
|
||||||
$userWithThisEmail = $this->userDao->findByEmail($emailToCheck);
|
$userWithThisEmail = $this->userDao->findByEmail($emailToCheck);
|
||||||
if ($userWithThisEmail and $userWithThisEmail->getId() !== $owner->getId())
|
if ($userWithThisEmail && $userWithThisEmail->getId() !== $owner->getId())
|
||||||
throw new \DomainException('User with this e-mail already exists.');
|
throw new \DomainException('User with this e-mail already exists.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ final class ImageManipulatorTest extends AbstractTestCase
|
||||||
|
|
||||||
private static function getAutoImageManipulator()
|
private static function getAutoImageManipulator()
|
||||||
{
|
{
|
||||||
if (extension_loaded('gd') and extension_loaded('imagick'))
|
if (extension_loaded('gd') && extension_loaded('imagick'))
|
||||||
{
|
{
|
||||||
return new ImageManipulator(
|
return new ImageManipulator(
|
||||||
self::getImagickImageManipulator(),
|
self::getImagickImageManipulator(),
|
||||||
|
|
Loading…
Reference in a new issue