forked from phpbb/phpbb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prep-release-3.3.12' into 3.3.x
- Loading branch information
Showing
8 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
phpBB/phpbb/db/migration/data/v33x/add_user_last_active.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* | ||
* This file is part of the phpBB Forum Software package. | ||
* | ||
* @copyright (c) phpBB Limited <https://www.phpbb.com> | ||
* @license GNU General Public License, version 2 (GPL-2.0) | ||
* | ||
* For full copyright and license information, please see | ||
* the docs/CREDITS.txt file. | ||
* | ||
*/ | ||
|
||
namespace phpbb\db\migration\data\v33x; | ||
|
||
use phpbb\db\migration\migration; | ||
|
||
class add_user_last_active extends migration | ||
{ | ||
public static function depends_on() | ||
{ | ||
return [ | ||
'\phpbb\db\migration\data\v33x\v3311', | ||
]; | ||
} | ||
|
||
public function update_schema() | ||
{ | ||
return [ | ||
'add_columns' => [ | ||
$this->table_prefix . 'users' => [ | ||
'user_last_active' => ['TIMESTAMP', 0, 'after' => 'user_lastvisit'], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
public function revert_schema() | ||
{ | ||
return [ | ||
'drop_columns' => [ | ||
$this->table_prefix . 'users' => ['user_last_active'], | ||
], | ||
]; | ||
} | ||
|
||
public function update_data() | ||
{ | ||
return [ | ||
['custom', [[$this, 'set_user_last_active']]], | ||
]; | ||
} | ||
|
||
public function set_user_last_active($start = 0) | ||
{ | ||
// Get maximum user id from database | ||
$sql = "SELECT MAX(user_id) AS max_user_id | ||
FROM {$this->table_prefix}users"; | ||
$result = $this->db->sql_query($sql); | ||
$max_id = (int) $this->db->sql_fetchfield('max_user_id'); | ||
$this->db->sql_freeresult($result); | ||
|
||
if ($start > $max_id) | ||
{ | ||
return; | ||
} | ||
|
||
// Keep setting user_last_active time | ||
$next_start = $start + 10000; | ||
|
||
$sql = 'UPDATE ' . $this->table_prefix . 'users | ||
SET user_last_active = user_lastvisit | ||
WHERE user_id > ' . (int) $start . ' | ||
AND user_id <= ' . (int) ($next_start); | ||
$this->db->sql_query($sql); | ||
|
||
return $next_start; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ public function test_autologin() | |
'user_email' => '[email protected]', | ||
'user_birthday' => '', | ||
'user_lastvisit' => 0, | ||
'user_last_active' => 0, | ||
'user_lastmark' => 0, | ||
'user_lastpost_time' => 0, | ||
'user_lastpage' => '', | ||
|