Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit fd9f14b

Browse files
committed
Pre/post update hooks for 6.5.1
1 parent 3b6600c commit fd9f14b

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/*
3+
* Copyright 2007-2016 Abstrium <contact (at) pydio.com>
4+
* This file is part of Pydio.
5+
*
6+
* Pydio is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Pydio is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* The latest code can be found at <https://pydio.com/>.
20+
*/
21+
22+
/**
23+
* @param string $version
24+
* @throws Exception
25+
*/
26+
function checkPhpVersion($version){
27+
if(version_compare(PHP_VERSION, $version) < 0){
28+
throw new Exception("For Pydio 7, PHP version must be greater or equal to $version, detected version is ".PHP_VERSION." - Upgrade aborted.");
29+
}else{
30+
echo "Checking Php Version (".PHP_VERSION.") : OK";
31+
}
32+
}
33+
34+
/**
35+
* @param string $type
36+
* @param string $name
37+
* @throws Exception
38+
*/
39+
function checkPluginUsed($type, $name){
40+
41+
if($type === "conf"){
42+
$p = ConfService::getConfStorageImpl();
43+
if($p->getName() === $name){
44+
throw new Exception("You are currently using $type.$name as configuration storage. This was deprecated in Pydio 6 and is now removed in Pydio7. Aborting upgrade");
45+
}else{
46+
echo "Checking plugin $type ($name) : OK";
47+
}
48+
}else if($type === "auth") {
49+
$p = ConfService::getAuthDriverImpl();
50+
if ($p->getName() === $name) {
51+
throw new Exception("You are currently using $type.$name for authentication backend. This was deprecated in Pydio 6 and is now removed in Pydio7. Aborting upgrade");
52+
} else {
53+
if ($p->getName() === "multi") {
54+
$drivers = $p->drivers;
55+
if (isSet($drivers[$name])) {
56+
throw new Exception("You are currently using $type.$name for authentication backend. This was deprecated in Pydio 6 and is nowremoved in Pydio7. Aborting upgrade");
57+
} else {
58+
echo "Checking plugin $type (" . implode(", ", array_keys($drivers)) . ") : OK";
59+
}
60+
}
61+
echo "Checking plugin $type ($name) : OK";
62+
}
63+
}else if($type === "access"){
64+
65+
// Check if a workspace is currently using this plugin
66+
67+
68+
}else{
69+
$plugs = AJXP_PluginsService::getInstance()->getActivePluginsForType($type);
70+
if(isSet($plugs[$name])){
71+
throw new Exception("You are currently using plugin $type.$name. This is removed in Pydio7. Please disable it before running upgrade. Aborting upgrade");
72+
}
73+
echo "Checking plugin $type ($name) : OK";
74+
}
75+
76+
}
77+
78+
/**
79+
* @param string $themeName
80+
* @throws Exception
81+
*/
82+
function checkThemeUsed($themeName){
83+
84+
$p = AJXP_PluginsService::getInstance()->findPlugin("gui", "ajax");
85+
$options = $p->getConfigs();
86+
if(isSet($options["GUI_THEME"]) && $options["GUI_THEME"] === $themeName){
87+
throw new Exception("You are currently using theme ".$options["GUI_THEME"]." which was removed from Pydio 7. If you want to be able to upgrade, you have to switch to Orbit theme. Aborting upgrade.");
88+
}else{
89+
echo "Checking usage of remove theme ($themeName): OK";
90+
}
91+
92+
}

dist/php/6.5.1.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div style='font-family: "Open sans", "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif; font-size: 13px;line-height: 1.5em;'
2+
xmlns="http://www.w3.org/1999/html">
3+
4+
<h2>Pydio Core 6.5.1 - Beta1 for Pydio 7</h2>
5+
6+
This is a beta for next major upgrade Pydio 7.
7+
<b>Please update at your own risks.</b>
8+
9+
</div>

dist/php/6.5.1.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/*
3+
* Copyright 2007-2016 Abstrium <contact (at) pydio.com>
4+
* This file is part of Pydio.
5+
*
6+
* Pydio is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Pydio is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* The latest code can be found at <https://pydio.com/>.
20+
*/
21+
22+
function updateSharePhpContent($installPath, $publicFolder){
23+
24+
$sharePhpPath = $installPath."/".trim($publicFolder, "/")."/"."share.php";
25+
if(!is_file($sharePhpPath)){
26+
echo "No share.php file was found in public folder. If it does exist, you may have to manually upgrade its content.";
27+
}
28+
$folders = array_map(function($value){
29+
return "..";
30+
}, explode("/", trim($publicFolder, "/")));
31+
$baseConfPath = implode("/", $folders);
32+
33+
$content = '
34+
<?php
35+
include_once("'.$baseConfPath.'/base.conf.php");
36+
define(\'AJXP_EXEC\', true);
37+
require_once AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/action.share/vendor/autoload.php";
38+
$base = rtrim(dirname($_SERVER["SCRIPT_NAME"]), "/");
39+
\Pydio\Share\ShareCenter::publicRoute($base, "/proxy", ["hash" => $_GET["hash"]]);
40+
';
41+
file_put_contents($sharePhpPath, $content);
42+
43+
}
44+
45+
function updateHtAccessContent($htAccessPath){
46+
47+
if(!is_file($htAccessPath)){
48+
echo "No htaccess file found. Skipping Htaccess update.";
49+
}
50+
$lines = file($htAccessPath);
51+
$startRemoving = false;
52+
// Remove unnecessary lines
53+
foreach($lines as $index => $line){
54+
if(!$startRemoving && strpos($line, "RewriteRule ") !== 0){
55+
continue;
56+
}
57+
if(trim($line) === 'RewriteRule (.*) index.php [L]'){
58+
break;
59+
}else{
60+
unset($lines[$index]);
61+
}
62+
}
63+
$contents = implode("\n", $lines);
64+
if(is_writable($htAccessPath)){
65+
file_put_contents($htAccessPath, $contents);
66+
}else{
67+
echo "ERROR: Htaccess file could not be written. Update it manually to the following content: <pre>$contents</pre>";
68+
}
69+
70+
}
71+
72+
function awsSdkVersion(){
73+
74+
$s3Options = \Pydio\Core\Services\ConfService::getConfStorageImpl()->loadPluginConfig("access", "s3");
75+
if($s3Options["SDK_VERSION"] === "v2"){
76+
$s3Options["SDK_VERSION"] = "v3";
77+
\Pydio\Core\Services\ConfService::getConfStorageImpl()->savePluginConfig("access.s3", $s3Options);
78+
}
79+
80+
}

dist/php/6.5.1.sql

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
3+
4+
ALTER TABLE `ajxp_log` CHANGE `dirname` `dirname` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
5+
CHANGE `basename` `basename` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;
6+
7+
ALTER TABLE `ajxp_log` DROP INDEX `basename`;
8+
ALTER TABLE `ajxp_log` DROP INDEX `dirname`;
9+
10+
ALTER TABLE `ajxp_log` ADD INDEX ( `user` ) ;
11+
ALTER TABLE `ajxp_log` ADD INDEX ( `dirname`, `basename` ) ;
12+
13+
14+
CREATE TABLE IF NOT EXISTS `ajxp_tasks` (
15+
`uid` varchar(255) NOT NULL,
16+
`type` int(11) NOT NULL,
17+
`parent_uid` varchar(255) DEFAULT NULL,
18+
`flags` int(11) NOT NULL,
19+
`label` varchar(255) NOT NULL,
20+
`userId` varchar(255) NOT NULL,
21+
`wsId` varchar(32) NOT NULL,
22+
`status` int(11) NOT NULL,
23+
`status_msg` mediumtext NOT NULL,
24+
`progress` int(11) NOT NULL,
25+
`schedule` int(11) NOT NULL,
26+
`schedule_value` varchar(255) DEFAULT NULL,
27+
`action` text NOT NULL,
28+
`parameters` mediumtext NOT NULL,
29+
`nodes` text NOT NULL,
30+
`creation_date` int(11) NOT NULL DEFAULT '0' COMMENT 'Date of creation of the job',
31+
`status_update` int(11) NOT NULL DEFAULT '0' COMMENT 'Last time the status was updated',
32+
PRIMARY KEY (`uid`),
33+
KEY `userId` (`userId`,`status`),
34+
KEY `type` (`type`),
35+
FULLTEXT KEY `nodes` (`nodes`)
36+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Task persistence layer';
37+

0 commit comments

Comments
 (0)