Title: davidedw's Replies | WordPress.org

---

# davidedw

  [  ](https://wordpress.org/support/users/davidedw/)

 *   [Profile](https://wordpress.org/support/users/davidedw/)
 *   [Topics Started](https://wordpress.org/support/users/davidedw/topics/)
 *   [Replies Created](https://wordpress.org/support/users/davidedw/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/davidedw/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/davidedw/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/davidedw/engagements/)
 *   [Favorites](https://wordpress.org/support/users/davidedw/favorites/)

 Search replies:

## Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Debugging help for widgetized theme](https://wordpress.org/support/topic/debugging-help-for-widgetized-theme/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/debugging-help-for-widgetized-theme/#post-1181375)
 * I have found and resolved the problem. See the post [“Spurious $GLOBALS name attribute caused 404 with widgetized theme”](http://wordpress.org/support/topic/302894).
   You might also want to look at another post of mine [“Understanding WordPress Flow – from URL to page”](http://wordpress.org/support/topic/302141).
 * In the end I used a fairly standard debugging approach:
    1. Identify what has changed (in this case the changes were well known, listed 
       above),
    2. Compare the behaviour between the (old) working theme and the (new) broken theme,
       and
    3. Trace through the code using statements/variables written to the PHP log to 
       determine where the point of change was between the working and broken theme
       behaviour.
 * If you’re familiar with the Kepner-Tregoe method, any changed behaviour must 
   be linked to changes in the environment. This was certainly the case here; I 
   knew I’d introduced the new functions.php file and some custom sidebars as well
   as changing the template files.
 * I was able to see that the query being sent to the DB to build the page involved
   the following variables:
 *     ```
       URI: //test_blog/testing-page-category/page/2
       query_string: paged=2&name=Search%20Sidebar&pagename=testing-page-category
       request:  SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'search-sidebar' AND wp_posts.post_type = 'post'  ORDER BY wp_posts.post_date DESC
       ```
   
 * The corresponding variables for the working theme were:
 *     ```
       URI: //test_blog/testing-page-category/page/2
       query_string: paged=2&pagename=testing-page-category
       request:  SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND (wp_posts.ID = '264') AND wp_posts.post_type = 'page'  ORDER BY wp_posts.post_date DESC
       ```
   
 * Obviously the request coming in from the HTTP server and passed in from the PHP
   processor (the URI) was correct, but between there and building the DB SQL statement
   something was screwed up.
 * So debugging was a matter of determining where in the code the behaviour changed.
   I used the error_log() function to write statements/arguments to the PHP error
   log. For example:
 *     ```
       $dae_error = ">>>> 9a. Name: " . $name . " global name: " . $GLOBALS['name'];
       error_log($dae_error, 0);
       ```
   
 * I then traced back up the code flow from the wrong SQL statement, placing error_log()
   statements to find the point of change.
 * The problem was a global variable somehow being set in my custom functions.php
   file (see [“Spurious $GLOBALS name attribute caused 404 with widgetized theme”](http://wordpress.org/support/topic/302894)).
 * This was a very slow process, and I’m sure the developers have a more efficient
   mechanism. But it did give me a good understanding of how WordPress is built.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Understanding WordPress Flow – from URL to page](https://wordpress.org/support/topic/understanding-wordpress-flow-from-url-to-page/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/understanding-wordpress-flow-from-url-to-page/#post-1182692)
 * I’ve had some success with answering these questions, through good old fashioned
   tracing (use of the error_log() function at strategic points of the code) and
   a Codex article [“Query Overview”](http://codex.wordpress.org/Query_Overview).
 * In response to my questions above:
    **First** – I can’t find where it’s unset,
   but the loop of wp-load.php, wp() and template-loader.php is run every time a
   URL is entered.
 * **Second** – The query is processed in the parse_request() function in classes.
   php. The various parts of the URL and/or query string are split up and placed
   in the various wp_query attributes.
 * **Finally** – it seems all paths are followed. I’m assuming that not every file
   is read from disk each time, but the same code paths are followed on each URL.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] How to add a new template file](https://wordpress.org/support/topic/plugin-now-reading-reloaded-how-to-add-a-new-template-file/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-how-to-add-a-new-template-file/#post-1171563)
 * I figured it out. The Now Reading (Reloaded) functions require a URL string of
   something like; blog/index.php?now_reading_<blahtype>=<blahvalue>. Where blahtype
   is something like library, tag, author etc. and blahvalue relates to the type(
   e.g now_reading_library=1, now_reading_tag=Doctor).
 * So to add a new template file you need to extend everything that plays with the
   URL and query strings…. For example, I decided to add a “now_reading_page=favourites.
   php” so I could add multiple pages with one set of plugin changes.
 * The files I had to modify were:
    1. **url.php**: this module processes the URL’s
   that use the mod_rewrite function. I had to modify the 1a. the _nr\_query\_vars_
   function to add a new variable (now_reading_page)…
 *     ```
       function nr_query_vars( $vars ) {
           $vars[] = 'now_reading_library';
           $vars[] = 'now_reading_id';
           $vars[] = 'now_reading_tag';
           $vars[] = 'now_reading_page';
           $vars[] = 'now_reading_search';
           $vars[] = 'now_reading_title';
           $vars[] = 'now_reading_author';
           $vars[] = 'now_reading_reader'; //in order to filter books by reader
           return $vars;
       }
       ```
   
 * 1b. the _nr\_mod\_rewrite_ function to add a new mod_rewrite rule for URL’s of
   the format library/page/favourites.php…
 *     ```
       function nr_mod_rewrite( $rules ) {
           $options = get_option('nowReadingOptions');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . '([0-9]+)/?$', 'index.php?now_reading_id=$matches[1]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . 'tag/([^/]+)/?$', 'index.php?now_reading_tag=$matches[1]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . 'page/([^/]+)/?$', 'index.php?now_reading_page=$matches[1]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . 'search/?$', 'index.php?now_reading_search=true', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . 'reader/([^/]+)/?$', 'index.php?now_reading_library=1&now_reading_reader=$matches[1]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . '([^/]+)/([^/]+)/?$', 'index.php?now_reading_author=$matches[1]&now_reading_title=$matches[2]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . '([^/]+)/?$', 'index.php?now_reading_author=$matches[1]', 'top');
           add_rewrite_rule(preg_quote($options['permalinkBase']) . '?$', 'index.php?now_reading_library=1', 'top');
       }
       ```
   
 * 1c. The _is\_now\_reading\_page_ function to make the new query string register
   as a now_reading page…
 *     ```
       function is_now_reading_page() {
           global $wp;
           $wp->parse_request();
   
           return (
           get_query_var('now_reading_library') ||
               get_query_var('now_reading_search')  ||
               get_query_var('now_reading_id')      ||
               get_query_var('now_reading_tag')     ||
               get_query_var('now_reading_page')    ||
               get_query_var('now_reading_title')   ||
               get_query_var('now_reading_author')
           );
       }
       ```
   
 * 2. **now-reading.php**: the main file in the _library\_init()_ function to add
   a new check:
 *     ```
       if ( get_query_var('now_reading_page') ) {
           // get page name from query string:
               $nrr_page = get_query_var('now_reading_page');
   
               $load = nr_load_template($nrr_page);
               if ( is_wp_error($load) )
                   echo $load->get_error_message();
   
               die;
           }
       ```
   
 * 3. I also had to create a new function in **template-functions.php** to return
   either a normal or mod_rewrite URL…
 *     ```
       /**
        * Returns a URL to the permalink for a given (custom) page.
        * @param string $page Page name (e.g. custom.php) to create URL for.
        * @param bool $echo Whether or not to echo the results.
        */
       function library_page_url( $page, $echo = true ) {
           $options = get_option('nowReadingOptions');
   
           if ( $options['useModRewrite'] )
               $url = get_option('home') . "/" . preg_replace("/^\/|\/+$/", "", $options['permalinkBase']) . "/page/" . urlencode($page);
           else
               $url = get_option('home') . '/index.php?now_reading_page=' . urlencode($page);
   
           $url = apply_filters('library_page_url', $url);
   
           if ( $echo )
               echo $url;
           return $url;
       }
       ```
   
 * I have no idea what the apply_filters function is doing.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] Fatal error trying to activate and use 5.3.0.1](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/#post-1134913)
 * Brilliant, the mod-rewrite was the problem! When I’d setup the test blog I’d 
   missed the custom permalink setting I used on the prod blog.
 * I was in the middle of modifying the templates for my custom theme, thus the 
   lack of css.
 * Thanks for all your help.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] Fatal error trying to activate and use 5.3.0.1](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/#post-1134884)
 * OK, halfway there. I’ve done as suggested on both my prod and test blogs.
 * For the prod blog ([http://davidedwardsphotos.com/blog](http://davidedwardsphotos.com/blog)),
   which is WP 2.7.1, all appears fine.
 * For the test blog ([http://davidedwardsphotos.com/test_blog](http://davidedwardsphotos.com/test_blog)),
   which is running WP 2.8, I’m still getting the internal server errors.
 * The php.ini file is showing 64M memory (“memory_limit = 64M”).
 * I’ve checked the .htaccess files and they seem fine. The one in my root is for
   the phpsuexec and the one in the test blog root is:
    ` Options -Indexes
 * # BEGIN WordPress
    <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond%{
   REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.
   php [L] </IfModule>
 * # END WordPress
 * I’m not seeing anything in the http server or php error logs, which is a worry.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] Fatal error trying to activate and use 5.3.0.1](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-fatal-error-trying-to-activate-and-use-5301/#post-1134858)
 * They were set. I’ve just checked them again and saved them again. Problem still
   persists.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] Out of Memory Errors](https://wordpress.org/support/topic/plugin-now-reading-reloaded-out-of-memory-errors/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-out-of-memory-errors/#post-1134649)
 * I followed the old deactivate all plugins and then selectively re-activate them.
   It proved to be the [Bluetrait Event Viewer](http://wordpress.org/extend/plugins/bluetrait-event-viewer/)
   plugin, which I had enabled to try and debug the issues with 4.4.5.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Now Reading Reloaded] Out of Memory Errors](https://wordpress.org/support/topic/plugin-now-reading-reloaded-out-of-memory-errors/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-now-reading-reloaded-out-of-memory-errors/#post-1134632)
 * For example when trying to run [http://davidedwardsphotos.com/test_blog/?now_reading_library=true](http://davidedwardsphotos.com/test_blog/?now_reading_library=true),
   I get:
 * **Fatal error**: Out of memory (allocated 33816576) (tried to allocate 20436801
   bytes) in **/home/davidedw/public_html/test_blog/wp-includes/wp-db.php** on line**
   445**
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [[Plugin: Sociable] Remove bullets and do horizontal](https://wordpress.org/support/topic/plugin-sociable-remove-bullets-and-do-horizontal/)
 *  [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-sociable-remove-bullets-and-do-horizontal/page/2/#post-956495)
 * Yes, that did it. I wasn’t aware of the specificity. Learn something new every
   day.
 * So, I’m back to the vanilla Sociable with the following CSS:
 *     ```
       #content .sociable span {
       	# display: block;
       }
       #content .sociable ul {
       	display: inline;
       	margin: 0;
       	padding: 0;
       }
       #content .sociable ul li {
       	background: none;
       	display: inline;
       	list-style-type: none;
       	margin: 0;
       	padding: 1px;
       }
       #content .sociable ul li:before { content: ""; }
       #content .sociable img {
       	display: inline;
       	float: none;
       	width: 16px;
       	height: 16px;
       	border: 0;
       	margin: 0;
       	padding: 0;
       }
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [[Plugin: Sociable] Remove bullets and do horizontal](https://wordpress.org/support/topic/plugin-sociable-remove-bullets-and-do-horizontal/)
 *  [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-sociable-remove-bullets-and-do-horizontal/page/2/#post-956492)
 * I found that sociable is using a class=sociable in the div, and my id CSS was
   overwriting it (which has the bullet in my #content defs).
 * So I changed the class=sociable in sociable.php to a id=sociable and put the 
   set of #sociable settings in my style.css…
 *     ```
       #sociable span {
       	# display: block;
       }
       #sociable ul {
       	display: inline;
       	margin: 0;
       	padding: 0;
       }
       #sociable ul li {
       	background: none;
       	display: inline;
       	list-style-type: none;
       	margin: 0;
       	padding: 1px;
       }
       #sociable ul li:before { content: ""; }
       #sociable img {
       	display: inline;
       	float: none;
       	width: 16px;
       	height: 16px;
       	border: 0;
       	margin: 0;
       	padding: 0;
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Plugin: Sociable] want icons in horizontal line rather than vertical list](https://wordpress.org/support/topic/plugin-sociable-want-icons-in-horizontal-line-rather-than-vertical-list/)
 *  [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-sociable-want-icons-in-horizontal-line-rather-than-vertical-list/#post-1074555)
 * I found that sociable is using a class=sociable in the div, and my id CSS was
   overwriting it. So I changed the class=sociable in sociable.php to a id=sociable
   and put the set of #sociable settings in my style.css…
 *     ```
       #sociable span {
       	# display: block;
       }
       #sociable ul {
       	display: inline;
       	margin: 0;
       	padding: 0;
       }
       #sociable ul li {
       	background: none;
       	display: inline;
       	list-style-type: none;
       	margin: 0;
       	padding: 1px;
       }
       #sociable ul li:before { content: ""; }
       #sociable img {
       	display: inline;
       	float: none;
       	width: 16px;
       	height: 16px;
       	border: 0;
       	margin: 0;
       	padding: 0;
       }
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Can’t edit a page with iframe](https://wordpress.org/support/topic/cant-edit-a-page-with-iframe/)
 *  [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/cant-edit-a-page-with-iframe/#post-633485)
 * with my 2.3.3 WP.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Can’t edit a page with iframe](https://wordpress.org/support/topic/cant-edit-a-page-with-iframe/)
 *  [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/cant-edit-a-page-with-iframe/#post-633484)
 * It must be fixed in WP 2.5, ‘cos I’ve just upgraded to Firefox 2.0.0.13 (from
   2.0.0.12) and the error is still occurring.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[XML Google Maps] – Get blank map screen](https://wordpress.org/support/topic/xml-google-maps-get-blank-map-screen/)
 *  Thread Starter [davidedw](https://wordpress.org/support/users/davidedw/)
 * (@davidedw)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/xml-google-maps-get-blank-map-screen/#post-725682)
 * BTW, it was not working before the upgrade.

Viewing 14 replies - 1 through 14 (of 14 total)