Skip to content

Commit

Permalink
3.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jawngee committed Nov 9, 2019
1 parent 206d20b commit 885caef
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 28 deletions.
33 changes: 11 additions & 22 deletions classes/Tasks/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Carbon\Carbon;
use function ILAB\MediaCloud\Utilities\gen_uuid;
use ILAB\MediaCloud\Utilities\Logging\Logger;
use function ILAB\MediaCloud\Utilities\phpMemoryLimit;
use ILAB\MediaCloud\Utilities\Tracker;


Expand Down Expand Up @@ -615,35 +616,23 @@ public function canWork($firstTime) {
return false;
}

$memory = memory_get_usage(true);
$limit = $this->memoryLimit() * 0.9;
if (empty($this->cli)) {
$memory = memory_get_usage(true);
$limit = phpMemoryLimit('32M') * 0.9;

if (!$firstTime) {
$limit -= $this->memoryPer;
}
if ($memory >= $limit) {
Logger::info("Out of memory!");
return false;
if (!$firstTime) {
$limit -= $this->memoryPer;
}
if ($memory >= $limit) {
Logger::info("Out of memory!");
return false;
}
}


return true;
}

private function memoryLimit() {
if (function_exists('ini_get')) {
$memory_limit = intval(ini_get('memory_limit'));
} else {
$memory_limit = 128;
}

if (empty($memory_limit) || ($memory_limit == -1)) {
$memory_limit = 64000;
}

return $memory_limit * 1024 * 1024;
}


public function nextChunk() {
if (count($this->data) == 0) {
Expand Down
17 changes: 17 additions & 0 deletions classes/Tools/Storage/CLI/StorageCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use ILAB\MediaCloud\Storage\StorageSettings ;
use ILAB\MediaCloud\Tools\Browser\Tasks\ImportFromStorageTask ;
use ILAB\MediaCloud\Tools\Integrations\PlugIns\Elementor\Tasks\UpdateElementorTask ;
use ILAB\MediaCloud\Tools\Integrations\PlugIns\NextGenGallery\Tasks\MigrateNextGenTask ;
use ILAB\MediaCloud\Tools\Storage\StorageTool ;
use ILAB\MediaCloud\Tools\Storage\Tasks\MigrateTask ;
use ILAB\MediaCloud\Tools\Storage\Tasks\RegenerateThumbnailTask ;
Expand Down Expand Up @@ -256,6 +257,22 @@ public function unlink( $args, $assoc_args )
$this->runTask( $task, $options );
}

/**
* Migrate NextGen Gallery images to cloud storage.
*
* @when after_wp_load
*
* @param $args
* @param $assoc_args
*
* @throws \Exception
*/
public function migrateNGG( $args, $assoc_args )
{
global $media_cloud_licensing ;
self::Error( "Only available in the Premium version. To upgrade: https://mediacloud.press/pricing/" );
}

/**
* Updates Elementor's data with the correct URLs.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/Tools/Storage/StorageTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ public function getAttachmentURL( $url, $post_id )
* @return null|string
* @throws StorageException
*/
private function getAttachmentURLFromMeta( $meta )
public function getAttachmentURLFromMeta( $meta )
{
if ( !isset( $meta['s3'] ) || !isset( $meta['s3']['key'] ) ) {
return null;
Expand Down
35 changes: 35 additions & 0 deletions classes/Utilities/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,40 @@ function objectPath($object, $path, $default = null) {
function postIdExists($postId) {
return is_string(get_post_status($postId));
}

/**
* Returns the PHP memory limit in bytes.
* @return int
*/
function phpMemoryLimit($default = '64M') {
$memory_limit = $default;

if (function_exists('ini_get')) {
$memory_limit = ini_get('memory_limit');
}

if (empty($memory_limit) || ($memory_limit == -1)) {
$memory_limit = $default;
}

preg_match('/^\s*([0-9.]+)\s*([KMGTPE])B?\s*$/i', $memory_limit, $matches);
$num = (float)$matches[1];
switch (strtoupper($matches[2])) {
case 'E':
$num = $num * 1024;
case 'P':
$num = $num * 1024;
case 'T':
$num = $num * 1024;
case 'G':
$num = $num * 1024;
case 'M':
$num = $num * 1024;
case 'K':
$num = $num * 1024;
}

return intval($num);
}
}

4 changes: 2 additions & 2 deletions ilab-media-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin URI: https://github.com/interfacelab/ilab-media-tools
Description: Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows.
Author: interfacelab
Version: 3.2.3
Version: 3.2.4
Author URI: http://interfacelab.io
*/
// Copyright (c) 2016 Interfacelab LLC. All rights reserved.
Expand Down Expand Up @@ -93,7 +93,7 @@
}

// Version Defines
define( 'MEDIA_CLOUD_VERSION', '3.2.3' );
define( 'MEDIA_CLOUD_VERSION', '3.2.4' );
define( 'MEDIA_CLOUD_INFO_VERSION', '1.0.0' );
// Directory defines
define( 'ILAB_TOOLS_DIR', dirname( __FILE__ ) );
Expand Down
12 changes: 9 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=== Media Cloud for Amazon S3, Imgix, Google Cloud Storage, DigitalOcean Spaces and more ===
Contributors: mediacloud, interfacelab
Contributors: mediacloud, interfacelab, freemius
Tags: offload, amazon, s3, imgix, uploads, google cloud storage, digital ocean spaces, wasabi, minio, media, cdn, rekognition, cloudfront, images, crop, image editing, image editor, media library, offload, offload s3, filepicker, smush, ewww, imagify, shortpixel
Requires at least: 4.4
Tested up to: 5.2.4
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Stable tag: 3.2.3
Stable tag: 3.2.4
Requires PHP: 5.6.4

Automatically store media on Amazon S3, Google Cloud Storage, DigitalOcean Spaces + others. Serve CSS/JS assets through CDNs. Integrate with Imgix.
Expand Down Expand Up @@ -47,7 +47,6 @@ Compatible with Short Pixel, EWWW, Smush and Imagify image optimization plugins!

* Upload to any of a variety of cloud storage providers (Amazon S3, Google Cloud Storage, Minio, Wasabi, Backblaze, DigitalOcean Spaces or any other S3 compatible service)
* Host your media directly from your cloud storage provider or specify a CDN
* Import your existing library to cloud storage
* Integrate with Imgix media hosting
* Use Amazon Rekognition to automatically tag and categorize images
* Use third party cloud file providers that use S3 compatible APIs
Expand Down Expand Up @@ -109,6 +108,13 @@ No, I'm just one very enthusiastic customer.

== Changelog ==

= 3.2.4 =

* Vastly improved NextGen Galleries integration (Premium)
* New Migrate to NextGen Galleries task to import all of your existing NextGen Galleries to cloud storage (Premium)
* Fix for you insane people have that PHP memory limits specified in gigabytes
* Skip memory limit check when running tasks from the command line

= 3.2.3 =

* Fix for asset push when the CSS rule contains a url with a query string
Expand Down
1 change: 1 addition & 0 deletions views/tasks/batch/instructions/migrate-ngg.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>This tool will migrate any images you are using with NextGen Gallery.</p>
8 changes: 8 additions & 0 deletions views/tasks/batch/migrate-ngg.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php /** @var string $taskClass */ ?>
@include('tasks.batch-info', [
'instructionsView' => $taskClass::instructionView(),
'commandLine' => 'wp mediacloud migrateNGG',
'commandTitle' => 'Migrate NextGen Galleries',
'warning' => $warning,
'taskClass' => $taskClass
])

0 comments on commit 885caef

Please sign in to comment.