diff --git a/AJAXPoll.php b/AJAXPoll.php index f8aa190..dd591ce 100644 --- a/AJAXPoll.php +++ b/AJAXPoll.php @@ -19,7 +19,7 @@ * @author Jack Phoenix * @author Thomas Gries * @maintainer Thomas Gries - * @version 1.72 + * @version 1.73 * @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation */ @@ -31,7 +31,7 @@ if( !defined( 'MEDIAWIKI' ) ) { $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'AJAX Poll', - 'version' => '1.72 20120314', + 'version' => '1.73 20120314', 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries' ), 'descriptionmsg' => 'ajaxpoll-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll', diff --git a/AJAXPoll_body.php b/AJAXPoll_body.php index 02a5145..4e26012 100644 --- a/AJAXPoll_body.php +++ b/AJAXPoll_body.php @@ -399,23 +399,38 @@ class AJAXPoll { } else { // >= 1.17 support - # poll_info.poll_title field was dropped in AJAXPoll version 1.72 - $updater->dropExtensionField( - 'poll_info', - 'poll_title', - dirname( __FILE__ ) . '/patches/drop-field--poll_info-poll_title.sql' - ); + if ( $updater->extensionTableExists( 'poll_info' ) ) { + # poll_info.poll_title field was dropped in AJAXPoll version 1.72 + $updater->dropExtensionField( + 'poll_info', + 'poll_title', + dirname( __FILE__ ) . '/patches/drop-field--poll_info-poll_title.sql' + ); + $updater->addExtensionTable( + 'ajaxpoll_info', + dirname( __FILE__ ) . '/patches/rename-table--poll_info.sql' + ); + } else { + $updater->addExtensionTable( + 'ajaxpoll_info', + dirname( __FILE__ ) . '/patches/create-table--ajaxpoll_info.sql' + ); + } - $updater->addExtensionTable( - 'ajaxpoll_info', - dirname( __FILE__ ) . '/patches/create-table--ajaxpoll_info.sql' - ); - $updater->addExtensionTable( - 'ajaxpoll_vote', - dirname( __FILE__ ) . '/patches/create-table--ajaxpoll_vote.sql' - ); + if ( $updater->extensionTableExists( 'poll_vote' ) ) { + $updater->addExtensionTable( + 'ajaxpoll_vote', + dirname( __FILE__ ) . '/patches/rename-table--poll_vote.sql' + ); + } else { + $updater->addExtensionTable( + 'ajaxpoll_vote', + dirname( __FILE__ ) . '/patches/create-table--ajaxpoll_vote.sql' + ); + } } + return true; } diff --git a/patches/create-table--ajaxpoll_info.sql b/patches/create-table--ajaxpoll_info.sql index 4aa7c79..d8d78fd 100644 --- a/patches/create-table--ajaxpoll_info.sql +++ b/patches/create-table--ajaxpoll_info.sql @@ -1,4 +1,3 @@ -RENAME TABLE /*_*/poll_info TO /*_*/ajaxpoll_info; CREATE TABLE IF NOT EXISTS /*_*/ajaxpoll_info ( `poll_id` varchar(32) NOT NULL PRIMARY KEY default '', `poll_txt` text, diff --git a/patches/create-table--ajaxpoll_vote.sql b/patches/create-table--ajaxpoll_vote.sql index 83cf036..e1c1553 100644 --- a/patches/create-table--ajaxpoll_vote.sql +++ b/patches/create-table--ajaxpoll_vote.sql @@ -1,4 +1,3 @@ -RENAME TABLE /*_*/poll_vote TO /*_*/ajaxpoll_vote; CREATE TABLE IF NOT EXISTS /*_*/ajaxpoll_vote ( `poll_id` varchar(32) NOT NULL default '', `poll_user` varchar(255) NOT NULL default '', diff --git a/patches/rename-table--poll_info.sql b/patches/rename-table--poll_info.sql new file mode 100644 index 0000000..7f8f180 --- /dev/null +++ b/patches/rename-table--poll_info.sql @@ -0,0 +1 @@ +RENAME TABLE /*_*/poll_info TO /*_*/ajaxpoll_info; diff --git a/patches/rename-table--poll_vote.sql b/patches/rename-table--poll_vote.sql new file mode 100644 index 0000000..fe2ec53 --- /dev/null +++ b/patches/rename-table--poll_vote.sql @@ -0,0 +1 @@ +RENAME TABLE /*_*/poll_vote TO /*_*/ajaxpoll_vote;