Search

I have tidied this up, removing all legacy code. I have put a preliminary version number of 0.9, but I’d appreciate you guys also testing the latest version.

https://github.com/nickdunn/db_sync

The biggest addition here is a key in the config so that you can check in the change to the MySQL class, but disable query logging on live sites by changing the config value (yes/no).

Now all the old code has been removed, you see how simple this extension actually is :-)

Test.

Test,

hmm, ok … hope it is not confusing for the new commers who won’t differentiate between Symphony < 2.2 and >= 2.2.

My point is that this extension is compatible with Symphony 2.0.7 right through to 2.2 and beyond. The bug fixes we’ve just been discussing don’t affect just Symphony 2.2; they are present in the extension regardless of what Symphony version you’re using.

Unless I am misunderstanding?

Ok, I finally understood.

And so far it is working.

Thanks for your constant contributions @nickdunn !

Database Synchroniser updated to version 0.9.1 on 10th of February 2011

I’m a little confused on how to use this extension. I see that a db_sync.sql file gets created in my manifest folder. Do i run that sql file when I’m migrating between servers? Also, I installed this extension after i made a bunch of sections and I noticed in the sql file that it just runs UPDATE statements and doesn’t check if the table is created yet. How do I get around this issue?

Do i run that sql file when I’m migrating between servers

Yes. From the README:

My workflow when using a development/staging/production environment is to install this extension on the development server only. When making a release I pull the production database back to staging where I apply the dbsync SQL file. If all goes well after testing, I back up production and run the same dbsync file. The log is then flushed and I can continue developing towards another release

When you're done making changes, take the .sql file and run it against your production database. But as I say above, always take and keep a backup just in case!

Also, I installed this extension after i made a bunch of sections and I noticed in the sql file that it just runs UPDATE statements and doesn’t check if the table is created yet. How do I get around this issue?

Unfortunately you cannot. You can only track changes after the extension has been installed. It will log your table CREATE statements when creating new sections, but only if the extension has been installed and enabled!

Got this working with a large update to an already-running site with version 2.1.2. This extension makes all the difference - hooraay!!

thanks Nick

/J

i just reread the README and have another question:

The log is then flushed and I can continue developing towards another release.

Then this is your general workflow with this extension:

  1. Dev work, creates SQL file
  2. Pull Prod DB to Staging, push SQL file to Staging
  3. If all looks good on Staging, push all to Prod
  4. If all looks good on Prod, go back to dev
  5. Clear contents of original SQL file, repeat

So you're not keeping a huge SQL file of everything that has happened on the development server, it's just basically what has happened between releases?

Yep that's correct. The SQL file is a "delta" that just contains the changes made between two releases. Once deployed to production, the SQL file is purged from dev and the development freeze is lifted. New changes to dev create the SQL file again.

I get the following error in my S2.1.2 installation (extension version = 0.9.1):

Fatal error: Call to undefined method Symphony::Engine() in [...]/extensions/db_sync/lib/class.logquery.php on line 9

I'm afraid 0.9.* is for Symphony 2.2 only.

I have symphony 2.2.1 and db_sync 0.9.1. When I copied the required code to the class.mysql.php file (as per README) I suddenly can't enter the admin interface anymore (Symphony keeps asking for my credentials). As soon as I remove the code, it all works again.

The log shows the following:

UNKNOWN: Accessing static property Administration::$Database as non static in file /home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php on line 78

I tried displaying errors (modified symphony/lib/boot/bundle.php to report E_ALL | E_STRICT) and strangely the same error occurs with or without the modified class.mysql.phpfile, it's just the stack trace that changes.

Accessing static property Administration::$Database as non static
/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php line 78

73       */
74      protected function __construct(){
75          parent::__construct();
76
77          // Need this part for backwards compatiblity
78          $this->Database = Symphony::Database();
79          $this->Configuration = Symphony::Configuration();
80          $this->ExtensionManager = Symphony::ExtensionManager();
81      }
82

Backtraces are

The one that works

[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:78] GenericErrorHandler::handler();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:57] Administration->__construct();
[/home/ixai/projects/ixai.xbebop/public/index.php:13] Administration::instance();
[/home/ixai/projects/ixai.xbebop/public/index.php:25] renderer();

The one that doesn't

[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:78] GenericErrorHandler::handler();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:57] Administration->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:153] Administration::instance();
[/home/ixai/projects/ixai.xbebop/public/extensions/db_sync/lib/class.logquery.php:9] Symphony::Engine();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:481] LogQuery::log();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:613] MySQL->query();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:671] MySQL->fetch();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.extensionmanager.php:580] MySQL->fetchCol();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.lang.php:309] ExtensionManager->listInstalledHandles();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.lang.php:251] Lang::fetch();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.lang.php:223] Lang::activate();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:141] Lang::set();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:75] Symphony->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:57] Administration->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:153] Administration::instance();
[/home/ixai/projects/ixai.xbebop/public/extensions/db_sync/lib/class.logquery.php:9] Symphony::Engine();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:481] LogQuery::log();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:613] MySQL->query();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:702] MySQL->fetch();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.session.php:195] MySQL->fetchVar();
[:0] Session::read();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.session.php:91] session_start();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.cookie.php:107] Session::start();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.cookie.php:98] Cookie->__init();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:205] Cookie->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:132] Symphony->initialiseCookie();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:75] Symphony->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:57] Administration->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:153] Administration::instance();
[/home/ixai/projects/ixai.xbebop/public/extensions/db_sync/lib/class.logquery.php:9] Symphony::Engine();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:481] LogQuery::log();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/toolkit/class.mysql.php:344] MySQL->query();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:258] MySQL->setCharacterSet();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.symphony.php:130] Symphony->initialiseDatabase();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:75] Symphony->__construct();
[/home/ixai/projects/ixai.xbebop/public/symphony/lib/core/class.administration.php:57] Administration->__construct();
[/home/ixai/projects/ixai.xbebop/public/index.php:13] Administration::instance();
[/home/ixai/projects/ixai.xbebop/public/index.php:25] renderer();

Could you help me out?

(hope I wrote the correct markdown...)

Thanks for your report Ixai. This is a weird one and I've traced it back to the very first line of LogQuery::log() in lib/class.logquery.php:

if(!Symphony::Engine() instanceOf Administration) return;

As soon as I refer to Symphony::Engine() it logs me out. My guess is that the very first query that Symphony runs is before the engine is fully instantiated, so something is getting out of sync. When I try to access Engine presumably Symphony tries to re-instantiate itself.

Anyway, the quick fix I found was to replace this line with:

if(!class_exists('Administration')) return;

This should be sufficient to check that the query logging is running in the context of the backend only.

I'm curious does if(!(Symphony::Engine() instanceOf Administration)) return; work?

Nope that also logs me out. It seems any reference to Symphony::Engine() at this point causes the log out, presumably because it's being called really early in the page lifecycle (on the very first database query that sets the charset/collation query).

I'm glad my report was helpful. Thanks for fixing it so fast.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details