Skip to content
Permalink
Browse files

[event_autoupdate] Add option to disable file integrity checks for one

run of the auto updater.

Signed-off-by: Matthias Gutjahr <mattsches@gmail.com>
  • Loading branch information...
mattsches committed Aug 20, 2019
1 parent 3529dbc commit c8b368cd89ee3fed8a8a0e92463c2cc981faa430
@@ -1,3 +1,6 @@
1.1.9: Add config setting 'disable_integrity_checks' to disable file integrity
checks for one run (see https://board.s9y.org/viewtopic.php?f=1&t=24492)

1.1.8: Iconfont a11y fix (yellowled)

1.1.7: Fix beta-version upgrade by using github-archive path and making the
@@ -65,4 +68,4 @@
* Fixed call-by-reference-warning in php 5.3
* Added checksum-test prior to unpacking to kind of authenticate
the update
* Added checksum-test after unpacking to check the integrity
* Added checksum-test after unpacking to check the integrity
@@ -1,7 +1,13 @@
<?php
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define('PLUGIN_EVENT_AUTOUPDATE_DESC', 'Sobald das Dashboard Plugin (einmal am Tag) ein Serendipity Update entdeckt, setzt dieses Plugin eine Ein-Klick Option in das Dashboard des Backends, um ein manuelles Download oder ein automatisches und gesichertes Upgrade der Blogsoftware zu starten.');
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Automatisches Upgrade starten');
?>
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DESC',
'Sobald das Dashboard Plugin (einmal am Tag) ein Serendipity Update entdeckt, setzt dieses Plugin eine Ein-Klick Option in das Dashboard des Backends, um ein manuelles Download oder ein automatisches und gesichertes Upgrade der Blogsoftware zu starten.'
);
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Automatisches Upgrade starten');
@define('PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS', 'Deaktiviere Integritätsprüfung (ACHTUNG!)');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS_DESC',
'Diese Einstellung deaktiviert die Integritätsprüfung für Dateien für einen Durchlauf des automatischen Updates. Sie wird danach automatisch wieder auf `Nein` gesetzt.'
);
@@ -1,7 +1,13 @@
<?php
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define('PLUGIN_EVENT_AUTOUPDATE_DESC', 'When the dashboard-plugin (once a day) detects an update, this plugin adds the option to manually download or start an automatic and secured upgrade of the blog directly with one click from within the adminarea.');
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Start automatic upgrade');
?>
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DESC',
'When the dashboard-plugin (once a day) detects an update, this plugin adds the option to manually download or start an automatic and secured upgrade of the blog directly with one click from within the adminarea.'
);
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Start automatic upgrade');
@define('PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS', 'Disable integrity checks (CAUTION!)');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS_DESC',
'This setting disables the file integrity checks for one run of the auto updater. It will be automatically reset to `No` after the update.'
);
@@ -3,5 +3,8 @@
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define('PLUGIN_EVENT_AUTOUPDATE_DESC', 'Sobald das Dashboard Plugin (einmal am Tag) ein Serendipity Update entdeckt, setzt dieses Plugin eine Ein-Klick Option in das Dashboard des Backends, um ein manuelles Download oder ein automatisches und gesichertes Upgrade der Blogsoftware zu starten.');
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Automatisches Upgrade starten');
?>
@define('PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS', 'Deaktiviere Integritätsprüfung (ACHTUNG!)');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS_DESC',
'Diese Einstellung deaktiviert die Integritätsprüfung für Dateien für einen Durchlauf des automatischen Updates. Sie wird danach automatisch wieder auf `Nein` gesetzt.'
);
@@ -1,7 +1,13 @@
<?php
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define('PLUGIN_EVENT_AUTOUPDATE_DESC', 'When the dashboard-plugin (once a day) detects an update, this plugin adds the option to manually download or start an automatic and secured upgrade of the blog directly with one click from within the adminarea.');
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Start automatic upgrade');
?>
@define('PLUGIN_EVENT_AUTOUPDATE_NAME', 'Serendipity Autoupdate');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DESC',
'When the dashboard-plugin (once a day) detects an update, this plugin adds the option to manually download or start an automatic and secured upgrade of the blog directly with one click from within the adminarea.'
);
@define('PLUGIN_EVENT_AUTOUPDATE_UPDATEBUTTON', 'Start automatic upgrade');
@define('PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS', 'Disable integrity casdf hecks (CAUTION!)');
@define(
'PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS_DESC',
'This setting disables the file integrity checks for one run of the auto updater. It will be automatically reset to `No` after the update.'
);
@@ -22,13 +22,16 @@ function introspect(&$propbag) {
$propbag->add('description', PLUGIN_EVENT_AUTOUPDATE_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'onli, Ian');
$propbag->add('version', '1.1.8');
$propbag->add('version', '1.1.9');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'php' => '5.2'
));
$propbag->add('event_hooks', array('plugin_dashboard_updater' => true,
'backend_sidebar_entries_event_display_update' => true));
$propbag->add('configuration', array(
'disable_integrity_checks',
));
$propbag->add('groups', array('BACKEND_FEATURES'));
if ($serendipity['version'][0] < 2) {
$this->dependencies = array('serendipity_event_dashboard' => 'keep');
@@ -47,9 +50,26 @@ function install() {
}
}
/*function introspect_config_item($name, &$propbag) {
}*/
/**
* @param string $name
* @param serendipity_property_bag $propbag
* @return bool
*/
function introspect_config_item($name, &$propbag)
{
switch ($name) {
case 'disable_integrity_checks':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS);
$propbag->add('description', PLUGIN_EVENT_AUTOUPDATE_DISABLE_INTEGRITY_CHECKS_DESC);
$propbag->add('default', false);
break;
default:
return false;
}
return true;
}
/**
* flush progress or error messages
@@ -211,10 +231,16 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
$this->show_message('<p class="msg_run"><span class="icon-clock" aria-hidden="true"></span><em>'.$lmsg.'</em></p>', 'Function unpack update', 'checking integrity');
if ($unpacked) {
$start = microtime(true);
if ($this->checkIntegrity($nv)) {
$disableIntegrityChecks = $this->get_config('disable_integrity_checks', false);
if ($disableIntegrityChecks === true || $this->checkIntegrity($nv)) {
usleep(3);
$time = microtime(true) - $start;
$logmsg .= $lmsg = sprintf("In %0.4d seconds run fcn checkIntegrity()...\n", $time); // print in readable format 1.2345
if ($disableIntegrityChecks === true) {
$this->set_config('disable_integrity_checks', false); //reset config
$logmsg .= $lmsg = "fcn checkIntegrity() skipped...\nReset 'disable_integrity_checks' to false\n";
} else {
$logmsg .= $lmsg = sprintf("In %0.4d seconds run fcn checkIntegrity()...\n", $time); // print in readable format 1.2345
}
$this->show_message('<p class="msg_run"><span class="icon-clock" aria-hidden="true"></span><em>'.$lmsg.'</em></p>', 'Function check integrity', 'finally copy update');
$start = microtime(true);
$copied = $this->copyUpdate($nv);
@@ -236,7 +262,7 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
sleep(2);
$this->show_message('<p class="msg_notice"><span class="icon-attention" aria-hidden="true"></span><a href="'.$serendipity['serendipityHTTPPath'].'">click to start Serendipity Installer here</a>!</p>');
sleep(1);
$this->doUpdate();//$logmsg
$this->doUpdate();//$logmsg
} else {
$this->show_message('<p class="msg_error"><span class="icon-error" aria-hidden="true"></span>Copying the files for the update failed</p>');
}
@@ -733,4 +759,4 @@ function debugMsg($msg) {
}
/* vim: set sts=4 ts=4 expandtab : */
/* vim: set sts=4 ts=4 expandtab : */

7 comments on commit c8b368c

@th-h

This comment has been minimized.

Copy link

replied Aug 20, 2019

I like this idea!

(The formatting of the language files looks a bit off.)

@mattsches

This comment has been minimized.

Copy link
Owner Author

replied Aug 21, 2019

I reformatted them on purpose because IMHO the original indentation made them even harder to read (after I added my long lines of text) ;)

@erAck

This comment has been minimized.

Copy link

replied Aug 21, 2019

I think a cleaner approach for the text vs bin checksum problem would be to have a list in checkIntegrity() of possibly failing files during an upgrade and their "other" checksums, and if serendipity_FTPChecksum() returns false for one of those invoke it again with
serendipity_FTPChecksum($updateDir . "serendipity/" . $file, 'bin')
and see if that one matches.

@mattsches

This comment has been minimized.

Copy link
Owner Author

replied Aug 21, 2019

Thank you, that seems to be a better idea indeed. 👍 My PR has already been merged, but hopefully I'm going to find the time tomorrow to give your approach a try.

@mattsches

This comment has been minimized.

Copy link
Owner Author

replied Aug 22, 2019

Actually, it's the other way round, right? The old serendipity_FTPChecksum() (before your PR) treats .svg et al. as binary files, so we have to invoke it again with serendipity_FTPChecksum($updateDir . "serendipity/" . $file, 'text'). Correct?

@mattsches

This comment has been minimized.

Copy link
Owner Author

replied Aug 22, 2019

I've just pushed a new commit implementing this approach: ccbe9a7

@erAck

This comment has been minimized.

Copy link

replied Aug 22, 2019

Actually, it's the other way round, right?

Yes, of course.

Please sign in to comment.
You can’t perform that action at this time.