Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_news
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_news
Commits
4bc2da8a
Commit
4bc2da8a
authored
4 years ago
by
Michael Kessler
Browse files
Options
Downloads
Patches
Plain Diff
[BUGFIX] Fix NewsByAuthors crashing when multiple authors are given
parent
b401960d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!26
[BUGFIX] Fix NewsByAuthors crashing when multiple authors are given
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/NewsByAuthorController.php
+16
-13
16 additions, 13 deletions
Classes/Controller/NewsByAuthorController.php
Classes/Domain/Repository/NewsRepository.php
+19
-4
19 additions, 4 deletions
Classes/Domain/Repository/NewsRepository.php
with
35 additions
and
17 deletions
Classes/Controller/NewsByAuthorController.php
+
16
−
13
View file @
4bc2da8a
...
...
@@ -79,25 +79,28 @@ class NewsByAuthorController extends AbstractController {
$categories
=
$newsMetaData
=
[];
$categoryRepository
=
$this
->
objectManager
->
get
(
CategoryRepository
::
class
);
$excludedNewsIds
=
GeneralUtility
::
intExplode
(
','
,
$this
->
settings
[
'excludedNews'
]);
foreach
(
$news
as
$newsEntry
)
{
/** @var News $newsEntry */
if
(
in_array
(
$newsEntry
->
getUid
(),
$excludedNewsIds
,
TRUE
))
{
continue
;
}
$categoryId
=
$newsEntry
->
getPid
();
if
(
!
isset
(
$categories
[
$categoryId
]))
{
$category
=
$categoryRepository
->
findByUid
(
$categoryId
);
if
(
!
$category
)
{
foreach
(
$news
as
$newsResult
)
{
foreach
(
$newsResult
as
$newsEntry
)
{
/** @var News $newsEntry */
if
(
in_array
(
$newsEntry
->
getUid
(),
$excludedNewsIds
,
TRUE
))
{
continue
;
}
$categories
[
$categoryId
]
=
$category
;
}
$categoryId
=
$newsEntry
->
getPid
();
if
(
!
isset
(
$categories
[
$categoryId
]))
{
$category
=
$categoryRepository
->
findByUid
(
$categoryId
);
if
(
!
$category
)
{
continue
;
}
$newsMetaData
[]
=
$this
->
getMetaDataForNews
(
$newsEntry
,
$categories
[
$categoryId
]);
$categories
[
$categoryId
]
=
$category
;
}
$newsMetaData
[]
=
$this
->
getMetaDataForNews
(
$newsEntry
,
$categories
[
$categoryId
]);
}
}
$this
->
view
->
assign
(
'newsMetaData'
,
$newsMetaData
);
$this
->
view
->
assign
(
'authors'
,
$authors
);
}
...
...
This diff is collapsed.
Click to expand it.
Classes/Domain/Repository/NewsRepository.php
+
19
−
4
View file @
4bc2da8a
...
...
@@ -40,17 +40,32 @@ class NewsRepository extends AbstractRepository {
* Finds all news by the given authors.
*
* @param array $authorIds
*
* @return QueryResultInterface|NULL
* @return array Contains only TYPO3\CMS\Extbase\Persistence\Generic\QueryResult items
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public
function
findAllByNewsAuthor
(
array
$authorIds
):
?
QueryResultInterface
{
public
function
findAllByNewsAuthor
(
array
$authorIds
):
?
array
{
if
(
count
(
$authorIds
)
<=
0
)
{
return
NULL
;
}
$result
=
[];
foreach
(
$authorIds
as
$authorId
)
{
$result
[]
=
$this
->
findNewsByAuthor
(
$authorId
);
}
return
$result
;
}
/**
* Find all news by the given author
*
* @param int $authorId
* @return QueryResultInterface|null
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public
function
findNewsByAuthor
(
int
$authorId
):
?QueryResultInterface
{
$query
=
$this
->
createQuery
();
$query
->
matching
(
$query
->
contains
(
'newsAuthor'
,
$authorId
s
));
$query
->
matching
(
$query
->
contains
(
'newsAuthor'
,
$authorId
));
return
$query
->
execute
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment