Skip to content

Commit 8d80111

Browse files
authored
Merge pull request #436 from phalcon/3.x
3.x
2 parents 82e2f5c + 954cb82 commit 8d80111

File tree

8 files changed

+29
-20
lines changed

8 files changed

+29
-20
lines changed

app/library/Mail/SendSpool.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ class SendSpool extends Injectable
3636
public function sendRemaining()
3737
{
3838
$notifications = Notifications::find([
39-
'conditions' => 'sent = ?1 AND created_at < ?2',
39+
'conditions' => 'sent = ?1 AND UNIX_TIMESTAMP() - created_at <= ?2',
4040
'order' => 'created_at DESC',
4141
'limit' => 1000,
4242
'bind' => [
43-
1 => Notifications::STATUS_NOT_SENT,
44-
// Max 7 days
45-
2 => time() - 7 * 24 * 60 * 60,
43+
1 => Notifications::STATUS_NOT_SENT, // Only unsent messages
44+
2 => 7 * 24 * 60 * 60, // For last 7 days
4645
],
4746
]);
4847

app/library/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ class Version extends PhVersion
3535
protected static function _getVersion()
3636
{
3737
// @codingStandardsIgnoreEnd
38-
return [3, 4, 0, 0, 0];
38+
return [3, 4, 1, 0, 0];
3939
}
4040
}

app/model/Posts.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,29 +273,34 @@ public function afterSave()
273273
{
274274
$this->clearCache();
275275

276+
if (!container()->has('session')) {
277+
return;
278+
}
279+
280+
if (!container('session')->isStarted()) {
281+
return;
282+
}
283+
276284
// In case of updating post through creating PostsViews
277-
if (!$this->getDI()->getShared('session')->has('identity')) {
285+
if (!container('session')->has('identity')) {
278286
return;
279287
}
280288

281289
$history = new PostsHistory([
282290
'posts_id' => $this->id,
283-
'users_id' => $this->getDI()->getShared('session')->get('identity'),
291+
'users_id' => container('session')->get('identity'),
284292
'content' => $this->content,
285293
]);
286294

287295
if (!$history->save()) {
288-
/** @var \Phalcon\Logger\AdapterInterface $logger */
289-
$logger = $this->getDI()->get('logger');
290-
$messages = $history->getMessages();
291296
$reason = [];
292297

293-
foreach ($messages as $message) {
298+
foreach ($history->getMessages() as $message) {
294299
/** @var \Phalcon\Mvc\Model\MessageInterface $message */
295300
$reason[] = $message->getMessage();
296301
}
297302

298-
$logger->error('Unable to store post history. Post id: {id}. Reason: {reason}', [
303+
container('logger')->error('Unable to store post history. Post id: {id}. Reason: {reason}', [
299304
'id' => $this->id,
300305
'reason' => implode('. ', $reason)
301306
]);

app/model/PostsReplies.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,14 @@ public function afterSave()
248248
{
249249
$this->clearCache();
250250

251+
$usersId = $this->users_id;
252+
if (container()->has('session') && container('session')->isStarted() && container('session')->has('identity')) {
253+
$usersId = container('session')->get('identity');
254+
}
255+
251256
$history = new PostsRepliesHistory();
252257
$history->posts_replies_id = $this->id;
253-
$usersId = $this->getDI()->getSession()->get('identity');
254-
$history->users_id = $usersId ? $usersId : $this->users_id;
258+
$history->users_id = $usersId;
255259
$history->content = $this->content;
256260

257261
$history->save();

config/session.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
'weight' => env('MEMCACHED_WEIGHT', 100),
1515
]
1616
],
17+
// Client options must be instance of array
18+
'client' => [
19+
20+
],
1721
],
1822

1923
'redis' => [

tests/console/HelpCept.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$I->wantToTest('getting help from command line');
99

1010
$output=<<<OUT
11-
Phosphorum 3.4.0
11+
Phosphorum 3.4.1
1212
Usage: php forum [command <arguments>] [--help | -H] [--version | -V] [--list]
1313
OUT;
1414

tests/console/NotificationsCest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ public function checkNotifications(ConsoleTester $I)
113113
];
114114

115115
if (!isset($this->messages[0]) || empty($this->messages)) {
116-
// FIXME:
117-
throw new PHPUnit_Framework_SkippedTestError(
118-
"Failed to test notifications.\n" . var_export($this->messages, true)
119-
);
116+
$I->fail("Failed to test notifications.\n" . print_r($this->messages, true));
120117
}
121118

122119
$message = $this->messages[0];

tests/console/VersionCept.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$sha = substr(trim($I->runShellCommand('git rev-parse HEAD')), 0, 7);
1212

1313
$output=<<<OUT
14-
Phosphorum version 3.4.0, git commit $sha
14+
Phosphorum version 3.4.1, git commit $sha
1515
OUT;
1616

1717
$I->runShellCommand('php forum -V');

0 commit comments

Comments
 (0)