• Hello everybody,
    editing a post on a WP installation of mine, i came across this never-had-before problem:

    PHP Catchable fatal error: Object of class stdClass could not be converted to string in /path/to/myWP.blog/wp-content/db.php on line 601, referer: [...]/wp-admin/post.php?action=edit&post=787&message=1

    Probably some plugin with some post enahnacement function (like a calendar plugin) has triggered this WP bug; the problem is similar to others, like this one: when WP tries to escape data before insert them in the database, it checks only for arrays and strings (99% times it is enough) and not for objects.
    I’ve posted this on discussions about “DB Cache Reloaded” cause I’m using it on that blog and the bug above was founded on wp-db.php (core WP library) and obviously on the db.php created by this plugin that, if I’m not wrong, replicate (or extends, don’t know) part of the WP core db library.

    So i’ve patched the “escape” function on theese two files and on the source file in “DB Cache Reloaded” (db-module.php), this way:

    function escape($data) {
      //PATCH START
      if(is_object($data))
        $data = serialize($data);
      //PATCH END
      if ( is_array($data) ) {
        foreach ( (array) $data as $k => $v ) {
          if ( is_array($v) )
            $data[$k] = $this->escape( $v );
          else
            $data[$k] = $this->_weak_escape( $v );
        }
      } else {
        $data = $this->_weak_escape( $data );
      }
      return $data;
    }

    and it seems to work for now. I Hope sirzooro (and others of course) can help me analyze and resolve this issue the right way.

    http://wordpress.org/extend/plugins/db-cache-reloaded/

  • The topic ‘[Plugin: DB Cache Reloaded] PHP Catchable fatal error’ is closed to new replies.