Elgg  Version 1.11
upgrade.php
Go to the documentation of this file.
1 <?php
21 // we want to know if an error occurs
22 ini_set('display_errors', 1);
23 
24 define('UPGRADING', 'upgrading');
25 require_once(dirname(__FILE__) . "/engine/start.php");
26 
28 $site_host = parse_url($site_url, PHP_URL_HOST) . '/';
29 
30 // turn any full in-site URLs into absolute paths
31 $forward_url = get_input('forward', '/admin', false);
32 $forward_url = str_replace(array($site_url, $site_host), '/', $forward_url);
33 
34 if (strpos($forward_url, '/') !== 0) {
35  $forward_url = '/' . $forward_url;
36 }
37 
38 if (get_input('upgrade') == 'upgrade') {
39 
40  $upgrader = new \Elgg\UpgradeService();
41  $result = $upgrader->run();
42  if ($result['failure'] == true) {
43  register_error($result['reason']);
45  }
46 } else {
47  // test the URL rewrite rules
48  if (!class_exists('ElggRewriteTester')) {
49  require dirname(__FILE__) . '/install/ElggRewriteTester.php';
50  }
51  $rewriteTester = new \ElggRewriteTester();
52  $url = elgg_get_site_url() . "__testing_rewrite?__testing_rewrite=1";
53  if (!$rewriteTester->runRewriteTest($url)) {
54  // see if there is a problem accessing the site at all
55  // due to ip restrictions for example
56  if (!$rewriteTester->runLocalhostAccessTest()) {
57  // note: translation may not be available until after upgrade
58  $msg = elgg_echo("installation:htaccess:localhost:connectionfailed");
59  if ($msg === "installation:htaccess:localhost:connectionfailed") {
60  $msg = "Elgg cannot connect to itself to test rewrite rules properly. Check "
61  . "that curl is working and there are no IP restrictions preventing "
62  . "localhost connections.";
63  }
64  echo $msg;
65  exit;
66  }
67 
68  // note: translation may not be available until after upgrade
69  $msg = elgg_echo("installation:htaccess:needs_upgrade");
70  if ($msg === "installation:htaccess:needs_upgrade") {
71  $msg = "You must update your .htaccess file so that the path is injected "
72  . "into the GET parameter __elgg_uri (you can use install/config/htaccess.dist as a guide).";
73  }
74  echo $msg;
75  exit;
76  }
77 
78  // if upgrading from < 1.8.0, check for the core view 'welcome' and bail if it's found.
79  // see https://github.com/elgg/elgg/issues/3064
80  // we're not checking the view itself because it's likely themes will override this view.
81  // we're only concerned with core files.
82  $welcome = dirname(__FILE__) . '/views/default/welcome.php';
83  if (file_exists($welcome)) {
84  elgg_set_viewtype('failsafe');
85  // can't have pretty messages because we don't know the state of the views.
86  $content = elgg_echo('upgrade:unable_to_upgrade_info');
87  $title = elgg_echo('upgrade:unable_to_upgrade');
88 
90  exit;
91  }
92 
93  $vars = array(
94  'forward' => $forward_url
95  );
96 
97  // reset cache to have latest translations available during upgrade
99 
100  echo elgg_view_page(elgg_echo('upgrading'), '', 'upgrade', $vars);
101  exit;
102 }
103 
$upgrader
Unlocks the upgrade script.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
Definition: cache.php:29
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$forward_url
Definition: upgrade.php:31
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:432
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:419
$title
Definition: save.php:24
exit
Definition: upgrade.php:100
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
Definition: views.php:70
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg echo
Translates a string.
Definition: languages.js:43
$site_url
Definition: upgrade.php:27
if(!$rewriteTester->runRewriteTest($url)) $welcome
Definition: upgrade.php:82
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:383
$content
Set robots.txt action.
Definition: set_robots.php:6
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
Definition: views.php:437
$site_host
Definition: upgrade.php:28
define(function(require){var $=require('jquery');var active=false;var SHOW_DELAY=20;$('body').append('< div class="elgg-spinner">< div class="elgg-ajax-loader"></div ></div >');return{start:function(){active=true;setTimeout(function(){if(active){$('body').addClass('elgg-spinner-active');}}, SHOW_DELAY);}, stop:function(){active=false;$('body').removeClass('elgg-spinner-active');}};})
$url
Definition: upgrade.php:52
if(file_exists($welcome)) $vars
Definition: upgrade.php:93