From 58c77d2b40b3b0086f2d3d21cbf6d1a72bb9ddcf Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 23 May 2011 16:19:12 +0000 Subject: [PATCH] Updates for version 1.24.4 git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3358 e3e1d417-86f3-4887-817a-d78f3d33393f --- configure.ac | 2 +- db/Makefile.am | 3 ++- db/zm_update-1.24.3.sql | 13 +++++++++++++ scripts/zmupdate.pl.in | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 db/zm_update-1.24.3.sql diff --git a/configure.ac b/configure.ac index 40ff8c55f..e780f308e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.59) -AC_INIT(zm,1.24.3,support@zoneminder.com,ZoneMinder,http://www.zoneminder.com/downloads.html) +AC_INIT(zm,1.24.4,support@zoneminder.com,ZoneMinder,http://www.zoneminder.com/downloads.html) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR(src/zm.h) AM_CONFIG_HEADER(config.h) diff --git a/db/Makefile.am b/db/Makefile.am index 39b3ef68a..1aa6a5a80 100644 --- a/db/Makefile.am +++ b/db/Makefile.am @@ -39,4 +39,5 @@ EXTRA_DIST = \ zm_update-1.23.3.sql \ zm_update-1.24.0.sql \ zm_update-1.24.1.sql \ - zm_update-1.24.2.sql + zm_update-1.24.2.sql \ + zm_update-1.24.3.sql diff --git a/db/zm_update-1.24.3.sql b/db/zm_update-1.24.3.sql new file mode 100644 index 000000000..6243e08fa --- /dev/null +++ b/db/zm_update-1.24.3.sql @@ -0,0 +1,13 @@ +-- +-- This updates a 1.24.3 database to the next version +-- + +-- +-- These are optional, but we might as well do it now +-- +optimize table Frames; +optimize table Events; +optimize table Filters; +optimize table Zones; +optimize table Monitors; +optimize table Stats; diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index 57e9f5957..ac6eb4ccb 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -901,6 +901,41 @@ if ( $version ) patchDB( $dbh, "1.24.2" ); $cascade = !undef; } + if ( $cascade || $version eq "1.24.3" ) + { + my $result = eval + { + require PHP::Serialization; + PHP::Serialization->import(); + }; + die( "Unable to perform upgrade from 1.24.3, PHP::Serialization module not found" ) if ( $result ); + + # Patch the database + patchDB( $dbh, "1.24.3" ); + + # Convert filters to JSON from PHP format serialisation + { + my $sql = "select * from Filters"; + my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() ); + my @dbFilters; + while( my $dbFilter = $sth->fetchrow_hashref() ) + { + push( @dbFilters, $dbFilter ); + } + $sth->finish(); + foreach my $dbFilter ( @dbFilters ) + { + my $phpQuery = $dbFilter->{Query}; + my $query = PHP::Serialization::unserialize( $phpQuery ); + my $jsonQuery = jsonEncode( $query ); + my $sql = "update Filters set Query = ? where Name = ?"; + my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $jsonQuery, $dbFilter->{Name} ) or die( "Can't execute: ".$sth->errstr() ); + } + } + $cascade = !undef; + } if ( $cascade ) { my $installed_version = ZM_VERSION;