source: trunk/install/upgrade_2.3.0.php @ 19703

Last change on this file since 19703 was 19703, checked in by plg, 11 years ago

update Piwigo headers to 2013 (the end of the world didn't occur as expected on r12922)

File size: 4.0 KB
RevLine 
[15679]1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
[15679]6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ('This page cannot be loaded directly, load upgrade.php');
27}
28else
29{
30  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
31  {
32    die ('Hacking attempt!');
33  }
34}
35
36// +-----------------------------------------------------------------------+
37// |             Fill upgrade table without applying upgrade               |
38// +-----------------------------------------------------------------------+
39
40// retrieve already applied upgrades
41$query = '
42SELECT id
43  FROM '.PREFIX_TABLE.'upgrade
44;';
45$applied = array_from_query($query, 'id');
46
47// retrieve existing upgrades
48$existing = get_available_upgrade_ids();
49
50// which upgrades need to be applied?
51$to_apply = array_diff($existing, $applied);
52$inserts = array();
53foreach ($to_apply as $upgrade_id)
54{
[16313]55  if ($upgrade_id >= 112) // TODO change on each release
[15679]56  {
57    break;
58  }
59 
60  array_push(
61    $inserts,
62    array(
63      'id' => $upgrade_id,
64      'applied' => CURRENT_DATE,
65      'description' => '[migration from 2.3.0 to '.PHPWG_VERSION.'] not applied',
66      )
67    );
68}
69
70if (!empty($inserts))
71{
72  mass_inserts(
73    '`'.UPGRADE_TABLE.'`',
74    array_keys($inserts[0]),
75    $inserts
76    );
77}
78
79// +-----------------------------------------------------------------------+
80// |                          Perform upgrades                             |
81// +-----------------------------------------------------------------------+
82
83ob_start();
84echo '<pre>';
85
[16313]86for ($upgrade_id = 112; $upgrade_id <= 127; $upgrade_id++) // TODO change on each release
[15679]87{
88  if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'))
89  {
[16313]90    continue;
[15679]91  }
[16313]92
93  // maybe the upgrade task has already been applied in a previous and
94  // incomplete upgrade
95  if (in_array($upgrade_id, $applied))
96  {
97    continue;
98  }
[15679]99 
100  unset($upgrade_description);
101
102  echo "\n\n";
103  echo '=== upgrade '.$upgrade_id."\n";
104
105  // include & execute upgrade script. Each upgrade script must contain
106  // $upgrade_description variable which describe briefly what the upgrade
107  // script does.
108  include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php');
109
110  // notify upgrade
111  $query = '
112INSERT INTO `'.PREFIX_TABLE.'upgrade`
113  (id, applied, description)
114  VALUES
115  (\''.$upgrade_id.'\', NOW(), \'[migration from 2.3.0 to '.PHPWG_VERSION.'] '.$upgrade_description.'\')
116;';
117  pwg_query($query);
118}
119
120echo '</pre>';
121ob_end_clean();
122
123// now we upgrade from 2.4.0
124// include_once(PHPWG_ROOT_PATH.'install/upgrade_2.4.0.php');
125?>
Note: See TracBrowser for help on using the repository browser.