Changeset 2825667
- Timestamp:
- 11/29/2022 07:28:25 AM (20 months ago)
- Location:
- c3-cloudfront-clear-cache
- Files:
-
- 21 edited
- 14 copied
Legend:
- Unmodified
- Added
- Removed
-
c3-cloudfront-clear-cache/tags/6.1.4/c3-cloudfront-clear-cache.php
r2728981 r2825667 2 2 /** 3 3 * Plugin Name: C3 Cloudfront Cache Controller 4 * Version: 6.1. 34 * Version: 6.1. 5 5 * Plugin URI:https://github.com/amimoto-ami/c3-cloudfront-clear-cache 6 6 * Description: Manage CloudFront Cache and provide some fixtures. 7 7 * Author: hideokamoto 8 8 * Author URI: https://wp-kyoto.net/ 9 * Requires PHP: 7. 09 * Requires PHP: 7. 10 10 * Text Domain: c3-cloudfront-clear-cache 11 11 * -
c3-cloudfront-clear-cache/tags/6.1.4/classes/AWS/CloudFront_Service.php
r2726571 r2825667 13 13 } 14 14 15 15 16 use C3_CloudFront_Cache_Controller\WP; 16 17 use Aws\CloudFront\CloudFrontClient; … … 56 57 } elseif ( $value instanceof WP\Hooks ) { 57 58 $this->hook_service = $value; 58 } elseif ( $value instanceof Environment ) {59 } elseif ( $value instanceof Environment ) { 59 60 $this->env = $value; 60 61 } … … 94 95 * @param string $access_key AWS access key id. 95 96 * @param string $secret_key AWS secret access key id. 96 * @ throws \WP_Error|\Exception If AWS API returns any error, should throw it.97 * @. 97 98 */ 98 99 public function try_to_call_aws_api( string $distribution_id, string $access_key = null, string $secret_key = null ) { … … 112 113 ) 113 114 ); 114 return true;115 return ; 115 116 } catch ( \Exception $e ) { 116 if ( 'NoSuchDistribution' === $e->getAwsErrorCode() ) {117 if ( 'NoSuchDistribution' === $e->getAwsErrorCode() ) { 117 118 $e = new \WP_Error( 'C3 Auth Error', "Can not find CloudFront Distribution ID: {$distribution_id} is not found." ); 118 } elseif ( 'InvalidClientTokenId' === $e->getAwsErrorCode() ) {119 } elseif ( 'InvalidClientTokenId' === $e->getAwsErrorCode() ) { 119 120 $e = new \WP_Error( 'C3 Auth Error', 'AWS AWS Access Key or AWS Secret Key is invalid.' ); 120 121 } else { 121 122 $e = new \WP_Error( 'C3 Auth Error', $e->getMessage() ); 122 123 } 123 error_log( $e->get_error_messages(), 0 );124 throw$e;124 error_log( ), 0 ); 125 $e; 125 126 } 126 127 } … … 209 210 $result = $client->createInvalidation( $params ); 210 211 return $result; 211 } catch ( \Aws\CloudFront\Exception\TooManyInvalidationsInProgressException $e ) { 212 error_log( $e->__toString(), 0 ); 213 $e = new \WP_Error( 'C3 Invalidation Error', $e->__toString() ); 214 return $e; 215 } catch ( \Aws\CloudFront\Exception $e ) { 212 } catch ( \Aws\CloudFront\Exception\CloudFrontException $e ) { 216 213 error_log( $e->__toString(), 0 ); 217 214 $e = new \WP_Error( 'C3 Invalidation Error', $e->__toString() ); … … 244 241 } 245 242 return array(); 246 } catch ( \Aws\CloudFront\Exception\NoSuchDistributionException $e ) { 247 error_log( $options['distribution_id'] . 'not found' ); 243 } catch ( \Aws\CloudFront\Exception\CloudFrontException $e ) { 244 if ( isset( $distribution_id ) && 'NoSuchDistribution' === $e->getAwsErrorCode() ) { 245 error_log( $distribution_id . ' not found' ); 246 } 248 247 error_log( $e->__toString(), 0 ); 249 248 } catch ( \Exception $e ) { -
c3-cloudfront-clear-cache/tags/6.1.4/classes/AWS/Invalidation_Batch_Service.php
r2728981 r2825667 91 91 $invalidation_batch->put_invalidation_path( $url ); 92 92 } 93 94 95 96 93 97 $invalidation_batch->apply_invalidation_item_filter( $post ); 94 98 return $invalidation_batch; -
c3-cloudfront-clear-cache/tags/6.1.4/classes/Invalidation_Service.php
r2558516 r2825667 24 24 * Hook service 25 25 * 26 * @var WP\Hook _Service26 * @var WP\Hook 27 27 */ 28 28 private $hook_service; … … 38 38 * Transient service. 39 39 * 40 * @var AWS\Transient_Service40 * @var \Transient_Service 41 41 */ 42 42 private $transient_service; -
c3-cloudfront-clear-cache/tags/6.1.4/classes/Settings_Service.php
r2558516 r2825667 84 84 * @param string $access_key AWS access key id. 85 85 * @param string $secret_key AWS secret access key id. 86 * @ throws \WP_Error If no distribution id provided, should throw error.86 * @ 87 87 */ 88 88 public function update_options( string $distribution_id, string $access_key = null, string $secret_key = null ) { 89 // Null check. 90 if ( ! $distribution_id ) { 91 throw new \WP_Error( 'distribution id is required' ); 89 // CloudFront API call. 90 $error = $this->cf_service->try_to_call_aws_api( $distribution_id, $access_key, $secret_key ); 91 if ( is_wp_error( $error ) ) { 92 return $error; 92 93 } 93 94 94 // CloudFront API call.95 $this-> cf_service->try_to_call_aws_api( $distribution_id, $access_key, $secret_key );95 // . 96 $this->( $distribution_id, $access_key, $secret_key ); 96 97 97 // Save. 98 $result = $this->options_service->update_options( $distribution_id, $access_key, $secret_key ); 99 return $result; 98 return null; 100 99 } 101 100 -
c3-cloudfront-clear-cache/tags/6.1.4/classes/Views/Settings.php
r2728981 r2825667 92 92 * 93 93 * @access public 94 * @param none95 94 * @since 4.0.0 96 95 */ -
c3-cloudfront-clear-cache/tags/6.1.4/classes/WP/Fixtures.php
r2559100 r2825667 100 100 * @param string $key Cookie key name. 101 101 * @param mixed $value Cookie value. 102 * @param in it$expires Cookie expiration.102 * @param in $expires Cookie expiration. 103 103 */ 104 104 private function set_cookie( $key, $value, $expires = 0 ) { -
c3-cloudfront-clear-cache/tags/6.1.4/classes/WP/Options_Service.php
r2558516 r2825667 82 82 * @param string $access_key AWS access key id. 83 83 * @param string $secret_key AWS secret access key id. 84 * @ throws \WP_Error If no distribution id provided, should throw error.84 * @ 85 85 */ 86 86 public function update_options( string $distribution_id, string $access_key = null, string $secret_key = null ) { 87 if ( ! $distribution_id ) {88 throw new \WP_Error( 'distribution id is required' );89 }90 91 87 $options = array( 92 88 'distribution_id' => $distribution_id, -
c3-cloudfront-clear-cache/tags/6.1.4/classes/WP/Post.php
r2558516 r2825667 39 39 * Get the post permalink 40 40 * 41 * @ throws \WP_Error If no post provided, should throw it.41 * @. 42 42 */ 43 43 public function get_permalink() { 44 44 if ( ! $this->post ) { 45 thrownew \WP_Error( 'Post is required' );45 new \WP_Error( 'Post is required' ); 46 46 } 47 47 return get_permalink( $this->post ); … … 65 65 * Load the post's term links 66 66 * 67 * @ throws \WP_Error If no post provided, should throw it.67 * @. 68 68 */ 69 69 public function get_the_post_term_links() { 70 70 if ( ! $this->post ) { 71 thrownew \WP_Error( 'Post is required' );71 new \WP_Error( 'Post is required' ); 72 72 } 73 73 $post = $this->post; … … 94 94 } 95 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 96 119 } -
c3-cloudfront-clear-cache/tags/6.1.4/classes/WP/Transient_Service.php
r2558516 r2825667 79 79 * Normalize invalidation query 80 80 * 81 * @param mi dex$query Invalidation query.81 * @param mi $query Invalidation query. 82 82 * @since 5.3.4 83 83 * @return array -
c3-cloudfront-clear-cache/tags/6.1.4/classes/WP/WP_CLI_Command.php
r2558516 r2825667 39 39 * 40 40 * @param string $args WP-CLI Command Name. 41 * @param string$assoc_args WP-CLI Command Option.41 * @param $assoc_args WP-CLI Command Option. 42 42 * @since 2.3.0 43 43 */ … … 103 103 * 104 104 * @param string $args WP-CLI Command Name. 105 * @param string$assoc_args WP-CLI Command Option.105 * @param $assoc_args WP-CLI Command Option. 106 106 * @since 2.4.0 107 107 */ -
c3-cloudfront-clear-cache/tags/6.1.4/composer.json
r2728981 r2825667 4 4 "type": "wordpress-plugin", 5 5 "require": { 6 "php": ">= 5.5"6 "php": ">=" 7 7 }, 8 8 "require-dev": { … … 12 12 "wp-coding-standards/wpcs": "*", 13 13 "wp-phpunit/wp-phpunit": "5.7.2", 14 "phpunit/phpunit": "7.5.20" 15 }, 14 "phpunit/phpunit": "7.5.20", 15 "yoast/phpunit-polyfills": "^1.0" 16 }, 16 17 "autoload": { 17 18 "psr-4": { … … 26 27 "lint": "phpcs --standard=./.phpcs.xml.dist", 27 28 "phpcs": "phpcs --standard=./.phpcs.xml.dist" 28 } 29 }, 30 "config": { 31 "allow-plugins": { 32 "dealerdirect/phpcodesniffer-composer-installer": true 33 } 34 } 29 35 } -
c3-cloudfront-clear-cache/tags/6.1.4/package.json
r2728981 r2825667 4 4 }, 5 5 "name": "trunk", 6 "version": "6.1. 3",6 "version": "6.1.", 7 7 "main": "index.js", 8 8 "directories": { -
c3-cloudfront-clear-cache/tags/6.1.4/readme.txt
r2728981 r2825667 4 4 Tags: AWS,CDN,CloudFront 5 5 Requires at least: 4.9.0 6 Tested up to: 5.9.37 Stable tag: 6.1. 36 Tested up to: 7 Stable tag: 6.1. 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 111 111 == Changelog == 112 112 113 114 115 113 116 == 6.1.3 == 114 117 * [Fix] Lost filter c3_invalidation_items From v6.0.0 -
c3-cloudfront-clear-cache/trunk/c3-cloudfront-clear-cache.php
r2728981 r2825667 2 2 /** 3 3 * Plugin Name: C3 Cloudfront Cache Controller 4 * Version: 6.1. 34 * Version: 6.1. 5 5 * Plugin URI:https://github.com/amimoto-ami/c3-cloudfront-clear-cache 6 6 * Description: Manage CloudFront Cache and provide some fixtures. 7 7 * Author: hideokamoto 8 8 * Author URI: https://wp-kyoto.net/ 9 * Requires PHP: 7. 09 * Requires PHP: 7. 10 10 * Text Domain: c3-cloudfront-clear-cache 11 11 * -
c3-cloudfront-clear-cache/trunk/classes/AWS/CloudFront_Service.php
r2558516 r2825667 13 13 } 14 14 15 15 16 use C3_CloudFront_Cache_Controller\WP; 16 17 use Aws\CloudFront\CloudFrontClient; … … 56 57 } elseif ( $value instanceof WP\Hooks ) { 57 58 $this->hook_service = $value; 58 } elseif ( $value instanceof Environment ) {59 } elseif ( $value instanceof Environment ) { 59 60 $this->env = $value; 60 61 } … … 94 95 * @param string $access_key AWS access key id. 95 96 * @param string $secret_key AWS secret access key id. 96 * @ throws \WP_Error|\Exception If AWS API returns any error, should throw it.97 * @. 97 98 */ 98 99 public function try_to_call_aws_api( string $distribution_id, string $access_key = null, string $secret_key = null ) { … … 112 113 ) 113 114 ); 114 return true;115 return ; 115 116 } catch ( \Exception $e ) { 116 if ( 'NoSuchDistribution' === $e->getAwsErrorCode() ) {117 if ( 'NoSuchDistribution' === $e->getAwsErrorCode() ) { 117 118 $e = new \WP_Error( 'C3 Auth Error', "Can not find CloudFront Distribution ID: {$distribution_id} is not found." ); 118 } elseif ( 'InvalidClientTokenId' === $e->getAwsErrorCode() ) {119 } elseif ( 'InvalidClientTokenId' === $e->getAwsErrorCode() ) { 119 120 $e = new \WP_Error( 'C3 Auth Error', 'AWS AWS Access Key or AWS Secret Key is invalid.' ); 120 121 } else { 121 122 $e = new \WP_Error( 'C3 Auth Error', $e->getMessage() ); 122 123 } 123 error_log( $e->get_error_messages(), 0 );124 throw$e;124 error_log( ), 0 ); 125 $e; 125 126 } 126 127 } … … 209 210 $result = $client->createInvalidation( $params ); 210 211 return $result; 211 } catch ( \Aws\CloudFront\Exception\TooManyInvalidationsInProgressException $e ) { 212 error_log( $e->__toString(), 0 ); 213 $e = new \WP_Error( 'C3 Invalidation Error', $e->__toString() ); 214 return $e; 215 } catch ( \Aws\CloudFront\Exception $e ) { 212 } catch ( \Aws\CloudFront\Exception\CloudFrontException $e ) { 216 213 error_log( $e->__toString(), 0 ); 217 214 $e = new \WP_Error( 'C3 Invalidation Error', $e->__toString() ); … … 244 241 } 245 242 return array(); 246 } catch ( \Aws\CloudFront\Exception\NoSuchDistributionException $e ) { 247 error_log( $options['distribution_id'] . 'not found' ); 243 } catch ( \Aws\CloudFront\Exception\CloudFrontException $e ) { 244 if ( isset( $distribution_id ) && 'NoSuchDistribution' === $e->getAwsErrorCode() ) { 245 error_log( $distribution_id . ' not found' ); 246 } 248 247 error_log( $e->__toString(), 0 ); 249 248 } catch ( \Exception $e ) { -
c3-cloudfront-clear-cache/trunk/classes/AWS/Invalidation_Batch_Service.php
r2728981 r2825667 91 91 $invalidation_batch->put_invalidation_path( $url ); 92 92 } 93 94 95 96 93 97 $invalidation_batch->apply_invalidation_item_filter( $post ); 94 98 return $invalidation_batch; -
c3-cloudfront-clear-cache/trunk/classes/Invalidation_Service.php
r2558516 r2825667 24 24 * Hook service 25 25 * 26 * @var WP\Hook _Service26 * @var WP\Hook 27 27 */ 28 28 private $hook_service; … … 38 38 * Transient service. 39 39 * 40 * @var AWS\Transient_Service40 * @var \Transient_Service 41 41 */ 42 42 private $transient_service; -
c3-cloudfront-clear-cache/trunk/classes/Settings_Service.php
r2558516 r2825667 84 84 * @param string $access_key AWS access key id. 85 85 * @param string $secret_key AWS secret access key id. 86 * @ throws \WP_Error If no distribution id provided, should throw error.86 * @ 87 87 */ 88 88 public function update_options( string $distribution_id, string $access_key = null, string $secret_key = null ) { 89 // Null check. 90 if ( ! $distribution_id ) { 91 throw new \WP_Error( 'distribution id is required' ); 89 // CloudFront API call. 90 $error = $this->cf_service->try_to_call_aws_api( $distribution_id, $access_key, $secret_key ); 91 if ( is_wp_error( $error ) ) { 92 return $error; 92 93 } 93 94 94 // CloudFront API call.95 $this-> cf_service->try_to_call_aws_api( $distribution_id, $access_key, $secret_key );95 // . 96 $this->( $distribution_id, $access_key, $secret_key ); 96 97 97 // Save. 98 $result = $this->options_service->update_options( $distribution_id, $access_key, $secret_key ); 99 return $result; 98 return null; 100 99 } 101 100 -
c3-cloudfront-clear-cache/trunk/classes/Views/Settings.php
r2728981 r2825667 92 92 * 93 93 * @access public 94 * @param none95 94 * @since 4.0.0 96 95 */ -
c3-cloudfront-clear-cache/trunk/classes/WP/Fixtures.php
r2559100 r2825667 100 100 * @param string $key Cookie key name. 101 101 * @param mixed $value Cookie value. 102 * @param in it$expires Cookie expiration.102 * @param in $expires Cookie expiration. 103 103 */ 104 104 private function set_cookie( $key, $value, $expires = 0 ) { -
c3-cloudfront-clear-cache/trunk/classes/WP/Options_Service.php
r2558516 r2825667 82 82 * @param string $access_key AWS access key id. 83 83 * @param string $secret_key AWS secret access key id. 84 * @ throws \WP_Error If no distribution id provided, should throw error.84 * @ 85 85 */ 86 86 public function update_options( string $distribution_id, string $access_key = null, string $secret_key = null ) { 87 if ( ! $distribution_id ) {88 throw new \WP_Error( 'distribution id is required' );89 }90 91 87 $options = array( 92 88 'distribution_id' => $distribution_id, -
c3-cloudfront-clear-cache/trunk/classes/WP/Post.php
r2558516 r2825667 39 39 * Get the post permalink 40 40 * 41 * @ throws \WP_Error If no post provided, should throw it.41 * @. 42 42 */ 43 43 public function get_permalink() { 44 44 if ( ! $this->post ) { 45 thrownew \WP_Error( 'Post is required' );45 new \WP_Error( 'Post is required' ); 46 46 } 47 47 return get_permalink( $this->post ); … … 65 65 * Load the post's term links 66 66 * 67 * @ throws \WP_Error If no post provided, should throw it.67 * @. 68 68 */ 69 69 public function get_the_post_term_links() { 70 70 if ( ! $this->post ) { 71 thrownew \WP_Error( 'Post is required' );71 new \WP_Error( 'Post is required' ); 72 72 } 73 73 $post = $this->post; … … 94 94 } 95 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 96 119 } -
c3-cloudfront-clear-cache/trunk/classes/WP/Transient_Service.php
r2558516 r2825667 79 79 * Normalize invalidation query 80 80 * 81 * @param mi dex$query Invalidation query.81 * @param mi $query Invalidation query. 82 82 * @since 5.3.4 83 83 * @return array -
c3-cloudfront-clear-cache/trunk/classes/WP/WP_CLI_Command.php
r2558516 r2825667 39 39 * 40 40 * @param string $args WP-CLI Command Name. 41 * @param string$assoc_args WP-CLI Command Option.41 * @param $assoc_args WP-CLI Command Option. 42 42 * @since 2.3.0 43 43 */ … … 103 103 * 104 104 * @param string $args WP-CLI Command Name. 105 * @param string$assoc_args WP-CLI Command Option.105 * @param $assoc_args WP-CLI Command Option. 106 106 * @since 2.4.0 107 107 */ -
c3-cloudfront-clear-cache/trunk/composer.json
r2728981 r2825667 4 4 "type": "wordpress-plugin", 5 5 "require": { 6 "php": ">= 5.5"6 "php": ">=" 7 7 }, 8 8 "require-dev": { … … 12 12 "wp-coding-standards/wpcs": "*", 13 13 "wp-phpunit/wp-phpunit": "5.7.2", 14 "phpunit/phpunit": "7.5.20" 15 }, 14 "phpunit/phpunit": "7.5.20", 15 "yoast/phpunit-polyfills": "^1.0" 16 }, 16 17 "autoload": { 17 18 "psr-4": { … … 26 27 "lint": "phpcs --standard=./.phpcs.xml.dist", 27 28 "phpcs": "phpcs --standard=./.phpcs.xml.dist" 28 } 29 }, 30 "config": { 31 "allow-plugins": { 32 "dealerdirect/phpcodesniffer-composer-installer": true 33 } 34 } 29 35 } -
c3-cloudfront-clear-cache/trunk/package.json
r2728981 r2825667 4 4 }, 5 5 "name": "trunk", 6 "version": "6.1. 3",6 "version": "6.1.", 7 7 "main": "index.js", 8 8 "directories": { -
c3-cloudfront-clear-cache/trunk/readme.txt
r2728981 r2825667 4 4 Tags: AWS,CDN,CloudFront 5 5 Requires at least: 4.9.0 6 Tested up to: 5.9.37 Stable tag: 6.1. 36 Tested up to: 7 Stable tag: 6.1. 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 111 111 == Changelog == 112 112 113 114 115 113 116 == 6.1.3 == 114 117 * [Fix] Lost filter c3_invalidation_items From v6.0.0
Note: See TracChangeset
for help on using the changeset viewer.