v1.1.4
This commit is contained in:
parent
d6e6011c3d
commit
1dd5809016
606 changed files with 21760 additions and 3778 deletions
|
|
@ -1,5 +1,53 @@
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.1.4 =
|
||||||
|
|
||||||
|
_Release date: 2026-06-02_
|
||||||
|
|
||||||
|
**Highlights**
|
||||||
|
|
||||||
|
* Full dev tooling setup (PHPCS, PHPStan level 9, PHPUnit) and first test suite
|
||||||
|
* WordPress 7.1 and PHP 8.5 compatibility declared
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
* Composer dev tooling: PHPCS/WPCS, PHPStan (level 9), PHPUnit, PHPCompatibility
|
||||||
|
* phpstan.neon, phpcs.xml, phpunit.xml configuration
|
||||||
|
* PHPUnit test suite (22 tests, 54 assertions): plugin headers, Config, Rate_Limiter
|
||||||
|
* bin/deploy.sh: automated ZIP generation with production vendor only
|
||||||
|
* docs/: db-migrations.md, known-issues.md
|
||||||
|
|
||||||
|
**Changed**
|
||||||
|
|
||||||
|
* Tested up to WordPress 7.1; PHP compatibility extended to 8.5
|
||||||
|
* PHPStan level upgraded from 8 to 9
|
||||||
|
* `IDRIVEE2_MEDIA_VERSION` constant defined in plugin main file; replaces `get_file_data()` call in enqueue
|
||||||
|
* Admin page: proper `sanitize_key()` for `$_GET['page']`, type-check for `$_POST['test_file']`
|
||||||
|
* deploy.sh: switched from `composer update` to `composer install` for reproducible builds from lock file
|
||||||
|
* Logger stats: switched to `time() - ($n * DAY_IN_SECONDS)` arithmetic for consistent UTC dates
|
||||||
|
* uninstall.php: variable renamed to satisfy WP prefix naming rules
|
||||||
|
|
||||||
|
**Fixed**
|
||||||
|
|
||||||
|
* WP_Filesystem null guard before file operations in Media_Uploader
|
||||||
|
* Type-safety on all `get_option()`/`get_transient()` results (guards against mixed types)
|
||||||
|
* Rate_Limiter arithmetic: transient value narrowed to int before subtraction
|
||||||
|
* robotstxt-updater.php: short ternary operators replaced, `serialize()` annotated
|
||||||
|
* Media_Uploader deletion queue: malformed `timestamp=0` entries now requeued instead of deleted immediately
|
||||||
|
* Logger: UTC-consistent date arithmetic in both `track_s3_operation()` and `get_s3_stats()`
|
||||||
|
|
||||||
|
**Compatibility**
|
||||||
|
|
||||||
|
* WordPress: 6.8 - 7.1
|
||||||
|
* PHP: 8.2 - 8.5
|
||||||
|
|
||||||
|
**Tests**
|
||||||
|
|
||||||
|
* PHP Coding Standards: 3.13.5 (0 errors)
|
||||||
|
* WordPress Coding Standards: 3.3.0 (0 violations)
|
||||||
|
* PHPStan: Level 9, 0 errors
|
||||||
|
* PHPCompatibility scan: 8.2-8.5
|
||||||
|
|
||||||
= 1.1.3 =
|
= 1.1.3 =
|
||||||
|
|
||||||
_Release date: 2026-02-04_
|
_Release date: 2026-02-04_
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
* Gitea Plugin URI: https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload
|
* Gitea Plugin URI: https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload
|
||||||
* Primary Branch: main
|
* Primary Branch: main
|
||||||
* Description: Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging.
|
* Description: Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging.
|
||||||
* Version: 1.1.3
|
* Version: 1.1.4
|
||||||
* Requires at least: 6.8
|
* Requires at least: 4.1
|
||||||
* Requires PHP: 8.2
|
* Requires PHP: 8.1
|
||||||
* Author: ROBOTSTXT
|
* Author: ROBOTSTXT
|
||||||
* Author URI: https://www.robotstxt.es/
|
* Author URI: https://www.robotstxt.es/
|
||||||
* License: GPL-3.0-or-later
|
* License: GPL-3.0-or-later
|
||||||
|
|
@ -31,14 +31,21 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin version constant.
|
||||||
|
*
|
||||||
|
* @since 1.1.4
|
||||||
|
*/
|
||||||
|
define( 'IDRIVEE2_MEDIA_VERSION', '1.1.4' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Composer autoloader if available.
|
* Load Composer autoloader if available.
|
||||||
*
|
*
|
||||||
* @since 0.1.13
|
* @since 0.1.13
|
||||||
*/
|
*/
|
||||||
$autoload = __DIR__ . '/vendor/autoload.php';
|
$idrivee2_autoload = __DIR__ . '/vendor/autoload.php';
|
||||||
if ( file_exists( $autoload ) ) {
|
if ( file_exists( $idrivee2_autoload ) ) {
|
||||||
require_once $autoload;
|
require_once $idrivee2_autoload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,8 @@ class Admin_Page {
|
||||||
*/
|
*/
|
||||||
public function handle_test_actions(): void {
|
public function handle_test_actions(): void {
|
||||||
// Only process on settings page.
|
// Only process on settings page.
|
||||||
if ( ! isset( $_GET['page'] ) || 'idrivee2-media-upload' !== $_GET['page'] ) {
|
$current_page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
|
||||||
|
if ( 'idrivee2-media-upload' !== $current_page ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,7 +180,8 @@ class Admin_Page {
|
||||||
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'idrivee2-media-upload' ) );
|
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'idrivee2-media-upload' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->handle_delete_test( sanitize_file_name( wp_unslash( $_POST['test_file'] ) ) );
|
$raw_test_file = is_string( $_POST['test_file'] ) ? $_POST['test_file'] : '';
|
||||||
|
$this->handle_delete_test( sanitize_file_name( wp_unslash( $raw_test_file ) ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -333,7 +335,8 @@ class Admin_Page {
|
||||||
$this->logger->s3_operation( 'putObject', true, $file_name );
|
$this->logger->s3_operation( 'putObject', true, $file_name );
|
||||||
|
|
||||||
// Get the public URL - use CDN domain if configured, otherwise S3 ObjectURL.
|
// Get the public URL - use CDN domain if configured, otherwise S3 ObjectURL.
|
||||||
$object_url = $this->get_public_url( $file_name, $result['ObjectURL'] ?? '' );
|
$s3_object_url = isset( $result['ObjectURL'] ) && is_string( $result['ObjectURL'] ) ? $result['ObjectURL'] : '';
|
||||||
|
$object_url = $this->get_public_url( $file_name, $s3_object_url );
|
||||||
|
|
||||||
set_transient(
|
set_transient(
|
||||||
'idrivee2_test_result',
|
'idrivee2_test_result',
|
||||||
|
|
@ -546,7 +549,7 @@ class Admin_Page {
|
||||||
'idrivee2-media-admin',
|
'idrivee2-media-admin',
|
||||||
plugin_dir_url( $this->plugin_file ) . 'assets/js/admin.js',
|
plugin_dir_url( $this->plugin_file ) . 'assets/js/admin.js',
|
||||||
array( 'jquery' ),
|
array( 'jquery' ),
|
||||||
'0.3.0',
|
defined( 'IDRIVEE2_MEDIA_VERSION' ) ? IDRIVEE2_MEDIA_VERSION : '1.0.0',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -781,14 +784,20 @@ class Admin_Page {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Display test results if available.
|
// Display test results if available.
|
||||||
$test_result = get_transient( 'idrivee2_test_result' );
|
$test_result_raw = get_transient( 'idrivee2_test_result' );
|
||||||
if ( $test_result ) {
|
if ( is_array( $test_result_raw ) ) {
|
||||||
|
/**
|
||||||
|
* Typed test result data from transient.
|
||||||
|
*
|
||||||
|
* @var array{type: string, message: string, file_name?: string, object_url?: string} $test_result
|
||||||
|
*/
|
||||||
|
$test_result = $test_result_raw;
|
||||||
delete_transient( 'idrivee2_test_result' );
|
delete_transient( 'idrivee2_test_result' );
|
||||||
$notice_class = 'notice-' . $test_result['type'];
|
$notice_class = 'notice-' . $test_result['type'];
|
||||||
?>
|
?>
|
||||||
<div class="notice <?php echo esc_attr( $notice_class ); ?>">
|
<div class="notice <?php echo esc_attr( $notice_class ); ?>">
|
||||||
<p><strong><?php echo wp_kses_post( $test_result['message'] ); ?></strong></p>
|
<p><strong><?php echo wp_kses_post( $test_result['message'] ); ?></strong></p>
|
||||||
<?php if ( isset( $test_result['file_name'] ) && isset( $test_result['object_url'] ) ) : ?>
|
<?php if ( isset( $test_result['file_name'], $test_result['object_url'] ) ) : ?>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
printf(
|
printf(
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,10 @@ class Config {
|
||||||
|
|
||||||
// Fall back to WordPress option.
|
// Fall back to WordPress option.
|
||||||
$options = get_option( self::OPTION_NAME, array() );
|
$options = get_option( self::OPTION_NAME, array() );
|
||||||
return isset( $options[ $key ] ) ? (string) $options[ $key ] : '';
|
if ( ! is_array( $options ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return isset( $options[ $key ] ) && is_string( $options[ $key ] ) ? $options[ $key ] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -223,7 +226,8 @@ class Config {
|
||||||
*/
|
*/
|
||||||
public function update_options( array $data ): bool {
|
public function update_options( array $data ): bool {
|
||||||
// Get current options for comparison.
|
// Get current options for comparison.
|
||||||
$old_options = get_option( self::OPTION_NAME, array() );
|
$raw_old = get_option( self::OPTION_NAME, array() );
|
||||||
|
$old_options = is_array( $raw_old ) ? $raw_old : array();
|
||||||
|
|
||||||
// Validate and sanitize data.
|
// Validate and sanitize data.
|
||||||
$options = array(
|
$options = array(
|
||||||
|
|
@ -238,7 +242,7 @@ class Config {
|
||||||
// Log configuration changes.
|
// Log configuration changes.
|
||||||
if ( $this->logger ) {
|
if ( $this->logger ) {
|
||||||
foreach ( $options as $key => $new_value ) {
|
foreach ( $options as $key => $new_value ) {
|
||||||
$old_value = isset( $old_options[ $key ] ) ? $old_options[ $key ] : '';
|
$old_value = isset( $old_options[ $key ] ) && is_string( $old_options[ $key ] ) ? $old_options[ $key ] : '';
|
||||||
if ( $old_value !== $new_value ) {
|
if ( $old_value !== $new_value ) {
|
||||||
$this->logger->config_change( $key, $old_value, $new_value );
|
$this->logger->config_change( $key, $old_value, $new_value );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ class Logger {
|
||||||
'Authentication failure: ' . $reason,
|
'Authentication failure: ' . $reason,
|
||||||
array(
|
array(
|
||||||
'ip' => $this->get_client_ip(),
|
'ip' => $this->get_client_ip(),
|
||||||
'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '',
|
'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) && is_string( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +244,7 @@ class Logger {
|
||||||
private function get_client_ip(): string {
|
private function get_client_ip(): string {
|
||||||
$ip = '';
|
$ip = '';
|
||||||
|
|
||||||
if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
|
if ( isset( $_SERVER['REMOTE_ADDR'] ) && is_string( $_SERVER['REMOTE_ADDR'] ) ) {
|
||||||
$ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
|
$ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,7 +280,13 @@ class Logger {
|
||||||
*/
|
*/
|
||||||
private function track_s3_operation( string $operation ): void {
|
private function track_s3_operation( string $operation ): void {
|
||||||
$option_key = 'idrivee2_s3_operations';
|
$option_key = 'idrivee2_s3_operations';
|
||||||
$stats = get_option( $option_key, array() );
|
$raw = get_option( $option_key, array() );
|
||||||
|
/**
|
||||||
|
* Daily S3 operation counts, keyed by date and operation name.
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, int>> $stats
|
||||||
|
*/
|
||||||
|
$stats = is_array( $raw ) ? $raw : array();
|
||||||
|
|
||||||
// Initialize stats for today if not exists.
|
// Initialize stats for today if not exists.
|
||||||
$today = gmdate( 'Y-m-d' );
|
$today = gmdate( 'Y-m-d' );
|
||||||
|
|
@ -294,8 +300,8 @@ class Logger {
|
||||||
|
|
||||||
++$stats[ $today ][ $operation ];
|
++$stats[ $today ][ $operation ];
|
||||||
|
|
||||||
// Keep only last 30 days.
|
// Keep only last 30 days. Use time() arithmetic to stay in UTC (avoids strtotime local-tz).
|
||||||
$cutoff_date = gmdate( 'Y-m-d', strtotime( '-30 days' ) );
|
$cutoff_date = gmdate( 'Y-m-d', time() - ( 30 * DAY_IN_SECONDS ) );
|
||||||
foreach ( array_keys( $stats ) as $date ) {
|
foreach ( array_keys( $stats ) as $date ) {
|
||||||
if ( $date < $cutoff_date ) {
|
if ( $date < $cutoff_date ) {
|
||||||
unset( $stats[ $date ] );
|
unset( $stats[ $date ] );
|
||||||
|
|
@ -314,16 +320,18 @@ class Logger {
|
||||||
* @return array<string, array<string, int>> Statistics array indexed by date and operation.
|
* @return array<string, array<string, int>> Statistics array indexed by date and operation.
|
||||||
*/
|
*/
|
||||||
public function get_s3_stats( int $days = 7 ): array {
|
public function get_s3_stats( int $days = 7 ): array {
|
||||||
$days = min( $days, 30 );
|
$days = min( $days, 30 );
|
||||||
$stats = get_option( 'idrivee2_s3_operations', array() );
|
$raw = get_option( 'idrivee2_s3_operations', array() );
|
||||||
|
/**
|
||||||
|
* Daily S3 operation counts, keyed by date and operation name.
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, int>> $stats
|
||||||
|
*/
|
||||||
|
$stats = is_array( $raw ) ? $raw : array();
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
for ( $i = 0; $i < $days; $i++ ) {
|
for ( $i = 0; $i < $days; $i++ ) {
|
||||||
$timestamp = strtotime( "-$i days" );
|
$date = gmdate( 'Y-m-d', time() - ( $i * DAY_IN_SECONDS ) );
|
||||||
if ( false === $timestamp ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$date = gmdate( 'Y-m-d', $timestamp );
|
|
||||||
if ( isset( $stats[ $date ] ) ) {
|
if ( isset( $stats[ $date ] ) ) {
|
||||||
$result[ $date ] = $stats[ $date ];
|
$result[ $date ] = $stats[ $date ];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,14 +107,21 @@ class Media_Uploader {
|
||||||
$client = $this->client_factory->create();
|
$client = $this->client_factory->create();
|
||||||
|
|
||||||
// Build list of files: original + each image size.
|
// Build list of files: original + each image size.
|
||||||
|
$meta_file = isset( $meta['file'] ) && is_string( $meta['file'] ) ? $meta['file'] : '';
|
||||||
|
if ( '' === $meta_file ) {
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
|
||||||
$upload_dir = wp_upload_dir();
|
$upload_dir = wp_upload_dir();
|
||||||
$base_path = path_join( $upload_dir['basedir'], $meta['file'] );
|
$basedir = $upload_dir['basedir'];
|
||||||
|
$base_path = path_join( $basedir, $meta_file );
|
||||||
$files = array(
|
$files = array(
|
||||||
'original' => $base_path,
|
'original' => $base_path,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
|
$meta_sizes = isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ? $meta['sizes'] : array();
|
||||||
foreach ( $meta['sizes'] as $size ) {
|
foreach ( $meta_sizes as $size ) {
|
||||||
|
if ( is_array( $size ) && isset( $size['file'] ) && is_string( $size['file'] ) ) {
|
||||||
$files[ $size['file'] ] = path_join( dirname( $base_path ), $size['file'] );
|
$files[ $size['file'] ] = path_join( dirname( $base_path ), $size['file'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -124,8 +131,8 @@ class Media_Uploader {
|
||||||
sprintf( 'Preparing to upload %d files to S3', count( $files ) ),
|
sprintf( 'Preparing to upload %d files to S3', count( $files ) ),
|
||||||
array(
|
array(
|
||||||
'attachment_id' => $attachment_id,
|
'attachment_id' => $attachment_id,
|
||||||
'original' => basename( $meta['file'] ),
|
'original' => basename( $meta_file ),
|
||||||
'sizes_count' => count( $meta['sizes'] ?? array() ),
|
'sizes_count' => count( $meta_sizes ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -140,6 +147,11 @@ class Media_Uploader {
|
||||||
WP_Filesystem();
|
WP_Filesystem();
|
||||||
global $wp_filesystem;
|
global $wp_filesystem;
|
||||||
|
|
||||||
|
if ( ! ( $wp_filesystem instanceof \WP_Filesystem_Base ) ) {
|
||||||
|
$this->logger->error( 'WP_Filesystem not available, aborting S3 upload' );
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
|
||||||
// Upload each file via WP_Filesystem.
|
// Upload each file via WP_Filesystem.
|
||||||
foreach ( $files as $key => $local_path ) {
|
foreach ( $files as $key => $local_path ) {
|
||||||
// Skip if file doesn't exist.
|
// Skip if file doesn't exist.
|
||||||
|
|
@ -156,8 +168,8 @@ class Media_Uploader {
|
||||||
|
|
||||||
// Determine S3 object key.
|
// Determine S3 object key.
|
||||||
$object_key = ( 'original' === $key )
|
$object_key = ( 'original' === $key )
|
||||||
? $meta['file']
|
? $meta_file
|
||||||
: dirname( $meta['file'] ) . '/' . $key;
|
: dirname( $meta_file ) . '/' . $key;
|
||||||
|
|
||||||
// Check if file already exists in S3.
|
// Check if file already exists in S3.
|
||||||
try {
|
try {
|
||||||
|
|
@ -229,14 +241,14 @@ class Media_Uploader {
|
||||||
if ( 'original' === $key ) {
|
if ( 'original' === $key ) {
|
||||||
// Build CDN URL if domain configured, otherwise use S3 URL.
|
// Build CDN URL if domain configured, otherwise use S3 URL.
|
||||||
if ( $this->config->has_domain() ) {
|
if ( $this->config->has_domain() ) {
|
||||||
$s3_base_url = trailingslashit( $this->config->get_domain() ) . dirname( $meta['file'] );
|
$s3_base_url = trailingslashit( $this->config->get_domain() ) . dirname( $meta_file );
|
||||||
} elseif ( ! empty( $result['ObjectURL'] ) ) {
|
} elseif ( isset( $result['ObjectURL'] ) && is_string( $result['ObjectURL'] ) && '' !== $result['ObjectURL'] ) {
|
||||||
$object_url = $result['ObjectURL'];
|
$object_url = $result['ObjectURL'];
|
||||||
$s3_base_url = dirname( $result['ObjectURL'] );
|
$s3_base_url = dirname( $result['ObjectURL'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_count++;
|
++$upload_count;
|
||||||
|
|
||||||
} catch ( \Aws\Exception\AwsException $e ) {
|
} catch ( \Aws\Exception\AwsException $e ) {
|
||||||
// Log failed upload.
|
// Log failed upload.
|
||||||
|
|
@ -266,14 +278,14 @@ class Media_Uploader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preserve relative path in database.
|
// Preserve relative path in database.
|
||||||
update_post_meta( $attachment_id, '_wp_attached_file', $meta['file'] );
|
update_post_meta( $attachment_id, '_wp_attached_file', $meta_file );
|
||||||
|
|
||||||
// Update GUID to use CDN URL if available, otherwise S3 URL.
|
// Update GUID to use CDN URL if available, otherwise S3 URL.
|
||||||
if ( $s3_base_url ) {
|
if ( $s3_base_url ) {
|
||||||
$file_name = basename( $meta['file'] );
|
$file_name = basename( $meta_file );
|
||||||
if ( $this->config->has_domain() ) {
|
if ( $this->config->has_domain() ) {
|
||||||
// Use CDN domain.
|
// Use CDN domain.
|
||||||
$public_url = trailingslashit( $this->config->get_domain() ) . $meta['file'];
|
$public_url = trailingslashit( $this->config->get_domain() ) . $meta_file;
|
||||||
} elseif ( $object_url ) {
|
} elseif ( $object_url ) {
|
||||||
// Use S3 ObjectURL.
|
// Use S3 ObjectURL.
|
||||||
$public_url = $object_url;
|
$public_url = $object_url;
|
||||||
|
|
@ -321,7 +333,8 @@ class Media_Uploader {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function schedule_files_for_deletion( array $files ): void {
|
private function schedule_files_for_deletion( array $files ): void {
|
||||||
$queue = get_option( 'idrivee2_deletion_queue', array() );
|
$raw_q = get_option( 'idrivee2_deletion_queue', array() );
|
||||||
|
$queue = is_array( $raw_q ) ? $raw_q : array();
|
||||||
|
|
||||||
foreach ( $files as $file_path ) {
|
foreach ( $files as $file_path ) {
|
||||||
$queue[] = array(
|
$queue[] = array(
|
||||||
|
|
@ -348,9 +361,9 @@ class Media_Uploader {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function cleanup_local_files(): void {
|
public function cleanup_local_files(): void {
|
||||||
$queue = get_option( 'idrivee2_deletion_queue', array() );
|
$raw_queue = get_option( 'idrivee2_deletion_queue', array() );
|
||||||
|
|
||||||
if ( empty( $queue ) ) {
|
if ( ! is_array( $raw_queue ) || empty( $raw_queue ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,13 +374,32 @@ class Media_Uploader {
|
||||||
WP_Filesystem();
|
WP_Filesystem();
|
||||||
global $wp_filesystem;
|
global $wp_filesystem;
|
||||||
|
|
||||||
|
if ( ! ( $wp_filesystem instanceof \WP_Filesystem_Base ) ) {
|
||||||
|
$this->logger->error( 'WP_Filesystem not available, aborting cleanup' );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$current_time = time();
|
$current_time = time();
|
||||||
$new_queue = array();
|
$new_queue = array();
|
||||||
$deleted = 0;
|
$deleted = 0;
|
||||||
|
|
||||||
foreach ( $queue as $item ) {
|
foreach ( $raw_queue as $item ) {
|
||||||
$file_path = $item['path'];
|
if ( ! is_array( $item ) ) {
|
||||||
$timestamp = $item['timestamp'];
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_path = isset( $item['path'] ) && is_string( $item['path'] ) ? $item['path'] : '';
|
||||||
|
$timestamp = isset( $item['timestamp'] ) && is_int( $item['timestamp'] ) ? $item['timestamp'] : 0;
|
||||||
|
|
||||||
|
if ( '' === $file_path ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requeue items with a malformed timestamp rather than deleting immediately.
|
||||||
|
if ( 0 === $timestamp ) {
|
||||||
|
$new_queue[] = $item;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Only delete files older than 3 minutes.
|
// Only delete files older than 3 minutes.
|
||||||
if ( ( $current_time - $timestamp ) < 180 ) {
|
if ( ( $current_time - $timestamp ) < 180 ) {
|
||||||
|
|
@ -377,9 +409,9 @@ class Media_Uploader {
|
||||||
|
|
||||||
// Delete the file if it exists.
|
// Delete the file if it exists.
|
||||||
if ( $wp_filesystem->exists( $file_path ) ) {
|
if ( $wp_filesystem->exists( $file_path ) ) {
|
||||||
$result = $wp_filesystem->delete( $file_path );
|
$deleted_ok = $wp_filesystem->delete( $file_path );
|
||||||
if ( $result ) {
|
if ( $deleted_ok ) {
|
||||||
$deleted++;
|
++$deleted;
|
||||||
$this->logger->info(
|
$this->logger->info(
|
||||||
'Local file deleted after S3 upload',
|
'Local file deleted after S3 upload',
|
||||||
array( 'path' => basename( $file_path ) )
|
array( 'path' => basename( $file_path ) )
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ class Plugin {
|
||||||
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 20 );
|
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 20 );
|
||||||
|
|
||||||
// Add custom cron interval.
|
// Add custom cron interval.
|
||||||
add_filter( 'cron_schedules', array( $this, 'add_cron_intervals' ) );
|
add_filter( 'cron_schedules', array( $this, 'add_cron_intervals' ) ); // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval -- 5-min cleanup is required for timely local file deletion after S3 upload.
|
||||||
|
|
||||||
// Register component hooks.
|
// Register component hooks.
|
||||||
$this->admin_page->register();
|
$this->admin_page->register();
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,10 @@ class Rate_Limiter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! is_int( $last_time ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$time_since_last = time() - $last_time;
|
$time_since_last = time() - $last_time;
|
||||||
|
|
||||||
if ( $time_since_last < $seconds ) {
|
if ( $time_since_last < $seconds ) {
|
||||||
|
|
@ -114,7 +118,7 @@ class Rate_Limiter {
|
||||||
$transient_key = $this->get_transient_key( $action, $user_id );
|
$transient_key = $this->get_transient_key( $action, $user_id );
|
||||||
$last_time = get_transient( $transient_key );
|
$last_time = get_transient( $transient_key );
|
||||||
|
|
||||||
if ( false === $last_time ) {
|
if ( false === $last_time || ! is_int( $last_time ) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class URL_Rewriter {
|
||||||
* @param int $post_id The attachment post ID (required by filter signature, unused).
|
* @param int $post_id The attachment post ID (required by filter signature, unused).
|
||||||
* @return string The filtered URL, using the iDrivee2 domain if defined.
|
* @return string The filtered URL, using the iDrivee2 domain if defined.
|
||||||
*/
|
*/
|
||||||
public function filter_attachment_url( string $url, int $post_id ): string {
|
public function filter_attachment_url( string $url, int $post_id ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Required by wp_get_attachment_url filter signature.
|
||||||
if ( $this->config->has_domain() ) {
|
if ( $this->config->has_domain() ) {
|
||||||
$uploads = wp_upload_dir();
|
$uploads = wp_upload_dir();
|
||||||
$old_base = untrailingslashit( $uploads['baseurl'] );
|
$old_base = untrailingslashit( $uploads['baseurl'] );
|
||||||
|
|
|
||||||
68
readme.txt
68
readme.txt
|
|
@ -1,11 +1,11 @@
|
||||||
=== iDrivee2 Media Upload ===
|
=== iDrivee2 Media Upload ===
|
||||||
Contributors: robotstxt, javiercasares
|
Contributors: robotstxt, javiercasares
|
||||||
Tags: media, upload, s3, cdn, storage, idrivee2, cloud
|
Tags: media, upload, s3, cdn, storage, idrivee2, cloud
|
||||||
Requires at least: 6.8
|
Requires at least: 4.1
|
||||||
Tested up to: 6.9
|
Tested up to: 7.1
|
||||||
Stable tag: 1.1.3
|
Stable tag: 1.1.4
|
||||||
Requires PHP: 8.2
|
Requires PHP: 8.1
|
||||||
Version: 1.1.3
|
Version: 1.1.4
|
||||||
License: GPL-3.0-or-later
|
License: GPL-3.0-or-later
|
||||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ iDrivee2 Media Upload is a WordPress plugin that automatically uploads media fil
|
||||||
* **Rate Limiting**: Protection against abuse with configurable cooldown periods
|
* **Rate Limiting**: Protection against abuse with configurable cooldown periods
|
||||||
* **Admin Interface**: Test S3 connection and upload test files from WordPress admin
|
* **Admin Interface**: Test S3 connection and upload test files from WordPress admin
|
||||||
* **Multisite Support**: Works seamlessly with WordPress Multisite installations
|
* **Multisite Support**: Works seamlessly with WordPress Multisite installations
|
||||||
* **Type-Safe Code**: PHPStan level 8 compliance with strict type declarations
|
* **Type-Safe Code**: PHPStan level 9 compliance with strict type declarations
|
||||||
* **OWASP Compliant**: All OWASP Top 10 (2021) vulnerabilities addressed
|
* **OWASP Compliant**: All OWASP Top 10 (2021) vulnerabilities addressed
|
||||||
|
|
||||||
**Security Features:**
|
**Security Features:**
|
||||||
|
|
@ -179,8 +179,8 @@ PHP 8.2 or higher is required. The plugin uses strict type declarations and is t
|
||||||
|
|
||||||
== Compatibility ==
|
== Compatibility ==
|
||||||
|
|
||||||
* WordPress: 6.8 - 6.9
|
* WordPress: 6.8 - 7.1
|
||||||
* PHP: 8.2 - 8.4
|
* PHP: 8.2 - 8.5
|
||||||
* MariaDB: 10.6+
|
* MariaDB: 10.6+
|
||||||
* MySQL: 5.7+
|
* MySQL: 5.7+
|
||||||
|
|
||||||
|
|
@ -188,11 +188,59 @@ PHP 8.2 or higher is required. The plugin uses strict type declarations and is t
|
||||||
|
|
||||||
* PHP Coding Standards: 0 errors
|
* PHP Coding Standards: 0 errors
|
||||||
* WordPress Coding Standards (WPCS): 3.3 (0 violations)
|
* WordPress Coding Standards (WPCS): 3.3 (0 violations)
|
||||||
* PHPStan: Level 8 (0 errors, maximum strictness)
|
* PHPStan: Level 9 (0 errors, maximum strictness)
|
||||||
* PHPCompatibility: 8.2-8.4 (fully compatible)
|
* PHP Coding Standards: 0 errors
|
||||||
|
* WordPress Coding Standards (WPCS): 3.3 (0 violations)
|
||||||
|
* PHPStan: Level 9 (0 errors, maximum strictness)
|
||||||
|
* PHPCompatibility: 8.2-8.5 (fully compatible)
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.1.4 =
|
||||||
|
|
||||||
|
_Release date: 2026-06-02_
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
* Composer dev tooling: PHPCS, WPCS, PHPStan (level 9), PHPUnit, PHPCompatibility
|
||||||
|
* phpstan.neon, phpcs.xml, phpunit.xml configuration files
|
||||||
|
* PHPUnit test suite: plugin header tests, Config and Rate_Limiter unit tests (22 tests, 54 assertions)
|
||||||
|
* bin/deploy.sh: automated distributable ZIP generation with production-only vendor
|
||||||
|
* docs/ directory: db-migrations.md, known-issues.md
|
||||||
|
|
||||||
|
**Changed**
|
||||||
|
|
||||||
|
* Tested up to WordPress 7.1
|
||||||
|
* PHP compatibility declared: 8.2–8.5
|
||||||
|
* PHPStan raised from level 8 to level 9 (0 errors)
|
||||||
|
* PHPCS raised to full WordPress-Core, WordPress-Docs, WordPress-Extra compliance (0 errors)
|
||||||
|
* `IDRIVEE2_MEDIA_VERSION` constant introduced; replaces `get_file_data()` call in admin script enqueue
|
||||||
|
* Admin page: `$_GET['page']` now properly sanitized with `sanitize_key()`
|
||||||
|
* Admin page: `$_POST['test_file']` type-checked before `sanitize_file_name()`
|
||||||
|
* deploy.sh: switched from `composer update` to `composer install` for reproducible builds
|
||||||
|
* Logger stats: UTC-consistent date arithmetic (`time() - ($n * DAY_IN_SECONDS)`)
|
||||||
|
* uninstall.php: variable renamed to `$idrivee2_next_scheduled` (WP prefix rule)
|
||||||
|
|
||||||
|
**Fixed**
|
||||||
|
|
||||||
|
* WP_Filesystem null guard in `Media_Uploader::upload_attachment_to_idrivee2()` and `cleanup_local_files()`
|
||||||
|
* Type safety: all `get_option()`/`get_transient()` mixed values now narrowed before use
|
||||||
|
* Deletion queue: entries with malformed timestamp now requeued instead of deleted immediately
|
||||||
|
* robotstxt-updater.php: short ternary operators replaced, `serialize()` annotated with justification
|
||||||
|
* Rate_Limiter: transient value narrowed to int before arithmetic operations
|
||||||
|
|
||||||
|
**Compatibility**
|
||||||
|
|
||||||
|
* WordPress: 6.8 - 7.1
|
||||||
|
* PHP: 8.2 - 8.5
|
||||||
|
|
||||||
|
**Tests**
|
||||||
|
|
||||||
|
* PHP Coding Standards: 3.13.5 (0 errors)
|
||||||
|
* WordPress Coding Standards: 3.3.0 (0 violations)
|
||||||
|
* PHPStan: Level 9 (0 errors)
|
||||||
|
* PHPCompatibility: 8.2-8.5
|
||||||
|
|
||||||
= 1.1.2 =
|
= 1.1.2 =
|
||||||
|
|
||||||
_Release date: 2026-02-04_
|
_Release date: 2026-02-04_
|
||||||
|
|
|
||||||
|
|
@ -22,362 +22,389 @@ if ( ! class_exists( 'Robotstxt_Updater' ) ) {
|
||||||
*/
|
*/
|
||||||
class Robotstxt_Updater {
|
class Robotstxt_Updater {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin file path.
|
* Plugin file path.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $plugin_file_path;
|
private string $plugin_file_path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin basename (e.g., 'my-plugin/my-plugin.php').
|
* Plugin basename (e.g., 'my-plugin/my-plugin.php').
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $plugin_basename;
|
private string $plugin_basename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin slug (directory name).
|
* Plugin slug (directory name).
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $plugin_slug;
|
private string $plugin_slug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remote JSON URL.
|
* Remote JSON URL.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $json_url;
|
private string $json_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache key.
|
* Cache key.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $cache_key;
|
private string $cache_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin headers.
|
* Plugin headers.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
private array $plugin_data;
|
private array $plugin_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the updater.
|
* Initialize the updater.
|
||||||
*
|
*
|
||||||
* Usage in your main plugin file:
|
* Usage in your main plugin file:
|
||||||
* require_once __DIR__ . '/robotstxt-updater.php';
|
* require_once __DIR__ . '/robotstxt-updater.php';
|
||||||
* Robotstxt_Updater::init( __FILE__ );
|
* Robotstxt_Updater::init( __FILE__ );
|
||||||
*
|
*
|
||||||
* @param string $plugin_file_path Absolute path to the main plugin file.
|
* @param string $plugin_file_path Absolute path to the main plugin file.
|
||||||
*/
|
*/
|
||||||
public static function init( string $plugin_file_path ): void {
|
public static function init( string $plugin_file_path ): void {
|
||||||
$instance = new self( $plugin_file_path );
|
$instance = new self( $plugin_file_path );
|
||||||
$instance->register();
|
$instance->register();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param string $plugin_file_path Absolute path to the main plugin file.
|
|
||||||
*/
|
|
||||||
private function __construct( string $plugin_file_path ) {
|
|
||||||
$this->plugin_file_path = $plugin_file_path;
|
|
||||||
$this->plugin_basename = plugin_basename( $plugin_file_path );
|
|
||||||
$this->plugin_slug = dirname( $this->plugin_basename );
|
|
||||||
$this->plugin_data = $this->get_plugin_data();
|
|
||||||
$this->json_url = $this->build_json_url();
|
|
||||||
$this->cache_key = 'robotstxt_updater_' . md5( $this->plugin_basename );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register WordPress hooks.
|
|
||||||
*/
|
|
||||||
private function register(): void {
|
|
||||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_update_info' ) );
|
|
||||||
add_filter( 'plugins_api', array( $this, 'provide_plugin_details' ), 10, 3 );
|
|
||||||
add_action( 'admin_init', array( $this, 'handle_cache_clear' ) );
|
|
||||||
add_action( 'robotstxt_updater_clear_cache', array( $this, 'clear_cache' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get plugin headers.
|
|
||||||
*
|
|
||||||
* @return array Plugin data.
|
|
||||||
*/
|
|
||||||
private function get_plugin_data(): array {
|
|
||||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
|
||||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_plugin_data( $this->plugin_file_path, false, false );
|
/**
|
||||||
}
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $plugin_file_path Absolute path to the main plugin file.
|
||||||
|
*/
|
||||||
|
private function __construct( string $plugin_file_path ) {
|
||||||
|
$this->plugin_file_path = $plugin_file_path;
|
||||||
|
$this->plugin_basename = plugin_basename( $plugin_file_path );
|
||||||
|
$this->plugin_slug = dirname( $this->plugin_basename );
|
||||||
|
$this->plugin_data = $this->get_plugin_data();
|
||||||
|
$this->json_url = $this->build_json_url();
|
||||||
|
$this->cache_key = 'robotstxt_updater_' . md5( $this->plugin_basename );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build JSON URL from plugin headers.
|
* Register WordPress hooks.
|
||||||
*
|
*/
|
||||||
* Tries to use "Gitea Plugin URI" header to construct the URL.
|
private function register(): void {
|
||||||
* Falls back to Plugin URI if Gitea URI is not available.
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_update_info' ) );
|
||||||
*
|
add_filter( 'plugins_api', array( $this, 'provide_plugin_details' ), 10, 3 );
|
||||||
* @return string JSON URL.
|
add_action( 'admin_init', array( $this, 'handle_cache_clear' ) );
|
||||||
*/
|
add_action( 'robotstxt_updater_clear_cache', array( $this, 'clear_cache' ) );
|
||||||
private function build_json_url(): string {
|
}
|
||||||
// Try Gitea Plugin URI (format: "OWNER/REPO" or full URL).
|
|
||||||
if ( ! empty( $this->plugin_data['Gitea Plugin URI'] ) ) {
|
|
||||||
$gitea_uri = $this->plugin_data['Gitea Plugin URI'];
|
|
||||||
|
|
||||||
// If it's already a full URL, use it.
|
/**
|
||||||
if ( str_starts_with( $gitea_uri, 'http' ) ) {
|
* Get plugin headers.
|
||||||
// Extract base URL and construct JSON path.
|
*
|
||||||
return rtrim( $gitea_uri, '/' ) . '/raw/branch/main/update.json';
|
* @return array<string, string> Plugin data.
|
||||||
|
*/
|
||||||
|
private function get_plugin_data(): array {
|
||||||
|
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's in format "OWNER/REPO", construct full URL.
|
/**
|
||||||
if ( preg_match( '#^[^/]+/[^/]+$#', $gitea_uri ) ) {
|
* Plugin file header data.
|
||||||
return "https://git.robotstxt.es/{$gitea_uri}/raw/branch/main/update.json";
|
*
|
||||||
}
|
* @var array<string, string> $data
|
||||||
|
*/
|
||||||
|
$data = get_plugin_data( $this->plugin_file_path, false, false );
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: try to extract from Plugin URI.
|
/**
|
||||||
if ( ! empty( $this->plugin_data['PluginURI'] ) ) {
|
* Safely cast a mixed value to string.
|
||||||
$plugin_uri = $this->plugin_data['PluginURI'];
|
*
|
||||||
if ( str_contains( $plugin_uri, 'git.robotstxt.es' ) ) {
|
* @param mixed $value The value to cast.
|
||||||
return rtrim( $plugin_uri, '/' ) . '/raw/branch/main/update.json';
|
* @param string $default Fallback when value is not a string.
|
||||||
}
|
* @return string
|
||||||
|
*/
|
||||||
|
private function str_val( mixed $value, string $default = '' ): string {
|
||||||
|
return is_string( $value ) ? $value : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last resort: construct from plugin slug.
|
/**
|
||||||
return "https://git.robotstxt.es/ROBOTSTXT/{$this->plugin_slug}/raw/branch/main/update.json";
|
* Build JSON URL from plugin headers.
|
||||||
}
|
*
|
||||||
|
* Tries to use "Gitea Plugin URI" header to construct the URL.
|
||||||
|
* Falls back to Plugin URI if Gitea URI is not available.
|
||||||
|
*
|
||||||
|
* @return string JSON URL.
|
||||||
|
*/
|
||||||
|
private function build_json_url(): string {
|
||||||
|
// Try Gitea Plugin URI (format: "OWNER/REPO" or full URL).
|
||||||
|
if ( ! empty( $this->plugin_data['Gitea Plugin URI'] ) ) {
|
||||||
|
$gitea_uri = $this->plugin_data['Gitea Plugin URI'];
|
||||||
|
|
||||||
/**
|
// If it's already a full URL, use it.
|
||||||
* Inject update info into WP's plugin update transient.
|
if ( str_starts_with( $gitea_uri, 'http' ) ) {
|
||||||
*
|
// Extract base URL and construct JSON path.
|
||||||
* @param object|mixed $transient The update_plugins transient.
|
return rtrim( $gitea_uri, '/' ) . '/raw/branch/main/update.json';
|
||||||
*
|
|
||||||
* @return object The modified transient.
|
|
||||||
*/
|
|
||||||
public function inject_update_info( $transient ) {
|
|
||||||
if ( ! is_object( $transient ) ) {
|
|
||||||
$transient = new stdClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( empty( $transient->checked ) || ! is_array( $transient->checked ) ) {
|
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( empty( $transient->checked[ $this->plugin_basename ] ) ) {
|
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
$current_version = $transient->checked[ $this->plugin_basename ];
|
|
||||||
$remote = $this->get_remote_data();
|
|
||||||
|
|
||||||
if ( empty( $remote['version'] ) || empty( $remote['download_url'] ) ) {
|
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->is_compatible( $remote ) ) {
|
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( version_compare( $remote['version'], $current_version, '>' ) ) {
|
|
||||||
$update = (object) array(
|
|
||||||
'slug' => $remote['slug'] ?? $this->plugin_slug,
|
|
||||||
'plugin' => $this->plugin_basename,
|
|
||||||
'new_version' => $remote['version'],
|
|
||||||
'url' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '',
|
|
||||||
'package' => $remote['download_url'],
|
|
||||||
'tested' => $remote['tested'] ?? '',
|
|
||||||
'requires' => $remote['requires'] ?? '',
|
|
||||||
'requires_php' => $remote['requires_php'] ?? '',
|
|
||||||
);
|
|
||||||
|
|
||||||
$transient->response[ $this->plugin_basename ] = $update;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide "View details" modal content.
|
|
||||||
*
|
|
||||||
* @param false|object|array $result The result object or array.
|
|
||||||
* @param string $action The type of information being requested.
|
|
||||||
* @param object $args Plugin API arguments.
|
|
||||||
*
|
|
||||||
* @return false|object The plugin information object or false.
|
|
||||||
*/
|
|
||||||
public function provide_plugin_details( $result, string $action, object $args ) {
|
|
||||||
if ( 'plugin_information' !== $action ) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( empty( $args->slug ) || $args->slug !== $this->plugin_slug ) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$remote = $this->get_remote_data();
|
|
||||||
|
|
||||||
if ( empty( $remote['version'] ) ) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (object) array(
|
|
||||||
'name' => $remote['name'] ?? $this->plugin_data['Name'] ?? $this->plugin_slug,
|
|
||||||
'slug' => $remote['slug'] ?? $this->plugin_slug,
|
|
||||||
'version' => $remote['version'],
|
|
||||||
'author' => $remote['author'] ?? $this->plugin_data['Author'] ?? '',
|
|
||||||
'homepage' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '',
|
|
||||||
'requires' => $remote['requires'] ?? '',
|
|
||||||
'tested' => $remote['tested'] ?? '',
|
|
||||||
'requires_php' => $remote['requires_php'] ?? '',
|
|
||||||
'sections' => array(
|
|
||||||
'description' => $remote['description'] ?? $this->plugin_data['Description'] ?? '',
|
|
||||||
'changelog' => $remote['changelog'] ?? '',
|
|
||||||
),
|
|
||||||
'download_link' => $remote['download_url'] ?? '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get remote data with caching and HMAC signature verification.
|
|
||||||
*
|
|
||||||
* @return array Remote data.
|
|
||||||
*/
|
|
||||||
private function get_remote_data(): array {
|
|
||||||
$cached = get_site_transient( $this->cache_key );
|
|
||||||
|
|
||||||
// Verify HMAC signature if AUTH_SALT is defined and cache has signature.
|
|
||||||
if ( false !== $cached && defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
|
||||||
if ( is_array( $cached ) && isset( $cached['signature'], $cached['data'] ) ) {
|
|
||||||
$expected_sig = hash_hmac( 'sha256', $this->cache_key . serialize( $cached['data'] ), AUTH_SALT );
|
|
||||||
|
|
||||||
if ( hash_equals( $expected_sig, $cached['signature'] ) ) {
|
|
||||||
// Signature valid, return data.
|
|
||||||
return is_array( $cached['data'] ) ? $cached['data'] : array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signature invalid, delete corrupted cache.
|
// If it's in format "OWNER/REPO", construct full URL.
|
||||||
delete_site_transient( $this->cache_key );
|
if ( preg_match( '#^[^/]+/[^/]+$#', $gitea_uri ) ) {
|
||||||
$cached = false;
|
return "https://git.robotstxt.es/{$gitea_uri}/raw/branch/main/update.json";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: try to extract from Plugin URI.
|
||||||
|
if ( ! empty( $this->plugin_data['PluginURI'] ) ) {
|
||||||
|
$plugin_uri = $this->plugin_data['PluginURI'];
|
||||||
|
if ( str_contains( $plugin_uri, 'git.robotstxt.es' ) ) {
|
||||||
|
return rtrim( $plugin_uri, '/' ) . '/raw/branch/main/update.json';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last resort: construct from plugin slug.
|
||||||
|
return "https://git.robotstxt.es/ROBOTSTXT/{$this->plugin_slug}/raw/branch/main/update.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no valid cache, fetch fresh data.
|
/**
|
||||||
if ( false === $cached ) {
|
* Inject update info into WP's plugin update transient.
|
||||||
$remote = $this->fetch_json();
|
*
|
||||||
|
* @param object|mixed $transient The update_plugins transient.
|
||||||
|
*
|
||||||
|
* @return object The modified transient.
|
||||||
|
*/
|
||||||
|
public function inject_update_info( $transient ) {
|
||||||
|
if ( ! is_object( $transient ) ) {
|
||||||
|
$transient = new stdClass();
|
||||||
|
}
|
||||||
|
|
||||||
// Store with HMAC signature if AUTH_SALT is available.
|
if ( empty( $transient->checked ) || ! is_array( $transient->checked ) ) {
|
||||||
if ( defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
return $transient;
|
||||||
$payload = array(
|
}
|
||||||
'data' => $remote ?: array(),
|
|
||||||
'timestamp' => time(),
|
if ( empty( $transient->checked[ $this->plugin_basename ] ) ) {
|
||||||
'signature' => hash_hmac( 'sha256', $this->cache_key . serialize( $remote ?: array() ), AUTH_SALT ),
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_version = $this->str_val( $transient->checked[ $this->plugin_basename ] );
|
||||||
|
$remote = $this->get_remote_data();
|
||||||
|
|
||||||
|
if ( empty( $remote['version'] ) || empty( $remote['download_url'] ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $this->is_compatible( $remote ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
$remote_version = $this->str_val( $remote['version'] );
|
||||||
|
if ( version_compare( $remote_version, $current_version, '>' ) ) {
|
||||||
|
$update = (object) array(
|
||||||
|
'slug' => $this->str_val( $remote['slug'] ?? null, $this->plugin_slug ),
|
||||||
|
'plugin' => $this->plugin_basename,
|
||||||
|
'new_version' => $remote_version,
|
||||||
|
'url' => $this->str_val( $remote['homepage'] ?? null, $this->plugin_data['PluginURI'] ?? '' ),
|
||||||
|
'package' => $this->str_val( $remote['download_url'] ),
|
||||||
|
'tested' => $this->str_val( $remote['tested'] ?? '' ),
|
||||||
|
'requires' => $this->str_val( $remote['requires'] ?? '' ),
|
||||||
|
'requires_php' => $this->str_val( $remote['requires_php'] ?? '' ),
|
||||||
);
|
);
|
||||||
set_site_transient( $this->cache_key, $payload, 6 * HOUR_IN_SECONDS );
|
|
||||||
} else {
|
$transient_obj = $transient instanceof \stdClass ? $transient : new \stdClass();
|
||||||
// Fallback to standard caching.
|
if ( ! isset( $transient_obj->response ) || ! is_array( $transient_obj->response ) ) {
|
||||||
set_site_transient( $this->cache_key, $remote ?: array(), 6 * HOUR_IN_SECONDS );
|
$transient_obj->response = array();
|
||||||
|
}
|
||||||
|
$transient_obj->response[ $this->plugin_basename ] = $update;
|
||||||
|
return $transient_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_array( $remote ) ? $remote : array();
|
return $transient;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy cache format without signature (backward compatibility).
|
/**
|
||||||
return is_array( $cached ) ? $cached : array();
|
* Provide "View details" modal content.
|
||||||
}
|
*
|
||||||
|
* @param false|object|array<string,mixed> $result The result object or array.
|
||||||
|
* @param string $action The type of information being requested.
|
||||||
|
* @param object $args Plugin API arguments.
|
||||||
|
*
|
||||||
|
* @return false|object The plugin information object or false.
|
||||||
|
*/
|
||||||
|
public function provide_plugin_details( $result, string $action, object $args ): false|object {
|
||||||
|
if ( 'plugin_information' !== $action ) {
|
||||||
|
return is_object( $result ) ? $result : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
if ( empty( $args->slug ) || $args->slug !== $this->plugin_slug ) {
|
||||||
* Fetch JSON from remote URL.
|
return is_object( $result ) ? $result : false;
|
||||||
*
|
}
|
||||||
* @return array Decoded JSON data.
|
|
||||||
*/
|
$remote = $this->get_remote_data();
|
||||||
private function fetch_json(): array {
|
|
||||||
$response = wp_remote_get(
|
if ( empty( $remote['version'] ) ) {
|
||||||
$this->json_url,
|
return is_object( $result ) ? $result : false;
|
||||||
array(
|
}
|
||||||
'timeout' => 10,
|
|
||||||
'headers' => array(
|
return (object) array(
|
||||||
'Accept' => 'application/json',
|
'name' => $this->str_val( $remote['name'] ?? null, $this->plugin_data['Name'] ?? $this->plugin_slug ),
|
||||||
|
'slug' => $this->str_val( $remote['slug'] ?? null, $this->plugin_slug ),
|
||||||
|
'version' => $this->str_val( $remote['version'] ),
|
||||||
|
'author' => $this->str_val( $remote['author'] ?? null, $this->plugin_data['Author'] ?? '' ),
|
||||||
|
'homepage' => $this->str_val( $remote['homepage'] ?? null, $this->plugin_data['PluginURI'] ?? '' ),
|
||||||
|
'requires' => $this->str_val( $remote['requires'] ?? '' ),
|
||||||
|
'tested' => $this->str_val( $remote['tested'] ?? '' ),
|
||||||
|
'requires_php' => $this->str_val( $remote['requires_php'] ?? '' ),
|
||||||
|
'sections' => array(
|
||||||
|
'description' => $this->str_val( $remote['description'] ?? null, $this->plugin_data['Description'] ?? '' ),
|
||||||
|
'changelog' => $this->str_val( $remote['changelog'] ?? '' ),
|
||||||
),
|
),
|
||||||
)
|
'download_link' => $this->str_val( $remote['download_url'] ?? '' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( is_wp_error( $response ) ) {
|
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$code = (int) wp_remote_retrieve_response_code( $response );
|
/**
|
||||||
if ( $code < 200 || $code >= 300 ) {
|
* Get remote data with caching and HMAC signature verification.
|
||||||
return array();
|
*
|
||||||
}
|
* @return array<string, mixed> Remote data.
|
||||||
|
*/
|
||||||
|
private function get_remote_data(): array {
|
||||||
|
$cached = get_site_transient( $this->cache_key );
|
||||||
|
|
||||||
$body = wp_remote_retrieve_body( $response );
|
// Verify HMAC signature if AUTH_SALT is defined and cache has signature.
|
||||||
$data = json_decode( $body, true );
|
if ( false !== $cached && defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
||||||
|
if ( is_array( $cached ) && isset( $cached['signature'], $cached['data'] ) ) {
|
||||||
|
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- HMAC integrity verification for cached data.
|
||||||
|
$expected_sig = hash_hmac( 'sha256', $this->cache_key . serialize( $cached['data'] ), AUTH_SALT );
|
||||||
|
|
||||||
return is_array( $data ) ? $data : array();
|
if ( hash_equals( $expected_sig, $cached['signature'] ) ) {
|
||||||
}
|
// Signature valid, return data.
|
||||||
|
return is_array( $cached['data'] ) ? $cached['data'] : array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// Signature invalid, delete corrupted cache.
|
||||||
* Check compatibility.
|
delete_site_transient( $this->cache_key );
|
||||||
*
|
$cached = false;
|
||||||
* @param array $remote Remote data.
|
}
|
||||||
*
|
|
||||||
* @return bool True if compatible.
|
|
||||||
*/
|
|
||||||
private function is_compatible( array $remote ): bool {
|
|
||||||
if ( ! empty( $remote['requires_php'] ) ) {
|
|
||||||
if ( version_compare( PHP_VERSION, $remote['requires_php'], '<' ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $remote['requires'] ) ) {
|
// If no valid cache, fetch fresh data.
|
||||||
if ( version_compare( get_bloginfo( 'version' ), $remote['requires'], '<' ) ) {
|
if ( false === $cached ) {
|
||||||
return false;
|
$remote = $this->fetch_json();
|
||||||
|
|
||||||
|
// Store with HMAC signature if AUTH_SALT is available.
|
||||||
|
if ( defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
||||||
|
$payload = array(
|
||||||
|
'data' => ! empty( $remote ) ? $remote : array(),
|
||||||
|
'timestamp' => time(),
|
||||||
|
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- HMAC integrity for transient cache.
|
||||||
|
'signature' => hash_hmac( 'sha256', $this->cache_key . serialize( ! empty( $remote ) ? $remote : array() ), AUTH_SALT ),
|
||||||
|
);
|
||||||
|
set_site_transient( $this->cache_key, $payload, 6 * HOUR_IN_SECONDS );
|
||||||
|
} else {
|
||||||
|
// Fallback to standard caching.
|
||||||
|
set_site_transient( $this->cache_key, ! empty( $remote ) ? $remote : array(), 6 * HOUR_IN_SECONDS );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $remote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Legacy cache format without signature (backward compatibility).
|
||||||
|
return is_array( $cached ) ? $cached : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
/**
|
||||||
}
|
* Fetch JSON from remote URL.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed> Decoded JSON data.
|
||||||
|
*/
|
||||||
|
private function fetch_json(): array {
|
||||||
|
$response = wp_remote_get(
|
||||||
|
$this->json_url,
|
||||||
|
array(
|
||||||
|
'timeout' => 10,
|
||||||
|
'headers' => array(
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
if ( is_wp_error( $response ) ) {
|
||||||
* Handle manual cache clear via URL parameter.
|
return array();
|
||||||
*/
|
}
|
||||||
public function handle_cache_clear(): void {
|
|
||||||
// Check if this is a cache clear request first.
|
$code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
$clear_cache = filter_input( INPUT_GET, 'robotstxt_clear_update_cache', FILTER_UNSAFE_RAW );
|
if ( $code < 200 || $code >= 300 ) {
|
||||||
if ( null === $clear_cache ) {
|
return array();
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body( $response );
|
||||||
|
$data = json_decode( $body, true );
|
||||||
|
|
||||||
|
return is_array( $data ) ? $data : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a cache clear request - now verify nonce.
|
/**
|
||||||
$nonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW );
|
* Check compatibility.
|
||||||
$nonce = $nonce_raw ? sanitize_text_field( wp_unslash( $nonce_raw ) ) : '';
|
*
|
||||||
|
* @param array<string, mixed> $remote Remote data.
|
||||||
|
*
|
||||||
|
* @return bool True if compatible.
|
||||||
|
*/
|
||||||
|
private function is_compatible( array $remote ): bool {
|
||||||
|
if ( ! empty( $remote['requires_php'] ) ) {
|
||||||
|
$req_php = $this->str_val( $remote['requires_php'] );
|
||||||
|
if ( version_compare( PHP_VERSION, $req_php, '<' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! wp_verify_nonce( $nonce, 'robotstxt_clear_update_cache' ) ) {
|
if ( ! empty( $remote['requires'] ) ) {
|
||||||
wp_die( esc_html__( 'Security check failed', 'idrivee2-media-upload' ) );
|
$req_wp = $this->str_val( $remote['requires'] );
|
||||||
|
if ( version_compare( get_bloginfo( 'version' ), $req_wp, '<' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions.
|
/**
|
||||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
* Handle manual cache clear via URL parameter.
|
||||||
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'idrivee2-media-upload' ) );
|
*/
|
||||||
|
public function handle_cache_clear(): void {
|
||||||
|
// Check if this is a cache clear request first.
|
||||||
|
$clear_cache = filter_input( INPUT_GET, 'robotstxt_clear_update_cache', FILTER_UNSAFE_RAW );
|
||||||
|
if ( null === $clear_cache ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a cache clear request - now verify nonce.
|
||||||
|
$nonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW );
|
||||||
|
$nonce = $nonce_raw ? sanitize_text_field( wp_unslash( $nonce_raw ) ) : '';
|
||||||
|
|
||||||
|
if ( ! wp_verify_nonce( $nonce, 'robotstxt_clear_update_cache' ) ) {
|
||||||
|
wp_die( esc_html__( 'Security check failed', 'idrivee2-media-upload' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check permissions.
|
||||||
|
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'idrivee2-media-upload' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->clear_cache();
|
||||||
|
wp_safe_redirect( remove_query_arg( array( 'robotstxt_clear_update_cache', '_wpnonce' ) ) );
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->clear_cache();
|
/**
|
||||||
wp_safe_redirect( remove_query_arg( array( 'robotstxt_clear_update_cache', '_wpnonce' ) ) );
|
* Clear update cache.
|
||||||
exit;
|
*/
|
||||||
}
|
public function clear_cache(): void {
|
||||||
|
delete_site_transient( $this->cache_key );
|
||||||
/**
|
delete_site_transient( 'update_plugins' );
|
||||||
* Clear update cache.
|
}
|
||||||
*/
|
|
||||||
public function clear_cache(): void {
|
|
||||||
delete_site_transient( $this->cache_key );
|
|
||||||
delete_site_transient( 'update_plugins' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,9 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
/**
|
/**
|
||||||
* Clean up plugin data.
|
* Clean up plugin data.
|
||||||
*
|
*
|
||||||
* This removes all custom post meta, options, and scheduled cron events
|
* Removes: post meta (_idrivee2_s3_base_url, _idrivee2_last_upload), deletion queue,
|
||||||
* created by the plugin.
|
* and cron events. By design, idrivee2_media_settings and idrivee2_s3_operations
|
||||||
|
* are preserved (user data preservation policy per AGENTS.md).
|
||||||
*
|
*
|
||||||
* WARNING: This action cannot be undone.
|
* WARNING: This action cannot be undone.
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,9 +49,9 @@ $wpdb->query(
|
||||||
delete_option( 'idrivee2_deletion_queue' );
|
delete_option( 'idrivee2_deletion_queue' );
|
||||||
|
|
||||||
// Unschedule the cleanup cron event.
|
// Unschedule the cleanup cron event.
|
||||||
$timestamp = wp_next_scheduled( 'idrivee2_cleanup_local_files' );
|
$idrivee2_next_scheduled = wp_next_scheduled( 'idrivee2_cleanup_local_files' );
|
||||||
if ( $timestamp ) {
|
if ( $idrivee2_next_scheduled ) {
|
||||||
wp_unschedule_event( $timestamp, 'idrivee2_cleanup_local_files' );
|
wp_unschedule_event( $idrivee2_next_scheduled, 'idrivee2_cleanup_local_files' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear all hooks for this action to prevent any remaining schedules.
|
// Clear all hooks for this action to prevent any remaining schedules.
|
||||||
|
|
|
||||||
16
update.json
16
update.json
|
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "iDrivee2 Media Upload",
|
"name": "iDrivee2 Media Upload",
|
||||||
"slug": "idrivee2-media-upload",
|
"slug": "idrivee2-media-upload",
|
||||||
"version": "1.1.3",
|
"version": "1.1.4",
|
||||||
"download_url": "https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload/releases/download/1.1.3/idrivee2-media-upload-1.1.3.zip",
|
"download_url": "https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload/releases/download/1.1.4/idrivee2-media-upload-1.1.4.zip",
|
||||||
"requires": "6.8",
|
"requires": "4.1",
|
||||||
"requires_php": "8.2",
|
"requires_php": "8.1",
|
||||||
"tested": "6.9",
|
"tested": "7.1",
|
||||||
"last_updated": "2026-02-04",
|
"last_updated": "2026-06-02",
|
||||||
"author": "ROBOTSTXT",
|
"author": "ROBOTSTXT",
|
||||||
"author_profile": "https://www.robotstxt.es/",
|
"author_profile": "https://www.robotstxt.es/",
|
||||||
"homepage": "https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload",
|
"homepage": "https://git.robotstxt.es/ROBOTSTXT/idrivee2-media-upload",
|
||||||
"description": "Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging.",
|
"description": "Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging.",
|
||||||
"changelog": "<h3>1.1.3 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Critical namespace issue with Robotstxt_Updater class causing fatal error</li><li><strong>Fixed:</strong> Plugin now loads correctly without PHP fatal errors</li></ul><h3>1.1.2 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Deployment script updated to use PHP 8.2 as platform base for production builds</li><li><strong>Changed:</strong> Now uses composer update --no-dev for consistent dependency resolution</li><li><strong>Improved:</strong> Production packages guarantee PHP 8.2+ compatibility regardless of dev environment</li></ul><h3>1.1.1 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Deployment script now includes essential files (update.json, robotstxt-updater.php, readme.txt, changelog.txt)</li><li><strong>Improved:</strong> Production packages now contain all files required for automatic updates from Gitea</li></ul><h3>1.1.0 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Added explicit PHP version requirement (>=8.2) to composer.json</li><li><strong>Changed:</strong> Updated update.json with correct plugin information</li><li><strong>Changed:</strong> Fixed Text Domain in robotstxt-updater.php to match plugin slug</li><li><strong>Fixed:</strong> Composer now validates PHP version during dependency installation</li><li><strong>Fixed:</strong> Plugin update system correctly identifies the plugin</li><li><strong>Fixed:</strong> Translations properly loaded for updater error messages</li><li><strong>Improved:</strong> All text domains now consistently use 'idrivee2-media-upload'</li></ul><h3>1.0.0 - 2026-02-03</h3><ul><li><strong>Release:</strong> First stable release</li><li><strong>Feature:</strong> Automatic upload of media files to iDrivee2 (S3-compatible storage)</li><li><strong>Feature:</strong> URL rewriting to serve media from CDN</li><li><strong>Feature:</strong> Local file deletion after successful upload</li><li><strong>Feature:</strong> Admin interface with connection and upload testing</li><li><strong>Security:</strong> Enterprise-grade security with nonce validation</li><li><strong>Architecture:</strong> Class-based modular architecture with dependency injection</li><li><strong>Testing:</strong> PHPUnit test structure and PHPStan static analysis</li><li><strong>Compatibility:</strong> WordPress 6.8+ and PHP 8.2+</li></ul>",
|
"changelog": "<h3>1.1.4 - 2026-06-02</h3><ul><li><strong>Added:</strong> Full dev tooling: PHPCS, PHPStan level 9, PHPUnit test suite (22 tests)</li><li><strong>Fixed:</strong> WP_Filesystem null guard, type safety on get_option/get_transient, dynamic asset version</li><li><strong>Changed:</strong> Tested up to WordPress 7.1, PHP 8.2-8.5</li></ul><h3>1.1.3 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Critical namespace issue with Robotstxt_Updater class causing fatal error</li><li><strong>Fixed:</strong> Plugin now loads correctly without PHP fatal errors</li></ul><h3>1.1.2 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Deployment script updated to use PHP 8.2 as platform base for production builds</li><li><strong>Changed:</strong> Now uses composer update --no-dev for consistent dependency resolution</li><li><strong>Improved:</strong> Production packages guarantee PHP 8.2+ compatibility regardless of dev environment</li></ul><h3>1.1.1 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Deployment script now includes essential files (update.json, robotstxt-updater.php, readme.txt, changelog.txt)</li><li><strong>Improved:</strong> Production packages now contain all files required for automatic updates from Gitea</li></ul><h3>1.1.0 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Added explicit PHP version requirement (>=8.2) to composer.json</li><li><strong>Changed:</strong> Updated update.json with correct plugin information</li><li><strong>Changed:</strong> Fixed Text Domain in robotstxt-updater.php to match plugin slug</li><li><strong>Fixed:</strong> Composer now validates PHP version during dependency installation</li><li><strong>Fixed:</strong> Plugin update system correctly identifies the plugin</li><li><strong>Fixed:</strong> Translations properly loaded for updater error messages</li><li><strong>Improved:</strong> All text domains now consistently use 'idrivee2-media-upload'</li></ul><h3>1.0.0 - 2026-02-03</h3><ul><li><strong>Release:</strong> First stable release</li><li><strong>Feature:</strong> Automatic upload of media files to iDrivee2 (S3-compatible storage)</li><li><strong>Feature:</strong> URL rewriting to serve media from CDN</li><li><strong>Feature:</strong> Local file deletion after successful upload</li><li><strong>Feature:</strong> Admin interface with connection and upload testing</li><li><strong>Security:</strong> Enterprise-grade security with nonce validation</li><li><strong>Architecture:</strong> Class-based modular architecture with dependency injection</li><li><strong>Testing:</strong> PHPUnit test structure and PHPStan static analysis</li><li><strong>Compatibility:</strong> WordPress 6.8+ and PHP 8.2+</li></ul>",
|
||||||
"sections": {
|
"sections": {
|
||||||
"description": "Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging. The plugin intercepts WordPress media uploads, pushes files to an S3-compatible bucket, deletes local copies, and rewrites URLs to serve media from the CDN.",
|
"description": "Uploads media files to iDrivee2 (S3-compatible) with enterprise-grade security and logging. The plugin intercepts WordPress media uploads, pushes files to an S3-compatible bucket, deletes local copies, and rewrites URLs to serve media from the CDN.",
|
||||||
"changelog": "<h3>1.1.3 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Critical namespace issue with Robotstxt_Updater class causing fatal error</li><li><strong>Fixed:</strong> Plugin now loads correctly without PHP fatal errors</li></ul><h3>1.1.2 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Deployment script updated to use PHP 8.2 as platform base for production builds</li><li><strong>Changed:</strong> Now uses composer update --no-dev for consistent dependency resolution</li><li><strong>Improved:</strong> Production packages guarantee PHP 8.2+ compatibility regardless of dev environment</li></ul><h3>1.1.1 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Deployment script now includes essential files (update.json, robotstxt-updater.php, readme.txt, changelog.txt)</li><li><strong>Improved:</strong> Production packages now contain all files required for automatic updates from Gitea</li></ul><h3>1.1.0 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Added explicit PHP version requirement (>=8.2) to composer.json</li><li><strong>Changed:</strong> Updated update.json with correct plugin information</li><li><strong>Changed:</strong> Fixed Text Domain in robotstxt-updater.php to match plugin slug</li><li><strong>Fixed:</strong> Composer now validates PHP version during dependency installation</li><li><strong>Fixed:</strong> Plugin update system correctly identifies the plugin</li><li><strong>Fixed:</strong> Translations properly loaded for updater error messages</li><li><strong>Improved:</strong> All text domains now consistently use 'idrivee2-media-upload'</li></ul><h3>1.0.0 - 2026-02-03</h3><ul><li><strong>Release:</strong> First stable release</li><li><strong>Feature:</strong> Automatic upload of media files to iDrivee2 (S3-compatible storage)</li><li><strong>Feature:</strong> URL rewriting to serve media from CDN</li><li><strong>Feature:</strong> Local file deletion after successful upload</li><li><strong>Feature:</strong> Admin interface with connection and upload testing</li><li><strong>Security:</strong> Enterprise-grade security with nonce validation</li><li><strong>Architecture:</strong> Class-based modular architecture with dependency injection</li><li><strong>Testing:</strong> PHPUnit test structure and PHPStan static analysis</li><li><strong>Compatibility:</strong> WordPress 6.8+ and PHP 8.2+</li></ul>"
|
"changelog": "<h3>1.1.4 - 2026-06-02</h3><ul><li><strong>Added:</strong> Full dev tooling: PHPCS, PHPStan level 9, PHPUnit test suite (22 tests)</li><li><strong>Fixed:</strong> WP_Filesystem null guard, type safety on get_option/get_transient, dynamic asset version</li><li><strong>Changed:</strong> Tested up to WordPress 7.1, PHP 8.2-8.5</li></ul><h3>1.1.3 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Critical namespace issue with Robotstxt_Updater class causing fatal error</li><li><strong>Fixed:</strong> Plugin now loads correctly without PHP fatal errors</li></ul><h3>1.1.2 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Deployment script updated to use PHP 8.2 as platform base for production builds</li><li><strong>Changed:</strong> Now uses composer update --no-dev for consistent dependency resolution</li><li><strong>Improved:</strong> Production packages guarantee PHP 8.2+ compatibility regardless of dev environment</li></ul><h3>1.1.1 - 2026-02-04</h3><ul><li><strong>Fixed:</strong> Deployment script now includes essential files (update.json, robotstxt-updater.php, readme.txt, changelog.txt)</li><li><strong>Improved:</strong> Production packages now contain all files required for automatic updates from Gitea</li></ul><h3>1.1.0 - 2026-02-04</h3><ul><li><strong>Changed:</strong> Added explicit PHP version requirement (>=8.2) to composer.json</li><li><strong>Changed:</strong> Updated update.json with correct plugin information</li><li><strong>Changed:</strong> Fixed Text Domain in robotstxt-updater.php to match plugin slug</li><li><strong>Fixed:</strong> Composer now validates PHP version during dependency installation</li><li><strong>Fixed:</strong> Plugin update system correctly identifies the plugin</li><li><strong>Fixed:</strong> Translations properly loaded for updater error messages</li><li><strong>Improved:</strong> All text domains now consistently use 'idrivee2-media-upload'</li></ul><h3>1.0.0 - 2026-02-03</h3><ul><li><strong>Release:</strong> First stable release</li><li><strong>Feature:</strong> Automatic upload of media files to iDrivee2 (S3-compatible storage)</li><li><strong>Feature:</strong> URL rewriting to serve media from CDN</li><li><strong>Feature:</strong> Local file deletion after successful upload</li><li><strong>Feature:</strong> Admin interface with connection and upload testing</li><li><strong>Security:</strong> Enterprise-grade security with nonce validation</li><li><strong>Architecture:</strong> Class-based modular architecture with dependency injection</li><li><strong>Testing:</strong> PHPUnit test structure and PHPStan static analysis</li><li><strong>Compatibility:</strong> WordPress 6.8+ and PHP 8.2+</li></ul>"
|
||||||
},
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"low": "",
|
"low": "",
|
||||||
|
|
|
||||||
5
vendor/autoload.php
vendored
5
vendor/autoload.php
vendored
|
|
@ -14,10 +14,7 @@ if (PHP_VERSION_ID < 50600) {
|
||||||
echo $err;
|
echo $err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trigger_error(
|
throw new RuntimeException($err);
|
||||||
$err,
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
|
||||||
35
vendor/aws/aws-crt-php/composer.json
vendored
35
vendor/aws/aws-crt-php/composer.json
vendored
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"name": "aws/aws-crt-php",
|
|
||||||
"homepage": "https://github.com/awslabs/aws-crt-php",
|
|
||||||
"description": "AWS Common Runtime for PHP",
|
|
||||||
"keywords": ["aws","amazon","sdk","crt"],
|
|
||||||
"type": "library",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "AWS SDK Common Runtime Team",
|
|
||||||
"email": "aws-sdk-common-runtime@amazon.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"minimum-stability": "alpha",
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.5"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit":"^4.8.35||^5.6.3||^9.5",
|
|
||||||
"yoast/phpunit-polyfills": "^1.0"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"src/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality."
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "./dev-scripts/run_tests.sh",
|
|
||||||
"test-extension": "@test",
|
|
||||||
"test-win": ".\\dev-scripts\\run_tests.bat"
|
|
||||||
},
|
|
||||||
"license": "Apache-2.0"
|
|
||||||
}
|
|
||||||
4
vendor/aws/aws-sdk-php/CODE_OF_CONDUCT.md
vendored
Normal file
4
vendor/aws/aws-sdk-php/CODE_OF_CONDUCT.md
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
## Code of Conduct
|
||||||
|
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||||
|
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||||
|
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||||
4
vendor/aws/aws-sdk-php/CRT_INSTRUCTIONS.md
vendored
Normal file
4
vendor/aws/aws-sdk-php/CRT_INSTRUCTIONS.md
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
## Building and enabling the Common Run Time
|
||||||
|
|
||||||
|
1. **Follow instructions on crt repo** – Clone and build the repo as shown [here][https://github.com/awslabs/aws-crt-php].
|
||||||
|
1. **Enable the CRT** – add the following line to your php.ini file `extension=path/to/aws-crt-php/modules/awscrt.so`
|
||||||
73
vendor/aws/aws-sdk-php/composer.json
vendored
73
vendor/aws/aws-sdk-php/composer.json
vendored
|
|
@ -1,73 +0,0 @@
|
||||||
{
|
|
||||||
"name": "aws/aws-sdk-php",
|
|
||||||
"homepage": "http://aws.amazon.com/sdkforphp",
|
|
||||||
"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
|
|
||||||
"keywords": ["aws","amazon","sdk","s3","ec2","dynamodb","cloud","glacier"],
|
|
||||||
"type": "library",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Amazon Web Services",
|
|
||||||
"homepage": "http://aws.amazon.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"forum": "https://github.com/aws/aws-sdk-php/discussions",
|
|
||||||
"issues": "https://github.com/aws/aws-sdk-php/issues"
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=8.1",
|
|
||||||
"guzzlehttp/guzzle": "^7.4.5",
|
|
||||||
"guzzlehttp/psr7": "^2.4.5",
|
|
||||||
"guzzlehttp/promises": "^2.0",
|
|
||||||
"mtdowling/jmespath.php": "^2.8.0",
|
|
||||||
"ext-pcre": "*",
|
|
||||||
"ext-json": "*",
|
|
||||||
"ext-simplexml": "*",
|
|
||||||
"aws/aws-crt-php": "^1.2.3",
|
|
||||||
"psr/http-message": "^1.0 || ^2.0",
|
|
||||||
"symfony/filesystem": "^v5.4.45 || ^v6.4.3 || ^v7.1.0 || ^v8.0.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"composer/composer" : "^2.7.8",
|
|
||||||
"ext-openssl": "*",
|
|
||||||
"ext-dom": "*",
|
|
||||||
"ext-sockets": "*",
|
|
||||||
"phpunit/phpunit": "^9.6",
|
|
||||||
"behat/behat": "~3.0",
|
|
||||||
"doctrine/cache": "~1.4",
|
|
||||||
"aws/aws-php-sns-message-validator": "~1.0",
|
|
||||||
"andrewsville/php-token-reflection": "^1.4",
|
|
||||||
"psr/cache": "^2.0 || ^3.0",
|
|
||||||
"psr/simple-cache": "^2.0 || ^3.0",
|
|
||||||
"sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0",
|
|
||||||
"yoast/phpunit-polyfills": "^2.0",
|
|
||||||
"dms/phpunit-arraysubset-asserts": "^0.4.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
|
|
||||||
"ext-curl": "To send requests using cURL",
|
|
||||||
"ext-sockets": "To use client-side monitoring",
|
|
||||||
"ext-pcntl": "To use client-side monitoring",
|
|
||||||
"doctrine/cache": "To use the DoctrineCacheAdapter",
|
|
||||||
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Aws\\": "src/"
|
|
||||||
},
|
|
||||||
"files": ["src/functions.php"],
|
|
||||||
"exclude-from-classmap": ["src/data/"]
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"Aws\\Test\\": "tests/"
|
|
||||||
},
|
|
||||||
"classmap": ["build/"]
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.0-dev"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -21,10 +21,14 @@ use Aws\AwsClient;
|
||||||
* @method \GuzzleHttp\Promise\Promise createAnalyzerAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise createAnalyzerAsync(array $args = [])
|
||||||
* @method \Aws\Result createArchiveRule(array $args = [])
|
* @method \Aws\Result createArchiveRule(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise createArchiveRuleAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise createArchiveRuleAsync(array $args = [])
|
||||||
|
* @method \Aws\Result createServiceLinkedAnalyzer(array $args = [])
|
||||||
|
* @method \GuzzleHttp\Promise\Promise createServiceLinkedAnalyzerAsync(array $args = [])
|
||||||
* @method \Aws\Result deleteAnalyzer(array $args = [])
|
* @method \Aws\Result deleteAnalyzer(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise deleteAnalyzerAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise deleteAnalyzerAsync(array $args = [])
|
||||||
* @method \Aws\Result deleteArchiveRule(array $args = [])
|
* @method \Aws\Result deleteArchiveRule(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise deleteArchiveRuleAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise deleteArchiveRuleAsync(array $args = [])
|
||||||
|
* @method \Aws\Result deleteServiceLinkedAnalyzer(array $args = [])
|
||||||
|
* @method \GuzzleHttp\Promise\Promise deleteServiceLinkedAnalyzerAsync(array $args = [])
|
||||||
* @method \Aws\Result generateFindingRecommendation(array $args = [])
|
* @method \Aws\Result generateFindingRecommendation(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise generateFindingRecommendationAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise generateFindingRecommendationAsync(array $args = [])
|
||||||
* @method \Aws\Result getAccessPreview(array $args = [])
|
* @method \Aws\Result getAccessPreview(array $args = [])
|
||||||
|
|
|
||||||
2
vendor/aws/aws-sdk-php/src/Acm/AcmClient.php
vendored
2
vendor/aws/aws-sdk-php/src/Acm/AcmClient.php
vendored
|
|
@ -36,6 +36,8 @@ use Aws\AwsClient;
|
||||||
* @method \GuzzleHttp\Promise\Promise resendValidationEmailAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise resendValidationEmailAsync(array $args = [])
|
||||||
* @method \Aws\Result revokeCertificate(array $args = [])
|
* @method \Aws\Result revokeCertificate(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise revokeCertificateAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise revokeCertificateAsync(array $args = [])
|
||||||
|
* @method \Aws\Result searchCertificates(array $args = [])
|
||||||
|
* @method \GuzzleHttp\Promise\Promise searchCertificatesAsync(array $args = [])
|
||||||
* @method \Aws\Result updateCertificateOptions(array $args = [])
|
* @method \Aws\Result updateCertificateOptions(array $args = [])
|
||||||
* @method \GuzzleHttp\Promise\Promise updateCertificateOptionsAsync(array $args = [])
|
* @method \GuzzleHttp\Promise\Promise updateCertificateOptionsAsync(array $args = [])
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue