Skip to content

Commit 9e5c63a

Browse files
A few minor fixes and improvements
1 parent c404308 commit 9e5c63a

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

ProcessWireUpgrade.module

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ProcessWireUpgrade extends Process {
2121
return array(
2222
'title' => 'Upgrades',
2323
'summary' => 'Tool that helps you identify and install core and module upgrades.',
24-
'version' => 9,
24+
'version' => 10,
2525
'author' => 'Ryan Cramer',
2626
'installs' => 'ProcessWireUpgradeCheck',
2727
'requires' => 'ProcessWire>=3.0.0',
@@ -180,14 +180,15 @@ class ProcessWireUpgrade extends Process {
180180

181181
$lastRefresh = $this->session->getFor($this, 'lastRefresh');
182182

183-
if(!$lastRefresh && method_exists($this->modules, 'resetCache')) {
183+
if(!$lastRefresh || $lastRefresh < (time() - 86400)) {
184184
$btn = $this->refreshButton();
185185
$btn->value = $this->_('Continue');
186186
$btn->icon = 'angle-right';
187187
return
188-
$this->h('We need to load the latest core and module versions from the ProcessWire modules directory.') .
189-
$this->p('This may take a few seconds to complete. Please click the button below to continue.') .
190-
$this->p($btn->render());
188+
$this->h('We will load the latest core and module versions from the ProcessWire modules directory.') .
189+
$this->p('Please be patient, this may take a few seconds to complete.') .
190+
$this->p($btn->render()) .
191+
$this->lastRefreshInfo();
191192
}
192193

193194
return '';
@@ -223,9 +224,8 @@ class ProcessWireUpgrade extends Process {
223224

224225
if(count($items)) {
225226
foreach($items as $name => $item) {
226-
if(empty($item['remote'])) {
227-
// not in directory
228-
}
227+
if(empty($item['local'])) continue;
228+
if(empty($item['remote'])) { /* not in directory */ }
229229

230230
$remote = $sanitizer->entities($item['remote']);
231231
$installer = empty($item['installer']) ? '' : $sanitizer->entities($item['installer']);
@@ -281,13 +281,12 @@ class ProcessWireUpgrade extends Process {
281281
if(!empty($item['pro'])) $title .= $proLabel;
282282

283283
} else if(!empty($item['pro'])) {
284+
$title = $this->a($upgradeURL, $title) . $proLabel;
284285
if($item['new'] > 0) {
285286
if(!empty($urls['support'])) $upgradeURL = $urls['support'];
286287
$protip = 'PRO module upgrade available in ProcessWire VIP support board (login required)';
287288
$upgrade = $this->tooltip($protip, $this->aa($upgradeURL, $upgradeLabel));
288-
$title = $this->tooltip($protip, $this->aa($upgradeURL, $title) . $proLabel);
289-
} else {
290-
$title = $this->a($upgradeURL, $title) . $proLabel;
289+
// $title = $this->tooltip($protip, $this->aa($upgradeURL, $title) . $proLabel);
291290
}
292291
$numPro++;
293292

@@ -306,12 +305,10 @@ class ProcessWireUpgrade extends Process {
306305
}
307306
}
308307

309-
$lastRefresh = $this->session->getFor($this, 'lastRefresh');
310-
311308
return
312309
$table->render() .
313-
$this->p(sprintf($this->_('Last refresh: %s'), wireRelativeTimeStr($lastRefresh)), 'description') .
314-
$this->refreshButton(true)->render();
310+
$this->p($this->refreshButton(true)->render()) .
311+
$this->lastRefreshInfo();
315312
}
316313

317314
/**
@@ -320,7 +317,7 @@ class ProcessWireUpgrade extends Process {
320317
*/
321318
public function executeRefresh() {
322319
$this->session->setFor($this, 'lastRefresh', time());
323-
$this->modules->resetCache();
320+
if(method_exists($this->modules, 'resetCache')) $this->modules->resetCache();
324321
$this->checker->getVersions(true);
325322
$this->message($this->_('Refreshed module versions data'));
326323
$this->session->redirect('./');
@@ -884,6 +881,19 @@ class ProcessWireUpgrade extends Process {
884881
return $btn;
885882
}
886883

884+
/**
885+
* @param bool $paragraph
886+
* @return string
887+
*
888+
*/
889+
protected function lastRefreshInfo($paragraph = true) {
890+
$lastRefresh = $this->session->getFor($this, 'lastRefresh');
891+
$lastRefresh = $lastRefresh ? wireRelativeTimeStr($lastRefresh) : $this->_('N/A');
892+
$out = sprintf($this->_('Last refresh: %s'), $lastRefresh);
893+
if($paragraph) $out = $this->p($out, 'detail last-refresh-info');
894+
return $out;
895+
}
896+
887897
/**
888898
* Process rename operations
889899
*

ProcessWireUpgradeCheck.module

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class ProcessWireUpgradeCheck extends WireData implements Module {
278278

279279
foreach($data['items'] as $item) {
280280
$name = $item['class_name'];
281+
if(empty($versions[$name]) || empty($versions[$name]['local'])) continue;
281282
$versions[$name]['remote'] = $item['version'];
282283
$new = version_compare($versions[$name]['remote'], $versions[$name]['local']);
283284
$versions[$name]['new'] = $new;
@@ -378,6 +379,8 @@ class ProcessWireUpgradeCheck extends WireData implements Module {
378379

379380
foreach($data as $key => $info) {
380381

382+
if(empty($info['name'])) continue;
383+
381384
$name = $info['name'];
382385

383386
$branch = array(

0 commit comments

Comments
 (0)