You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WordPress Ghost Exporter plugin (v1.6.0) throws a fatal error during activation when upgrading or reactivating the plugin on sites that have previously used it for exports. The error occurs in the deleteLocalExportFiles() method due to an incorrect implementation of array_slice() when cleaning up old export files in the /wp-content/uploads/ghost-exports directory.
Error Message
PHPFatal error: UncaughtArgumentCountError: array_slice() expects at least 2 arguments, 1 given in /wp-content/plugins/ghost/class-ghost.php:169
$filesInDir = scandir($gfiledir);
$slicesFilesInDir = array_slice($filesInDir, 2); // Added offset to skip . and .. directories
Steps to Reproduce
Have previously used the Ghost exporter plugin (creates /wp-content/uploads/ghost-exports directory)
Deactivate the plugin
Install/Update to Ghost WordPress Exporter v1.6.0
Attempt to activate the plugin
Plugin fails to activate with the above fatal error
Note: The error only occurs when the /wp-content/uploads/ghost-exports directory exists from previous exports. This is because the deleteLocalExportFiles() method runs during plugin activation to clean up old export files.
Workaround
Until this is fixed, users can either:
Manually delete the /wp-content/uploads/ghost-exports directory before activating
Or modify the deleteLocalExportFiles() method in class-ghost.php as shown in the fix above
Environment
WordPress: Latest version
PHP: 8.x
Plugin: Ghost Exporter Plugin v1.6.0
Impact
The bug prevents plugin activation, making it unusable without manual code modification.
Additional Context
The fix adds the offset parameter (2) to array_slice() to properly skip the "." and ".." directory entries that scandir() returns. I've implemented this fix locally and confirmed it resolves the issue.
The text was updated successfully, but these errors were encountered:
Bug Description
The WordPress Ghost Exporter plugin (v1.6.0) throws a fatal error during activation when upgrading or reactivating the plugin on sites that have previously used it for exports. The error occurs in the
deleteLocalExportFiles()
method due to an incorrect implementation ofarray_slice()
when cleaning up old export files in the/wp-content/uploads/ghost-exports
directory.Error Message
Current Implementation (Bug)
Fixed Implementation
Steps to Reproduce
Note: The error only occurs when the
/wp-content/uploads/ghost-exports
directory exists from previous exports. This is because thedeleteLocalExportFiles()
method runs during plugin activation to clean up old export files.Workaround
Until this is fixed, users can either:
/wp-content/uploads/ghost-exports
directory before activatingdeleteLocalExportFiles()
method inclass-ghost.php
as shown in the fix aboveEnvironment
Impact
The bug prevents plugin activation, making it unusable without manual code modification.
Additional Context
The fix adds the offset parameter (2) to
array_slice()
to properly skip the "." and ".." directory entries thatscandir()
returns. I've implemented this fix locally and confirmed it resolves the issue.The text was updated successfully, but these errors were encountered: