Skip to content

Commit

Permalink
3.3.7
Browse files Browse the repository at this point in the history
* Massive improvement to background tasks performance.  Processing times reduced by 50 to 90% in most cases.
* Fixed settings toggle in Google Chrome
* Fix for srcset generation when using wp_get_attachment_image() in your theme
  • Loading branch information
jawngee committed Dec 7, 2019
1 parent 889c154 commit eeae037
Show file tree
Hide file tree
Showing 21 changed files with 452 additions and 132 deletions.
4 changes: 3 additions & 1 deletion classes/CLI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ protected function runTask($task, $options = [], $selected = []) {
exit(0);
}

$task->save();
$task->wait();
$task->dumpExisting();
$task->loadNextData();


Command::Out("", true);
Expand Down
4 changes: 4 additions & 0 deletions classes/Storage/Driver/Backblaze/BackblazeStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ public function presignedUrl($key, $expiration = 0) {
public function url($key, $type = null) {
return $this->bucketUrl.$key;
}

public function signedURLExpirationForType($type = null) {
return null;
}
//endregion

//region Direct Uploads
Expand Down
21 changes: 10 additions & 11 deletions classes/Storage/Driver/GoogleCloud/GoogleStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,19 @@ public function usesSignedURLs($type = null) {
return $this->settings->usePresignedURLs;
}

$use = false;
if (strpos($type, 'image') === 0) {
return $this->settings->usePresignedURLsForImages;
$use = $this->settings->usePresignedURLsForImages;
} else if (strpos($type, 'video') === 0) {
$use = $this->settings->usePresignedURLsForVideo;
} else if (strpos($type, 'audio') === 0) {
$use = $this->settings->usePresignedURLsForAudio;
} else if (strpos($type, 'application') === 0) {
$use = $this->settings->usePresignedURLsForDocs;
}

if (strpos($type, 'video') === 0) {
return $this->settings->usePresignedURLsForVideo;
}

if (strpos($type, 'audio') === 0) {
return $this->settings->usePresignedURLsForAudio;
}

if ((strpos($type, 'application') === 0) || (strpos($type, 'text') === 0)) {
return $this->settings->usePresignedURLsForDocs;
if (!empty($use)) {
return true;
}

return $this->settings->usePresignedURLs;
Expand Down
25 changes: 12 additions & 13 deletions classes/Storage/Driver/S3/S3Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,24 @@ public function pathLink($bucket, $key) {

//region Enabled/Options
public function usesSignedURLs($type = null) {
if (($type == null) || (!empty($this->settings->usePresignedURLs))) {
if (($type === null) || (!empty($this->settings->usePresignedURLs))) {
return $this->settings->usePresignedURLs;
}

$use = false;
if (strpos($type, 'image') === 0) {
return $this->settings->usePresignedURLsForImages;
}

if (strpos($type, 'video') === 0) {
return $this->settings->usePresignedURLsForVideo;
}

if (strpos($type, 'audio') === 0) {
return $this->settings->usePresignedURLsForAudio;
$use = $this->settings->usePresignedURLsForImages;
} else if (strpos($type, 'video') === 0) {
$use = $this->settings->usePresignedURLsForVideo;
} else if (strpos($type, 'audio') === 0) {
$use = $this->settings->usePresignedURLsForAudio;
} else if (strpos($type, 'application') === 0) {
$use = $this->settings->usePresignedURLsForDocs;
}

if (strpos($type, 'application') === 0) {
return $this->settings->usePresignedURLsForDocs;
}
if (!empty($use) && ($use !== 'inherit')) {
return true;
}

return $this->settings->usePresignedURLs;
}
Expand Down
9 changes: 9 additions & 0 deletions classes/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ public function pathLink($bucket, $key);
*/
public function usesSignedURLs($type = null);

/**
* Returns the expiration for a particular type
*
* @param null|string $type
*
* @return int|null
*/
public function signedURLExpirationForType($type = null);

/**
* Insures that all the configuration settings are valid and that the storage is enabled.
* @return bool
Expand Down
6 changes: 6 additions & 0 deletions classes/Tasks/AttachmentTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ public function prepare($options = [], $selectedItems = []) {

$query = new \WP_Query($args);
$postIds = $query->posts;
if (count($postIds) === 0) {
return false;
}

foreach($postIds as $postId) {
$this->addItem(['id' => $postId]);
}
}

$this->state = Task::STATE_WAITING;

Logger::info("Added {$this->totalItems} to the task.");
return ($this->totalItems > 0);
}
Expand Down
Loading

0 comments on commit eeae037

Please sign in to comment.