[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/db/migration/data/v30x/ -> release_3_0_7_rc2.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\db\migration\data\v30x;
  15  
  16  class release_3_0_7_rc2 extends \phpbb\db\migration\migration
  17  {
  18  	public function effectively_installed()
  19      {
  20          return phpbb_version_compare($this->config['version'], '3.0.7-RC2', '>=');
  21      }
  22  
  23  	static public function depends_on()
  24      {
  25          return array('\phpbb\db\migration\data\v30x\release_3_0_7_rc1');
  26      }
  27  
  28  	public function update_data()
  29      {
  30          return array(
  31              array('custom', array(array(&$this, 'update_email_hash'))),
  32  
  33              array('config.update', array('version', '3.0.7-RC2')),
  34          );
  35      }
  36  
  37  	public function update_email_hash($start = 0)
  38      {
  39          $limit = 1000;
  40  
  41          $sql = 'SELECT user_id, user_email, user_email_hash
  42              FROM ' . USERS_TABLE . '
  43              WHERE user_type <> ' . USER_IGNORE . "
  44                  AND user_email <> ''";
  45          $result = $this->db->sql_query_limit($sql, $limit, $start);
  46  
  47          $i = 0;
  48          while ($row = $this->db->sql_fetchrow($result))
  49          {
  50              $i++;
  51  
  52              // Snapshot of the phpbb_email_hash() function
  53              // We cannot call it directly because the auto updater updates the DB first. :/
  54              $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']);
  55  
  56              if ($user_email_hash != $row['user_email_hash'])
  57              {
  58                  $sql_ary = array(
  59                      'user_email_hash'    => $user_email_hash,
  60                  );
  61  
  62                  $sql = 'UPDATE ' . USERS_TABLE . '
  63                      SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
  64                      WHERE user_id = ' . (int) $row['user_id'];
  65                  $this->sql_query($sql);
  66              }
  67          }
  68          $this->db->sql_freeresult($result);
  69  
  70          if ($i < $limit)
  71          {
  72              // Completed
  73              return;
  74          }
  75  
  76          // Return the next start, will be sent to $start when this function is called again
  77          return $start + $limit;
  78      }
  79  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1