From fea268104cb8f53aad9e25130aec310e3ba0882d Mon Sep 17 00:00:00 2001 From: onli Date: Sun, 20 Jun 2021 11:44:51 +0200 Subject: [PATCH] autoupdate 1.2.1: PHP 8 compatibility fixes --- serendipity_event_autoupdate/ChangeLog | 4 ++ .../serendipity_event_autoupdate.php | 41 +++---------------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/serendipity_event_autoupdate/ChangeLog b/serendipity_event_autoupdate/ChangeLog index bf477dd5..2a228002 100644 --- a/serendipity_event_autoupdate/ChangeLog +++ b/serendipity_event_autoupdate/ChangeLog @@ -1,3 +1,7 @@ +1.2.1: + * PHP 8 compatibility fix: Use language constant loading API, + ski[ dot files when emptying directory + 1.2: * Drop unnecessary time-elapsed messaged and microsleep steps * Stop if plugins are not current diff --git a/serendipity_event_autoupdate/serendipity_event_autoupdate.php b/serendipity_event_autoupdate/serendipity_event_autoupdate.php index e80fe2fc..f2b939fd 100644 --- a/serendipity_event_autoupdate/serendipity_event_autoupdate.php +++ b/serendipity_event_autoupdate/serendipity_event_autoupdate.php @@ -4,13 +4,7 @@ if (IN_serendipity !== true) { die ("Don't hack!"); } -// Probe for a language include with constants. Still include defines later on, if some constants were missing -$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php'; -if (file_exists($probelang)) { - include $probelang; -} - -include dirname(__FILE__) . '/lang_en.inc.php'; +@serendipity_plugin_api::load_language(dirname(__FILE__)); class serendipity_event_autoupdate extends serendipity_event { var $title = PLUGIN_EVENT_AUTOUPDATE_NAME; @@ -22,7 +16,7 @@ class serendipity_event_autoupdate extends serendipity_event { $propbag->add('description', PLUGIN_EVENT_AUTOUPDATE_DESC); $propbag->add('stackable', false); $propbag->add('author', 'onli, Ian'); - $propbag->add('version', '1.2'); + $propbag->add('version', '1.2.1'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'php' => '5.2' @@ -633,23 +627,6 @@ EOS; $msg = "Autoupdate successfully done!\\nWe now refresh to Serendipity Installer!\\n"; // escape for js $this->show_message('

Autoupdate successfully done - refresh to Serendipity Installer

', 'Autoupdate'); - //$this->close_page(); - - //if (die(''."\n \n")) { - //return; - //} else { - //if (!headers_sent()) { - //if (header('Location: http://' . $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'])) exit; - //} else { - //echo ''."\n"; - //echo ''; - //exit; - //} - //} } /** @@ -659,13 +636,11 @@ EOS; function empty_dir($dir) { if (!is_dir($dir)) return; try { - $_dir = new RecursiveDirectoryIterator($dir); - // NOTE: UnexpectedValueException thrown for PHP >= 5.3 - } catch (Exception $e) { - return; - } + $_dir = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); + } catch (Exception $e) { + return; + } $iterator = new RecursiveIteratorIterator($_dir, RecursiveIteratorIterator::CHILD_FIRST); - //$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $file) { if ($file->isFile()) { unlink($file->__toString()); @@ -685,10 +660,6 @@ EOS; $zip = (string)$serendipity['serendipityPath'] . 'templates_c/' . "serendipity-$version.zip"; $zipDir = (string)$serendipity['serendipityPath'] . 'templates_c/' . "serendipity-$version"; - // leave rm zip untouched here as not causing any errors - #unlink($zip);// if (unlink($zip)) { else error note? - #$this->show_message('

Removing the zip file in templates_c done

'); - // As trying to remove a directory that php is still using, we use open/closedir($handle) to be sure if ($handle = opendir($zipDir)) { $this->empty_dir($zipDir);