Bug #36571
Relation list crashes, if one Friends Account is deleted,
| Status: | Needs Feedback | Start date: | 2012-04-25 | |
|---|---|---|---|---|
| Priority: | Must have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | important tasks | |||
| Target version: | First TER version | |||
| Votes: | 1 (View) |
Description
1) in Relation controller listSomeAction i fixed this small bug, that happens, when a usrrelation exists to a deleted user.
as $relation->getRequestedUser() is not an Objekt, it crashes in this line:
if ($relation->getRequestedUser()->getUid() == $this->getRequestedUser()->getUid()) {
so Just add inside the foreach loop
if ( is_object($relation->getRequestedUser())) {
....
}
2) to be perfect, add that line after the foreach loop:
$relationNumber = count($users) ;
and delete the Setting by $relations before the foreach loop
so also the relations count Value is corrected...
3) and absolute perfekt, if there is a default Value in setup.txt for the listSome Action Limit :
plugin.tx_community {
settings {
relations.listSome.limit = 1
******
Fixed action:
/**
* Display some of user's friends
/
public function listSomeAction() {
$relations = $this->repositoryService->get('relation')->findRelationsForUser($this->getRequestedUser(), $this->settings['relations']['listSome']['limit']);
/// $relationNumber = $relations->count(); // TODO: this only counts until the limit is reached! solved see below ?
$users = array();
foreach($relations as $relation) { / @var $relation Tx_Community_Domain_Model_Relation */
if ( is_object($relation->getRequestedUser())) {
if ($relation->getRequestedUser()->getUid() == $this->getRequestedUser()->getUid()) {
$users[$relation->getUid()] = $relation->getInitiatingUser();
} else {
$users[$relation->getUid()] = $relation->getRequestedUser();
}
}
}
$relationNumber = count($users) ;
$this->view->assign('usersRelations', $users);
$this->view->assign('countRelations', $relationNumber);
}
History
Updated by Jörg Velletti about 1 year ago
- File List.html added
PS: same Problem in list ALL Friends of someone else if one of the friends is deleted i fe_users.
so i added in /ext/community/Resources/Private/Templates/Relation/List.html
in line 26 after
<!-- we view someone else's friends -->
this condition
<f:if condition="{user}">
and of Course closing the </f:if> at the end ... before the
</f:alias>
see also attached file
Updated by Tymoteusz Motylewski about 1 year ago
- Status changed from New to Needs Feedback
when a usrrelation exists to a deleted user.
How did you manage to have relation to deleted user?
Relation should be marked as deleted after you delete user in backend or in frontend.
Updated by Jörg Velletti about 1 year ago
if some one changes userstatus to deteled in Typo3 backend, this should not happen because of your hook.
But this could happen in many cases, that you connect to a user, and after a while, the connection breaks, because
user is not in fe_users (or only with stauts deleted)
Possible scenarios:
- if the FE_User repository is generated/updated by an external Database Connector. (you remember that there are two woman from a FH/TU/UNI reading the users addresses from LDAB. we also have our fe user table in an external non typo3 db and just read the users data from there after Login. if the user is deleted in the extenal DB
- if some one imports a db backup of not all tables
- if db is corrupted because of server break during the the operation
- if user can deleted his Account in Frontend (using other extension for registration/Account management than community)
.. and maybe more ...