WP Debugging Not Working
January 28, 2025 · AI Conversations
—
### 1. **Check Debug Settings**
Ensure the following lines are correctly added to your `wp-config.php` file (before the line `/* That's all, stop editing! Happy blogging. */`):
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
@ini_set('display_errors', 1);
– **WP_DEBUG**: Enables debugging mode.
– **WP_DEBUG_LOG**: Logs errors to a file (`wp-content/debug.log`).
– **WP_DEBUG_DISPLAY**: Displays errors on the screen.
– **@ini_set('display_errors', 1)**: Ensures PHP error display is enabled.
—
### 2. **Check PHP Error Reporting**
If PHP error reporting is disabled on the server, WordPress cannot display errors. To ensure it's enabled, add the following to your `wp-config.php`:
error_reporting(E_ALL);
ini_set('display_errors', 1);
—
### 3. **File Permissions**
Ensure the `wp-content` folder and the `debug.log` file (if it exists) have the correct write permissions. For Linux servers:
chmod 775 wp-content
chmod 664 wp-content/debug.log
—
### 4. **Check Server Error Logging**
Your server configuration might be overriding WordPress settings. Check your server's `php.ini` file or `.htaccess` file for conflicting directives:
– In `php.ini`:
display_errors = On
log_errors = On
error_reporting = E_ALL
– In `.htaccess`:
Make sure there are no rules disabling error display.
—
### 5. **Check If Errors Exist**
If there are no PHP or WordPress errors, the debug mode won't output anything. Try introducing a simple error to confirm debugging works, like a syntax error in your theme or plugin:
// Add this temporarily to functions.php or a plugin file
echo $undefined_variable;
—
### 6. **Caching**
Caching plugins (e.g., WP Super Cache, W3 Total Cache) or server-side caching (e.g., Cloudflare, NGINX) might prevent error messages from displaying. Disable caching temporarily while debugging.
—
### 7. **Debug File Location**
Errors might not display on the screen but could still be logged in `wp-content/debug.log`. Check this file for error logs.
—
### 8. **Server Logs**
If you're still not seeing errors, check your server's PHP error log (e.g., `/var/log/apache2/error.log` or `/var/log/nginx/error.log`).
—
If none of the above resolves the issue, let me know about your hosting environment (e.g., Apache, NGINX, or specific WordPress hosting platform) for more tailored assistance.
Here's how you can address this issue:
—
### 1. **Temporary Fix**
You can modify the code in the plugin to handle this edge case.
#### File Path:
`/home/autohaus/public_html/wp-content/plugins/revslider/includes/functions.class.php`
#### Fix:
Locate **line 387** in the file. It likely looks like this:
if (strrpos($fileName, '.', -1) !== false) {
Change it to:
if (!empty($fileName) && strrpos($fileName, '.', -1) !== false) {
This ensures that `strrpos()` is only called if `$fileName` is not an empty string.
—
### 2. **Permanent Fix (Plugin Update)**
Check if an update is available for the Revolution Slider plugin. Plugin developers often release patches to fix such issues.
– Go to **Plugins > Installed Plugins** in WordPress.
– Locate **Revolution Slider** and check for an available update.
– If an update is available, update the plugin and recheck the issue.
—
### 3. **Debug the Input**
The root cause might be that the `$fileName` variable is not being set correctly. This can happen if an image file is missing or a configuration issue exists.
#### Steps:
1. **Log the `$fileName` Value**:
Modify the code to log the value of `$fileName` for debugging:
error_log('$fileName: ' . var_export($fileName, true));
2. Check the PHP error logs for the output.
2. **Ensure Required Images Exist**:
Verify that all the media files used in the slider are present in the WordPress media library and are not missing.
—
### 4. **Rollback the Plugin**
If updating the plugin is not an option or the issue persists after the update, consider rolling back to a previous version of the plugin where the issue doesn't exist.
– Use a plugin like **WP Rollback** to downgrade Revolution Slider to a previous version.
—
### 5. **Disable the Plugin**
If you're unable to fix or update the plugin immediately, you can temporarily disable it to regain access to your WordPress admin.
#### Steps:
1. Access your site via FTP or your hosting file manager.
2. Navigate to `/wp-content/plugins/`.
3. Rename the `revslider` folder to something like `revslider-disabled`.
This will deactivate the plugin, allowing you to access your WordPress dashboard.
—
### 6. **Contact Support**
If you have a valid license for Revolution Slider, you can contact their support team for assistance. Provide them with the error details and the steps to reproduce the issue.
—
### Long-Term Solution
Ensure all plugins are kept up-to-date, and periodically audit your site for unused or outdated plugins to prevent such issues in the future. Let me know if you need help implementing any of these fixes!
$pos = strrpos($url, '.', -1);
if($pos === false) return false;
$ext = strtolower(substr($url, $pos));
$img_exts = array('.gif', '.jpg', '.jpeg', '.png');
if(in_array($ext, $img_exts)) return $url;
return false;
}
Here’s a safer implementation of your function:
### Fixed Function
public function check_valid_image($url) {
// Check if $url is not empty
if (empty($url)) {
return false;
}
// Find the position of the last '.' in the URL
$pos = strrpos($url, '.');
if ($pos === false) {
return false;
}
// Get the file extension and convert to lowercase
$ext = strtolower(substr($url, $pos));
// Define allowed image extensions
$img_exts = array('.gif', '.jpg', '.jpeg', '.png');
// Check if the extension is valid
if (in_array($ext, $img_exts)) {
return $url;
}
return false;
}
—
### Explanation of Changes
1. **Validate `$url`:**
– Added `if (empty($url))` to ensure that the `$url` variable is not empty before calling `strrpos()`.
2. **Remove the Third Argument of `strrpos()`:**
– The `-1` offset is unnecessary because `strrpos()` starts searching from the end of the string by default. Omitting this makes the function safer.
3. **Use `strtolower()` for Case Insensitivity:**
– Use `strtolower()` to ensure the extension is checked in a case-insensitive manner.
4. **Maintain Readability:**
– The function is now clean, readable, and handles edge cases gracefully.
—
### Example Usage
// Valid image URL
echo $this->check_valid_image('https://example.com/image.jpg'); // Outputs: https://example.com/image.jpg
// Invalid image URL
echo $this->check_valid_image('https://example.com/file.txt'); // Outputs: false
// Empty URL
echo $this->check_valid_image(''); // Outputs: false
—
### Why This Fix Works
By checking if `$url` is empty and removing the unnecessary third argument (`-1`) from `strrpos()`, this implementation avoids the fatal error and handles edge cases like missing file extensions or invalid input properly.
Let me know if you encounter any other issues!