Skip to content

Commit 1170c45

Browse files
authored
Merge pull request #5 from netgen/NGSTACK-913-prevent-trashed-content-being-processed
Ibexa scheduled visibility fixes
2 parents c11032b + e2d9f78 commit 1170c45

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.php-cs-fixer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,49 @@
88

99
$config = new PhpCsFixer\Config();
1010
return $config
11+
->setRiskyAllowed(true)
1112
->setRules([
12-
'@PSR12' => true,
13-
'@PSR12:risky' => true,
13+
'@PER' => true,
14+
'@PER:risky' => true,
1415
'@PhpCsFixer' => true,
1516
'@PhpCsFixer:risky' => true,
1617

1718
// Overrides for rules included in PhpCsFixer rule sets
1819
'concat_space' => ['spacing' => 'one'],
20+
'fully_qualified_strict_types' => ['phpdoc_tags' => []],
1921
'method_chaining_indentation' => false,
2022
'multiline_whitespace_before_semicolons' => false,
2123
'native_function_invocation' => ['include' => ['@all']],
2224
'no_superfluous_phpdoc_tags' => false,
2325
'no_unset_on_property' => false,
2426
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
27+
'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'alpha'],
2528
'php_unit_internal_class' => false,
2629
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
2730
'php_unit_test_class_requires_covers' => false,
2831
'phpdoc_align' => false,
32+
'phpdoc_order' => ['order' => ['param', 'throws', 'return']],
2933
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
3034
'single_line_comment_style' => false,
31-
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
35+
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'match', 'parameters']],
3236
'yoda_style' => false,
33-
'php_unit_strict' => false,
34-
'php_unit_test_annotation' => false,
3537

3638
// Additional rules
37-
'return_assignment' => false,
3839
'date_time_immutable' => true,
3940
'declare_strict_types' => true,
4041
'global_namespace_import' => [
4142
'import_classes' => null,
4243
'import_constants' => true,
4344
'import_functions' => true,
4445
],
45-
'list_syntax' => ['syntax' => 'short'],
4646
'heredoc_indentation' => ['indentation' => 'same_as_start'],
4747
'mb_str_functions' => true,
4848
'native_constant_invocation' => true,
4949
'nullable_type_declaration_for_default_null_value' => true,
5050
'static_lambda' => true,
5151
'ternary_to_null_coalescing' => true,
5252
'use_arrow_functions' => true,
53-
])
53+
])
5454
->setRiskyAllowed(true)
5555
->setFinder($finder)
5656
;

bundle/Command/ScheduledVisibilityUpdateCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
1212
use Ibexa\Contracts\Core\Repository\LanguageService;
1313
use Ibexa\Contracts\Core\Repository\Repository;
14+
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
1415
use Ibexa\Contracts\Core\Repository\Values\Content\Language;
1516
use Netgen\Bundle\IbexaScheduledVisibilityBundle\Core\Configuration;
1617
use Netgen\Bundle\IbexaScheduledVisibilityBundle\Core\Exception\InvalidStateException;
@@ -30,6 +31,7 @@
3031

3132
use function count;
3233
use function sprintf;
34+
use function time;
3335

3436
final class ScheduledVisibilityUpdateCommand extends Command
3537
{
@@ -205,8 +207,10 @@ private function getQueryBuilder(?int $since, array $contentTypeIds): QueryBuild
205207
->select('id', 'initial_language_id')
206208
->from('ezcontentobject')
207209
->where('published != :unpublished')
210+
->andWhere('status != :trashed')
208211
->orderBy('id', 'ASC')
209-
->setParameter('unpublished', 0);
212+
->setParameter('unpublished', 0)
213+
->setParameter('trashed', ContentInfo::STATUS_TRASHED);
210214

211215
$this->applySince($queryBuilder, $since);
212216
$this->applyContentTypes($queryBuilder, $contentTypeIds);
@@ -254,6 +258,7 @@ private function getPager(?int $since): Pagerfanta
254258
->from('ezcontentobject')
255259
->where('published != :unpublished')
256260
->setParameter('unpublished', 0)
261+
->setParameter('trashed', ContentInfo::STATUS_TRASHED)
257262
->setMaxResults(1);
258263

259264
$this->applySince($queryBuilder, $since);

docs/reference/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ By default it is set to 1024.
3939
The command also has a ``since`` option that limits processing to content items modified since the given number of days.
4040
By default it is not set, which means all items will be processed.
4141
Command can be executed with: ``bin/console ngscheduledvisibility:update``.
42-
For this mechanism to work how it was intended, this command should be set as cron job.
42+
For this mechanism to work how it was intended, this command should be set as cron job with ``--no-interaction`` option.

0 commit comments

Comments
 (0)