moving Drupal 6 site - get blank white page - drupal

I moved Drupal from one Linux server to another by copying files to PC then back to new server. I made changes to settings.php to reflect new database name. I got PHPmyADMIN working, so I know database and server are running.
When I run index.php, I get white screen. However in index.php when I echo out menu_execute_active_handler(), I get some part of my home page without menus. I think that this means that I am getting through bootstrap but failing somewhere else. Any ideas?
index.php
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler();
echo $return ;

Turn display_errors on in your php.ini file.
Your new server probably has them disabled.

Put this code in your index.php to see the error
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

Related

Get WordPress plugin directory URI

I want to include a WooCommerce file while running a plugin. Here is the code I am using,
include_once(include( content_url() .'/plugins/woocommerce/includes/wc-core-functions.php'));
This gives me below error,
include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /nas/content/staging/squatwolf/wp-content/plugins/wpfront-notification-bar/classes/class-wpfront-notification-bar.php on line 58
I understand its being caused because the content_url function is giving complete url instead of relative url. I also tried,
plugin_dir_url(__FILE__)
but it gives the url of the plugin I am in, not the wordpress plugin directory url.
you want like this : /home/user/var/www/wordpress/wp-content/plugins/?
try $dir = plugin_dir_path( __DIR__ );

Debug logs at wordpress not working

I would like to enable debug logs of wordpress site, added following setting at wp-config.php
/* WordPress debug mode for developers. */
define('WP_DEBUG', true);
if (WP_DEBUG) {
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
#ini_set('display_errors', 0);
}
created debug.log file under wp-content folder.
updated 777 on wp-content as well as debug.log..
But still file is blank..
Please let me know how can I fix it...
Just I would like to debug the site, some times home page going in infinite loop..i.e. browser not loading the page.. CPU goes to 100%...
Thanks
You have #ini_set('display_errors', 0); - which will tell PHP (not WordPress) to stop displaying errors. WordPress requires errors to be turned on in order for it to pass them to the appropriate place. define('WP_DEBUG_DISPLAY', false); or define('WP_DEBUG', false); should take care of hiding them on the front end for you.
Also, you should only need to define the constants, the IF statement you've created isn't necessary. What you're essentially saying there is "Turn on error reporting. Now, if error reporting is turned on, do this." - although logically correct, it's verbose. Simply defining the WP_DEBUG constant as true should be enough, as WordPress will do the rest of the work.
Also - if wp_debug.log doesn't exist- WordPress will create it for you (with the correct permissions), assuming it has permission to do so on your server (in most cases this will be true). So - you shouldn't need to change the CHMOD values of wp-content or it's children. I'd advise you to change them to WordPress' recommended values (755 for folders, and 644 for files) - as a CHMOD value of 777 is pretty foolhardy to have.
You should only need the following:
define('WP_DEBUG', true); // Turn on WP Debugging
define('WP_DEBUG_LOG', true); // Log errors to wp_debug.log
define('WP_DEBUG_DISPLAY', false); // Turns off error reporting on the front end
According to Debugging in Wordpress:
You must insert this BEFORE /* That's all, stop editing! Happy
blogging. */ in the wp-config.php file
In your case "this" is:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
It may also be worth checking the WP_CONTENT_DIR as that is where the debug.log file would be put. The value of WP_CONTENT_DIR may be checked as suggested in this question, or using the Wordfence plugin->Tools->Diagnostics->WordPress Settings.
Normally it is not explicitly set unless there's a non-standard setup. Though it can can be set in wp-config.php e.g. define('WP_CONTENT_DIR', '/var/www/sites/wordpress/wp-content');

Unable to access analytics.txt once uploaded, returns 404

I've been asked to add an analytics.txt file to a wordpress website so I've created the file and uploaded it to the server document root but when I go to it via the url www.examples.com/analytics.txt all I get is a 404 error.
I've checked the file permissions and I've cleared the wordpress cache but neither have helped.
Any ideas?
The folder structure is as follows:
wp-admin
wp-content
wp-includes
analytics.txt <-- added this file, but cannot seem to access it via a web browser
index.php
etc...
This is NOT the solution but it is a work-around while I carry on trying to figure out why wordpress won't allow me to access my file.
So if you're desperate and HAVE to get it sorted right now, here is what you could do, but I warn you, it's ugly! Open your index.php file and you should see something like this:
<?php
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
?>
Make a backup copy first and then add the wrapping if statement:
<?php
if ($_SERVER[REQUEST_URI] == '/analytics.txt') {
die('Put the text that you were instructed to put into your analytics.txt file in here');
} else {
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
}
?>
Like I said, this is a dirty solution but when needs must and the client is getting impatient, this could help in the mean time.
Hoping that someone will have a better solution though!
I was able to get this to work with the following for the Sage theme:
Upload the analytics.txt through the theme administration panel
Copy the url of the upload and remove the hostname. For me it looked like this: app/uploads/2018/09/analytics.txt
Open the functions.php file and add the following:
function analytics_txt_rewrite(){
add_rewrite_rule('^analytics\.txt$','<route to your analytics.txt file>','top');
}
add_action('init','analytics_txt_rewrite');
Flush and regenerate the rewrite rules database: From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.

How should I protect a static Wordpress file directory from the outside world?

I'm taking over the admin of a WP site that serves static docs from a dedicated directory. The current directory resides on the top level (/public_html/docs) which seems susceptible to snooping. The site sits behind a login firewall.
The file directory contains >500 individual files, so uploading and hand-editing individual links seems absurd. (At least to me.)
Should I move this directory to a more secure location within the WP directory? Or, what is the preferred way to configure .htaccess?
At a minimum I would disable Directory Listing by using an .htaccess file that sits inside your /public_html/docs directory.
IndexIgnore *
Possibly a more secure method would be to move the docs directory outside your public_html directory. Then use a PHP script that can serve your document by passing a variable, such as www.site.com/serve_doc.php?name=xxxx.pdf.
Here is some code to accomplish this:
// get the file name
$file = $_GET['name'];
$dir = "/home/xxxx/docs/";
$fp = fopen($dir.$file, 'rb');
if(!$fp) { exit; }
// open the file
$finfo = finfo_open();
$filetype = finfo_file($finfo, $file, FILEINFO_MIME);
finfo_close($finfo);
$filename = $file;
// send the right headers
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
header("Content-Type: " .$filetype );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Length: " . filesize($dir.$file));
// dump the file and stop the script
fpassthru($fp);
exit();
Of course you'll want to add some authentication to validate whether the user should be able to call this PHP script. One possible way would be to call the Wordpress function is_user_logged_in in that script before serving the file.

WP Super Cache caching broken

I am having an ambiguous error. The path in the error is correct:
Warning! WP Super Cache caching broken! The script advanced-cache.php
could not load wp-cache-phase1.php.
Please edit /wp-content/advanced-cache.php
and make sure the path to
/wp-content/plugins/wp-super-cache/wp-cache-phase1.php
is correct.
What needs to be fixed?
The problem is that the constant is not defined until after the plugin loads. This error is possible if the line "require_once(ABSPATH . 'wp-settings.php');" is present in wp-config.php . WPCACHEHOME is probably being defined after this line, but needs to be defined above it:
define( 'WPCACHEHOME', '<site root>/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
require_once(ABSPATH . 'wp-settings.php');
http://wangweiqiang.net/warning-wp-super-cache-caching-broken-the-script-advanced-cache-php-could-not-load-wp-cache-phase1-php/
This worked like a charm for me...!
This is a permission issue, U should check that the paths mantioned in the error notice have 777 permisions, BUT, my advice on this issue is simply to NOT use this plugin, I had it installed on some of my site, and almost in all of them it caused errors on diffrent elements on my site.
I'm not saying that using this plugin will cause problems for sure, but this plugin is known as problematic, and for my opinion it doesn't justify itself.
Please use this in your wp-config.php file
define('WPCACHEHOME', dirname(__FILE__) . '/wp-content/plugins/wp-super-cache/');
before
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

Resources