Hot answers tagged errors
7
Survey said! Wolf Fence in Alaska.
The basic idea is that you divide your problem space in half by inserting a print "Hi, Mom!\n"; exit; (insert your favorite phrase) somewhere near the "middle" of your code. If you get the message, then the bug is beyond where you put the print, so move it farther along in the execution. If you don't get there, move the ...
7
Assign return of the function to the variable.
Check the variable with is_wp_error().
If true handle accordingly, for example trigger_error() with message from WP_Error->get_error_message() method.
If false - proceed as usual.
Example from Codex:
function doer_of_stuff() {
return new WP_Error('broke', __("I've fallen and can't get up"));
}
$return ...
7
http://yoast.com/custom-wordpress-database-error-pages/
You can make your own Database Error page by adding a db-error.php to your wp-content folder (/wp-content/db-error.php). You can find a good example of such a page in the link above. Don't forget adding header("HTTP/1.0 500 Internal Server Error"); in that file so it get a proper header message.
7
Do not just upgrade immediately. Take the time you need for an informed decision. And make a backup, of course. :)
Read the changelog for the new version. Example for 3.4.1. The blog announcements and the Codex pages are not complete.
Test the upgrade with an exact copy of your production site, including plugins and themes.
Add, change and delete an ...
6
I'm assuming that you put WordPress in your site root and the external directories are also in your site root. The reason this is happening is that .htaccess files follow a hierarchy. Whatever directives are in the top-level .htaccess file flow down and apply to all directories below it.
If this is the case, you can do one of several things:
Move your ...
6
First do not use 777, change it back to 755.
Second you need to add the proper group permissions most likely to the same that Apache is running under.
To find that out try:
ps aux | grep apache
You will see the Apache user group on the left.
Now change your WordPress folder to the same user group, you can do this in a parent folder or sub folder ...
6
There are several components to error/notice creation and display process:
add_settings_error() call to add item to stack (global $wp_settings_errors variable).
settings_errors transient that keeps the errors so they survive move from page to page.
settings_errors() function get_settings_errors() to retrieve errors from memory or transient and then ...
6
Let’s start with the output we got before the fix:
What happened here? My guess: a collision between the plugin W3 Total Cache and your web server LiteSpeed. I found a thread in a Drupal forum about a very similar (or the same) issue.
LiteSpeed seems not to send the appropriate HTTP headers for the compressed cache files W3TC stores. In its changelog for ...
5
I suggest to use sessions since this will not create strange effects when two users editing at the same time. So this is what I do:
Sessions are not started by wordpress. So you need to start a session in your plugin, functions.php or even wp-config.php:
if (!session_id())
session_start();
When saving the post, append errors and notices to the ...
5
There are multiple tools and possibilities, and shure it would be nice to have something quick at hand. I know plugin authors who do offer debug flags so you can analyze what's going on quite easy.
As for plugins, I have not tested it but looked at some screenshots and it is at least informative: Debug Bar (Wordpress Plugin) and the BlackBox Debug Bar ...
5
Because widget_name::__construct() calls WP_Widget::WP_Widget(), which in turn calls widget_name::__construct() etc.
A simple solution would be to make widget_name::__construct() call WP_Widget::__construct() directly.
Also see http://core.trac.wordpress.org/ticket/16768#comment:9
5
I would recommend running the following code right after your query to see what's happening:
exit( var_dump( $wpdb->last_query ) );
This should print the last query that hit your database. In cases like these, I usually will manually run such a query through phpMyAdmin to see if it runs without errors and to see if it even affects the database. ...
5
It's a common PHP error, usually when you try to access an array member with a non-existent key;
$array = array( 'hello' => 'world' );
echo $array['foobar']; // undefined index
You should check for the key first with isset( $array['foobar'] );
UPDATE: In this case, I would chuck in a loop that sets-up the variables for you, checking for the index in ...
5
You're probably talking about theming wp_die(), which is the function that produces those grey error pages with a white box of text in them.
For a plugin solution, you could try this plugin, which says it does what you want. Not sure about version support though--it says it only works up to 3.1.4.
For a programatic solution, you'll want to hook into the ...
5
There's not one if you didn't set one up. The codex has a good example of how to do this.
<?php
@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/home/example.com/logs/php_error.log');
/**
* This will log all errors notices and warnings to a file called debug.log in
* wp-content (if Apache does not have write ...
5
Remove the call to $wpdb->prepare():
$result = $wpdb->get_var(
"SELECT DISTINCT meta_value FROM $metatable
WHERE meta_key LIKE '%matchme%'
AND meta_value IS NOT NULL
AND meta_value <> ''"
);
In this case, the $wpdb->prepare() function is not doing anything. There are no variables holding unknown values, therefore there is no ...
4
The only way to debug this is to disable one plugin at a time, each time trying to reproduce the problem before you disable another plugin. Start with the plugins that have anything to do with the administration of WP, then move down to regular theme plugins, widgets and such.
Inspect the "Not Found" page that you are served better (browse with Opera and ...
4
Try this code:
WARNING: THIS IS JUST PSEUDOCODE!
$entries = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type IN ('post', 'page')");
foreach($entries as $entry)
{
$post_id = $entry->ID;
$comment_count = $wpdb->get_var("SELECT COUNT(*) AS comment_cnt FROM wp_comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
...
4
Ok, I think I have an idea what is going on.
The list of notices to display is retrieved by get_settings_errors() ( source ).
This function reads notices from global $wp_settings_errors unless there is settings_errors transient set, which trumps global var.
When settings are saved there is check for no setting errors and if so Settings saved. notice is ...
4
Hei,
first, you check weather your result is a WP_Error object or not:
$id = wp_insert_post(...);
if (is_wp_error($id)) {
$errors = $id->get_error_messages();
foreach ($errors as $error) {
echo $error; //this is just an example and generally not a good idea, you should implement means of processing the errors further down the track and ...
4
The amount of memory that is allocated to PHP is insufficient.
Add this to your wp-config.php file:
define('WP_MEMORY_LIMIT', '64M');
If that doesn't work, the chances are your host has this locked down and you can't change it, in which case you either need to simplify your site, or move hosts.
4
it sounds like even though its a fresh install of WP 3.1.2 that you are also using an existing theme that is using a deprecated function (you havent said so but im presuming),
if so paste this into your themes functions.php file (if your theme doesnt have one just create one and save it in your themes root folder)..
...
4
A zero response means zero rows affected, which is different from an error.
Its hard to say without looking at your query why no rows are being updated. One debug tool you can try is setting "SAVEQUERIES" to true in your wp-config.php file.
Then after your query runs, try var_dumping $wpdb->queries.
4
Show errors:
$wpdb->show_errors = true shows errors automatically, if WP_DEBUG is set to true.
$wpdb->suppress_errors = false stops suppressing errors.
Multisite need special treatment
// Show errors in Multisite:
global $wpdb, $blog_id;
// There's no is_multisite(), so we need to check the ID
// This means, that we can't debug the blog with the ID ...
4
Displaying PHP errors isn't really a WordPress thing, it is more of a PHP thing directly. No, I don't think you are crazy for wanting this, I had a similar need for a separate application and I wrote this blog post which should be helpful: http://bit.ly/uW8erf
Essentially, define your own error handler.
4
You are already calling isset() each time you are printing the data to the screen.
Why not just skip this part:
if (isset($custom)) {
$genus = $custom["genus"][0];
$species = $custom["species"][0];
$etymology = $custom["etymology"][0];
$family = $custom["family"][0];
$common_names = $custom["common_names"][0];
}
and do this when you ...
4
you can do that using login_errors filter hook and here is how:
add_filter('login_errors','login_error_message');
function login_error_message($error){
//check if that's the error you are looking for
$pos = strpos($error, 'incorrect');
if (is_int($pos)) {
//its the right error so you can overwrite it
$error = "Wrong ...
4
A white screen of death is typically a fatal PHP error, most of the time due to a syntax error. This often sends no errors to the browser.
Some things you can do:
Turn on PHP error_log in your php.ini file and set the error_reporting levels.
http://php.net/manual/en/errorfunc.configuration.php
Error info: ...
4
Is it your host?
Test if cURL is installed. If not: Go and talk to your host.
Here you got a small plugin. Drop it in your MU-Plugins folder and reload any page, or drop it into your plugins folder, activate it and then reload the page.
/* Plugin Name: _CHECK IF cURL INSTALLED */
function wpse61626_can_I_haz_cURL()
{
if ( ! in_array ( 'curl', ...
4
I don’t know how to move the notices to the bottom or if that’s possible at all. To disable the debug mode in wp-admin write in wp-config.php:
define( 'WP_DEBUG', FALSE === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) );
Untested:
You could try to enable warnings in admin with:
// happens early in wp-admin/admin.php
add_filter( ...
Only top voted, non community-wiki answers of a minimum length are eligible
