Skip to content

Commit f09be94

Browse files
Update docker containers to create manticore indices. Fix some bugs and make forum work with strict mode for DB.
1 parent 16b5375 commit f09be94

14 files changed

+94
-75
lines changed

build/forums/forums.model.php

+18-10
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,8 @@ private function replyTopic(&$vars) {
13611361
$this->dao->query("START TRANSACTION");
13621362
$query = sprintf(
13631363
"
1364-
INSERT INTO `forums_posts` ( `threadid`, `create_time`, `message`,`IdWriter`,`IdFirstLanguageUsed`,`PostVisibility`)
1365-
VALUES ('%d', NOW(), '%s','%d',%d,'%s')
1364+
INSERT INTO `forums_posts` ( `threadid`, `create_time`, `message`,`IdWriter`,`IdFirstLanguageUsed`,`PostVisibility`, `IdContent`,`edit_count`)
1365+
VALUES ('%d', NOW(), '%s','%d',%d,'%s',0, 0)
13661366
",
13671367
$this->threadid,
13681368
$this->dao->escape($this->cleanupText($vars['topic_text'])),
@@ -1437,12 +1437,20 @@ public function newTopic(&$vars) {
14371437

14381438
/** @var PDBStatement_mysqli $statement */
14391439
$statement = $this->dao->prepare("
1440-
INSERT INTO `forums_posts` (
1441-
`create_time`, `message`,`IdWriter`,`IdFirstLanguageUsed`,`PostVisibility`)
1442-
VALUES (NOW(), ?, ?, ?, ?)
1440+
INSERT INTO `forums_posts`
1441+
(
1442+
`create_time`,
1443+
`message`,
1444+
`IdWriter`,
1445+
`IdFirstLanguageUsed`,
1446+
`PostVisibility`,
1447+
`PostDeleted`,
1448+
`IdContent`,
1449+
`edit_count`
1450+
)
1451+
VALUES (NOW(), ?, ?, ?, ?, 'NotDeleted', 0, 0)
14431452
");
14441453
$text = $this->cleanupText($vars['topic_text']);
1445-
$userId = $User->getId();
14461454
$memberId = $this->session->get("IdMember");
14471455
$language = $this->GetLanguageChoosen();
14481456
$statement->bindParam(1, $text);
@@ -1464,8 +1472,8 @@ public function newTopic(&$vars) {
14641472
$statement = $this->dao->prepare("
14651473
INSERT INTO `forums_threads` (
14661474
`title`, `first_postid`, `last_postid`,
1467-
`IdFirstLanguageUsed`,`IdGroup`,`ThreadVisibility`)
1468-
VALUES (?, ?, ?, ?, ?, ?)
1475+
`IdFirstLanguageUsed`,`IdGroup`,`ThreadVisibility`, `IdTitle`, `replies`, `views`, `stickyvalue`)
1476+
VALUES (?, ?, ?, ?, ?, ?, 0, 0, 0, 0)
14691477
");
14701478

14711479
$title = strip_tags($vars['topic_title']);
@@ -2004,8 +2012,8 @@ public function SubscribeThread($IdThread,$ParamIdMember=0) {
20042012
}
20052013
$key=MD5(rand(100000,900000)) ;
20062014
$query = "INSERT INTO
2007-
members_threads_subscribed(IdThread,IdSubscriber,UnSubscribeKey,notificationsEnabled)
2008-
VALUES(".$IdThread.",".$this->session->get("IdMember").",'".$this->dao->escape($key)."', 1)" ;
2015+
members_threads_subscribed(IdThread,IdSubscriber,UnSubscribeKey,notificationsEnabled,created)
2016+
VALUES(".$IdThread.",".$this->session->get("IdMember").",'".$this->dao->escape($key)."', 1,NOW())" ;
20092017
$s = $this->dao->query($query);
20102018
if (!$s) {
20112019
throw new PException('Forum->SubscribeThread failed !');

docker-compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ services:
6767
soft: -1
6868
hard: -1
6969
volumes:
70-
- ./data:/var/lib/manticore
70+
- manticore-data:/var/lib/manticore:rw
7171

7272
mailer:
7373
image: tophfr/mailcatcher
7474

7575
volumes:
7676
db-data: {}
77+
manticore-data: {}

docker/php/docker-entrypoint.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ "${1#-}" != "$1" ]; then
77
fi
88

99
if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
10-
PHP_INI_RECOMMENDED="$PHP_INI_DIR/php.ini-production"
10+
PHP_INI_RECOMMENDED="$PHP_INI_DIR/php.ini-production"
1111
if [ "$APP_ENV" != 'prod' ]; then
1212
PHP_INI_RECOMMENDED="$PHP_INI_DIR/php.ini-development"
1313
fi
@@ -27,6 +27,7 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
2727
fi
2828

2929
if [ "$APP_ENV" != 'prod' ] && [ ! -f VERSION ]; then
30+
git config --global --add safe.directory /srv/bewelcome
3031
git rev-parse --short HEAD > VERSION
3132
fi
3233

@@ -89,6 +90,11 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
8990
echo "yarn"
9091
yarn encore dev --mode=development
9192
fi
93+
94+
# create manticore indices
95+
echo "Manticore"
96+
bin/console manticore:indices:forum
97+
bin/console manticore:indices:geonames
9298
fi
9399
echo "docker-php"
94100

fixtures/newlocations.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ App\Entity\NewLocation:
1212
countryId: 'DE'
1313
NewCountryReferenceIndonesia:
1414
name: 'Indonesia'
15-
latitude: 0.0
16-
longitude: 0.0
15+
latitude: -5.0
16+
longitude: 120.0
1717
geonameId: 1643084
1818
featureClass: A
1919
featureCode: PCLI
@@ -31,6 +31,8 @@ App\Entity\NewLocation:
3131
population: 12
3232
modificationDate: '<DateTime()>'
3333
country: '@NewCountryReferenceGermany'
34+
latitude: 52.5
35+
longitude: 13.41667
3436
NewAdmin1ReferenceProvinsiPapua:
3537
geonameId: 1643012
3638
name: 'Provinsi Papua'
@@ -40,6 +42,8 @@ App\Entity\NewLocation:
4042
admin1Id: '36'
4143
countryId: '@NewCountryReferenceIndonesia->countryId'
4244
modificationDate: '<DateTime()>'
45+
latitude: -2.59026
46+
longitude: 139.41564
4347
NewBerlin:
4448
name: 'Berlin'
4549
latitude: 52.5243700

modules/i18n/lib/words.lib.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,8 @@ function InsertInMTrad($ss,$TableColumn,$IdRecord, $_IdMember = 0, $_IdLanguage
906906
}
907907
}
908908

909-
$str = "insert into memberstrads(TableColumn,IdRecord,IdLanguage,IdOwner,IdTrad,IdTranslator,Sentence,created) ";
910-
$str .= "Values('".$TableColumn."',".$IdRecord.",". $IdLanguage . "," . $IdOwner . "," . $IdTrad . "," . $IdTranslator . ",\"" . $Sentence . "\",now())";
909+
$str = "insert into memberstrads(TableColumn,IdRecord,IdLanguage,IdOwner,IdTrad,IdTranslator,Sentence,created,Type) ";
910+
$str .= "Values('".$TableColumn."',".$IdRecord.",". $IdLanguage . "," . $IdOwner . "," . $IdTrad . "," . $IdTranslator . ",\"" . $Sentence . "\",now(),'Member')";
911911
$s = $this->_dao->query($str);
912912
if (!$s) {
913913
// Unlock table before throwing exception!
@@ -1053,8 +1053,8 @@ function InsertInFTrad($ss,$TableColumn,$IdRecord, $_IdMember = 0, $_IdLanguage
10531053
$IdOwner = $IdMember;
10541054
$IdTranslator = $this->session->get('IdMember'); // the recorded translator will always be the current logged member
10551055
$Sentence = $ss;
1056-
$str = "insert into translations(TableColumn,IdRecord,IdLanguage,IdOwner,IdTrad,IdTranslator,Sentence,created) ";
1057-
$str .= "Values('".$TableColumn."',".$IdRecord.",". $IdLanguage . "," . $IdOwner . "," . $IdTrad . "," . $IdTranslator . ",\"" . $Sentence . "\",now())";
1056+
$str = "insert into translations(TableColumn,IdRecord,IdLanguage,IdOwner,IdTrad,IdTranslator,Sentence,created,Type) ";
1057+
$str .= "Values('".$TableColumn."',".$IdRecord.",". $IdLanguage . "," . $IdOwner . "," . $IdTrad . "," . $IdTranslator . ",\"" . $Sentence . "\",now(),'Member')";
10581058
$s = $this->_dao->query($str);
10591059
if (!$s) {
10601060
throw new PException('Failed in InsertInFTrad for inserting in translations!');

src/Command/ManticoreIndicesForumCommand.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ private function addForumDocuments(Index $index, OutputInterface $output)
132132
___SQL);
133133

134134
$count = ($stmt->fetchNumeric())[0];
135+
if ($count !== 0) {
136+
$progressBar = $this->getProgressBar($output, $count);
135137

136-
$progressBar = $this->getProgressBar($output, $count);
137-
138-
$firstResult = 0;
139-
do {
140-
$query = $this->entityManager->createNativeQuery(<<<___SQL
138+
$firstResult = 0;
139+
do {
140+
$query = $this->entityManager->createNativeQuery(<<<___SQL
141141
SELECT
142142
fp.id as post_id,
143143
fp.PostDeleted as post_deleted,
@@ -156,15 +156,16 @@ private function addForumDocuments(Index $index, OutputInterface $output)
156156
JOIN languages l ON ftr.IdLanguage = l.id
157157
LIMIT {$firstResult}, {$this->chunkSize}
158158
___SQL
159-
, $this->getResultSetMappingForForumIndex());
159+
, $this->getResultSetMappingForForumIndex());
160160

161-
$addDocumentsCount = $this->addForumDocumentsToIndex($index, $query, $progressBar);
161+
$addDocumentsCount = $this->addForumDocumentsToIndex($index, $query, $progressBar);
162162

163-
$firstResult += $this->chunkSize;
164-
} while ($addDocumentsCount > 0);
163+
$firstResult += $this->chunkSize;
164+
} while ($addDocumentsCount > 0);
165165

166-
$progressBar->finish();
167-
$this->io->newLine();
166+
$progressBar->finish();
167+
$this->io->newLine();
168+
}
168169
}
169170

170171
private function addForumDocumentsToIndex(Index $index, NativeQuery $query, ProgressBar $progress): int

src/Command/ManticoreIndicesGeonamesCommand.php

+31-30
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,12 @@ private function addGeonamesDocuments(Index $index, OutputInterface $output)
127127
___SQL);
128128

129129
$count = ($stmt->fetchNumeric())[0];
130-
$this->io->note($count);
130+
if ($count !== 0) {
131+
$progressBar = $this->getProgressBar($output, $count);
131132

132-
$progressBar = $this->getProgressBar($output, $count);
133-
134-
$firstResult = 0;
135-
do {
136-
$query = $this->entityManager->createNativeQuery(<<<___SQL
133+
$firstResult = 0;
134+
do {
135+
$query = $this->entityManager->createNativeQuery(<<<___SQL
137136
SELECT
138137
g.geonameid AS geonameid,
139138
g.`name` AS name,
@@ -162,15 +161,16 @@ private function addGeonamesDocuments(Index $index, OutputInterface $output)
162161
ON (g.geonameid = membercounts.IdCity)
163162
LIMIT {$firstResult}, {$this->chunkSize}
164163
___SQL
165-
, $this->getResultSetMappingForGeonamesIndex());
164+
, $this->getResultSetMappingForGeonamesIndex());
166165

167-
$addDocumentsCount = $this->addGeonamesDocumentsToIndex($index, $query, $progressBar);
166+
$addDocumentsCount = $this->addGeonamesDocumentsToIndex($index, $query, $progressBar);
168167

169-
$firstResult += $this->chunkSize;
170-
} while ($addDocumentsCount > 0);
168+
$firstResult += $this->chunkSize;
169+
} while ($addDocumentsCount > 0);
171170

172-
$progressBar->finish();
173-
$this->io->newLine();
171+
$progressBar->finish();
172+
$this->io->newLine();
173+
}
174174
}
175175

176176
private function addAlternateNamesDocuments(Index $index, OutputInterface $output)
@@ -188,13 +188,13 @@ private function addAlternateNamesDocuments(Index $index, OutputInterface $outpu
188188
___SQL);
189189

190190
$count = ($stmt->fetchNumeric())[0];
191+
if ($count !== 0) {
192+
$progressBar = $this->getProgressBar($output, $count);
193+
$progressBar->start();
191194

192-
$progressBar = $this->getProgressBar($output, $count);
193-
$progressBar->start();
194-
195-
$firstResult = 0;
196-
do {
197-
$query = $this->entityManager->createNativeQuery(<<<___SQL
195+
$firstResult = 0;
196+
do {
197+
$query = $this->entityManager->createNativeQuery(<<<___SQL
198198
SELECT
199199
g.geonameid,
200200
gt.`content` AS name,
@@ -225,15 +225,16 @@ private function addAlternateNamesDocuments(Index $index, OutputInterface $outpu
225225
ON (g.geonameid = membercounts.IdCity)
226226
LIMIT {$firstResult}, {$this->chunkSize}
227227
___SQL
228-
, $this->getResultSetMappingForGeonamesIndex());
228+
, $this->getResultSetMappingForGeonamesIndex());
229229

230-
$addDocumentsCount = $this->addGeonamesDocumentsToIndex($index, $query, $progressBar);
230+
$addDocumentsCount = $this->addGeonamesDocumentsToIndex($index, $query, $progressBar);
231231

232-
$firstResult += $this->chunkSize;
233-
} while ($addDocumentsCount > 0);
232+
$firstResult += $this->chunkSize;
233+
} while ($addDocumentsCount > 0);
234234

235-
$progressBar->finish();
236-
$this->io->newLine();
235+
$progressBar->finish();
236+
$this->io->newLine();
237+
}
237238
}
238239

239240
private function addGeonamesDocumentsToIndex(Index $index, NativeQuery $query, ProgressBar $progress): int
@@ -255,16 +256,16 @@ private function addGeonamesDocumentsToIndex(Index $index, NativeQuery $query, P
255256
$documents[] = [
256257
'geoname_id' => $location['geonameid'],
257258
'name' => $location['name'],
258-
'country' => $location['country'],
259+
'country' => $location['country'] ?? 0,
259260
'isPlace' => $isPlace,
260261
'isAdmin' => $isAdmin,
261262
'isCountry' => $isCountry,
262263
'locale' => $this->adaptLocale($location['locale']),
263-
'admin1' => $location['admin1'],
264-
'admin2' => $location['admin2'],
265-
'admin3' => $location['admin3'],
266-
'admin4' => $location['admin4'],
267-
'population' => $location['population'],
264+
'admin1' => $location['admin1'] ?? 0,
265+
'admin2' => $location['admin2'] ?? 0,
266+
'admin3' => $location['admin3'] ?? 0,
267+
'admin4' => $location['admin4'] ?? 0,
268+
'population' => $location['population'] ?? 0,
268269
'member_count' => $location['member_count'],
269270
];
270271
$progress->advance();

src/Controller/Admin/GroupController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ public function __construct(Mailer $mailer)
5555
public function approveGroups()
5656
{
5757
if (!$this->isGranted(Member::ROLE_ADMIN_GROUP)) {
58-
throw $this->createAccessDeniedException('You need to have Group right to access this.');
58+
throw $this->createAccessDeniedException('You need to have Group right to access this.1');
5959
}
6060

6161
if (!$this->hasGroupRightLevel(10)) {
62-
throw $this->createAccessDeniedException('You need to have Group right to access this.');
62+
$admin = $this->getUser();
63+
$level = $admin->getLevelForRight(Member::ROLE_ADMIN_GROUP);
64+
throw $this->createAccessDeniedException('You need to have level 10 to access this.' . $level);
6365
}
6466

6567
// Fetch unapproved groups and decide on their fate

src/Controller/GroupController.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,13 @@ public function withdrawInviteMemberGroup(Request $request, Group $group, Member
333333

334334
/**
335335
* @Route("/new/group", name="new_group")
336-
*
337-
* @throws Exception
338-
*
339-
* @return Response
340336
*/
341-
public function createGroup(Request $request, Logger $logger)
337+
public function createGroup(Request $request, Logger $logger): Response
342338
{
343339
/** @var Member $member */
344340
$member = $this->getUser();
345341

346-
if (MemberStatusType::ACCOUNT_ACTIVATED !== $member->getStatus()) {
342+
if (MemberStatusType::ACCOUNT_ACTIVATED === $member->getStatus()) {
347343
$this->addTranslatedFlash('notice', 'flash.group.not.confirmed');
348344

349345
return $this->redirectToRoute('groups_mygroups');

src/Entity/ForumPost.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class ForumPost implements ObjectManagerAware
4848
* @var ForumThread
4949
*
5050
* @ORM\ManyToOne(targetEntity="ForumThread", inversedBy="posts")
51-
* @ORM\JoinColumn(name="threadid", referencedColumnName="id")
51+
* @ORM\JoinColumn(name="threadid", referencedColumnName="id", nullable=true)
5252
*/
53-
private $thread;
53+
private $thread = null;
5454

5555
/**
5656
* @var string

src/Entity/Member.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ public function getLevelForRight($nameOfRight): int
12691269

12701270
/** @var RightVolunteer $volunteerRight */
12711271
foreach ($volunteerRights->getIterator() as $volunteerRight) {
1272-
if ($volunteerRight->getRight()->getName() === $nameOfRight) {
1272+
if (strtolower($volunteerRight->getRight()->getName()) === $nameOfRight) {
12731273
$level = $volunteerRight->getLevel();
12741274
}
12751275
}

src/Entity/MemberThreadSubscription.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MemberThreadSubscription
4848
/**
4949
* @var string
5050
*
51-
* @ORM\Column(name="UnSubscribeKey", type="string", length=20, nullable=false)
51+
* @ORM\Column(name="UnSubscribeKey", type="string", length=32, nullable=false)
5252
*/
5353
private $unsubscribeKey;
5454

src/Entity/NewLocation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function setLatitude(float $latitude): self
220220
return $this;
221221
}
222222

223-
public function getLatitude(): float
223+
public function getLatitude(): ?float
224224
{
225225
return $this->latitude;
226226
}
@@ -232,7 +232,7 @@ public function setLongitude($longitude): self
232232
return $this;
233233
}
234234

235-
public function getLongitude(): float
235+
public function getLongitude(): ?float
236236
{
237237
return $this->longitude;
238238
}

src/Entity/Translation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class Translation
5454
/**
5555
* @var DateTime
5656
*
57-
* @ORM\Column(name="updated", type="datetime", nullable=false)
57+
* @ORM\Column(name="updated", type="datetime", nullable=true)
5858
*/
59-
private $updated;
59+
private $updated = null;
6060

6161
/**
6262
* @var DateTime

0 commit comments

Comments
 (0)