summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-05-13 19:42:05 +0200
committerAndreas Gohr <andi@splitbrain.org>2014-05-13 19:43:18 +0200
commit59d6be95449db272ee0a6b6d437f535246f795c9 (patch)
treeedff699ea6c668a2f5cb6bd7b85b05613f7b6f22
parentc0d17c851c1bf4371e550a105c91a17644de6b29 (diff)
downloadrpg-59d6be95449db272ee0a6b6d437f535246f795c9.tar.gz
rpg-59d6be95449db272ee0a6b6d437f535246f795c9.tar.bz2
update manager.dat correctly on install. closes #704
-rw-r--r--lib/plugins/extension/helper/extension.php39
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index a4736a850..2aca0e218 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -292,7 +292,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
*/
public function getUpdateDate() {
if (!empty($this->managerData['updated'])) return $this->managerData['updated'];
- return false;
+ return $this->getInstallDate();
}
/**
@@ -577,6 +577,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
try {
$installed = $this->installArchive("$tmp/upload.archive", true, $basename);
+ $this->updateManagerData('', $installed);
// purge cache
$this->purgeCache();
}catch (Exception $e){
@@ -596,6 +597,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
try {
$path = $this->download($url);
$installed = $this->installArchive($path, true);
+ $this->updateManagerData($url, $installed);
// purge cache
$this->purgeCache();
@@ -612,8 +614,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
* @return array The list of installed extensions
*/
public function installOrUpdate() {
- $path = $this->download($this->getDownloadURL());
+ $url = $this->getDownloadURL();
+ $path = $this->download($url);
$installed = $this->installArchive($path, $this->isInstalled(), $this->getBase());
+ $this->updateManagerData($url, $installed);
// refresh extension information
if (!isset($installed[$this->getID()])) {
@@ -728,6 +732,37 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
}
/**
+ * Save the given URL and current datetime in the manager.dat file of all installed extensions
+ *
+ * @param string $url Where the extension was downloaded from. (empty for manual installs via upload)
+ * @param array $installed Optional list of installed plugins
+ */
+ protected function updateManagerData($url = '', $installed = null) {
+ $origID = $this->getID();
+
+ if(is_null($installed)) {
+ $installed = array($origID);
+ }
+
+ foreach($installed as $ext => $info) {
+ if($this->getID() != $ext) $this->setExtension($ext);
+ if($url) {
+ $this->managerData['downloadurl'] = $url;
+ } elseif(isset($this->managerData['downloadurl'])) {
+ unset($this->managerData['downloadurl']);
+ }
+ if(isset($this->managerData['installed'])) {
+ $this->managerData['updated'] = date('r');
+ } else {
+ $this->managerData['installed'] = date('r');
+ }
+ $this->writeManagerData();
+ }
+
+ if($this->getID() != $origID) $this->setExtension($origID);
+ }
+
+ /**
* Read the manager.dat file
*/
protected function readManagerData() {