diff --git a/module/VuFind/sql/migrations/pgsql/9.0/006-modify-boolean-fields.sql b/module/VuFind/sql/migrations/pgsql/9.0/006-modify-boolean-fields.sql new file mode 100644 index 00000000000..a978bd49ae0 --- /dev/null +++ b/module/VuFind/sql/migrations/pgsql/9.0/006-modify-boolean-fields.sql @@ -0,0 +1,18 @@ +-- +-- Modifications to table `search` +-- + +ALTER TABLE "search" + ALTER COLUMN saved DROP DEFAULT, + ALTER COLUMN saved TYPE boolean USING saved::boolean, + ALTER COLUMN saved SET NOT NULL, + ALTER COLUMN saved SET DEFAULT '0'; +-- +-- Modifications to table `user_list` +-- + +ALTER TABLE "user_list" + ALTER COLUMN public DROP DEFAULT, + ALTER COLUMN public TYPE boolean USING public::boolean, + ALTER COLUMN public SET NOT NULL, + ALTER COLUMN public SET DEFAULT '0'; \ No newline at end of file diff --git a/module/VuFind/sql/mysql.sql b/module/VuFind/sql/mysql.sql index eef3af002cd..5207588c586 100644 --- a/module/VuFind/sql/mysql.sql +++ b/module/VuFind/sql/mysql.sql @@ -138,7 +138,7 @@ CREATE TABLE `search` ( `folder_id` int(11) DEFAULT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `title` varchar(20) DEFAULT NULL, - `saved` int(1) NOT NULL DEFAULT '0', + `saved` tinyint(1) NOT NULL DEFAULT '0', `search_object` blob, `checksum` int(11) DEFAULT NULL, `notification_frequency` int(11) NOT NULL DEFAULT '0', @@ -265,7 +265,7 @@ CREATE TABLE `user_list` ( `title` varchar(200) NOT NULL, `description` text, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', - `public` int(11) NOT NULL DEFAULT '0', + `public` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `user_id` (`user_id`), CONSTRAINT `user_list_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE diff --git a/module/VuFind/sql/pgsql.sql b/module/VuFind/sql/pgsql.sql index 4b71608261c..1843b2d1b52 100644 --- a/module/VuFind/sql/pgsql.sql +++ b/module/VuFind/sql/pgsql.sql @@ -95,7 +95,7 @@ session_id varchar(128), folder_id int DEFAULT NULL, created timestamp NOT NULL DEFAULT '1970-01-01 00:00:00', title varchar(20) DEFAULT NULL, -saved int NOT NULL DEFAULT '0', +saved boolean NOT NULL DEFAULT '0', search_object bytea, checksum int DEFAULT NULL, notification_frequency int NOT NULL DEFAULT '0', @@ -192,7 +192,7 @@ user_id int NOT NULL, title varchar(200) NOT NULL, description text DEFAULT NULL, created timestamp NOT NULL DEFAULT '1970-01-01 00:00:00', -public int NOT NULL DEFAULT '0', +public boolean NOT NULL DEFAULT '0', PRIMARY KEY (id) ); CREATE INDEX user_list_user_id_idx ON user_list (user_id); diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index a90230a74d7..26c8063444d 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -541,7 +541,9 @@ protected function isDuplicateOfSavedSearch( $userId ); foreach ($matches as $current) { - if ($current->saved === 1 && $current->id !== $rowToCheck->id) { + // $current->saved may be 1 (MySQL) or true (PostgreSQL), so we should + // avoid a strict === comparison here: + if ($current->saved == 1 && $current->id !== $rowToCheck->id) { return $current->id; } } diff --git a/module/VuFind/src/VuFind/Search/History.php b/module/VuFind/src/VuFind/Search/History.php index 6728638e767..1d89a6e5a0c 100644 --- a/module/VuFind/src/VuFind/Search/History.php +++ b/module/VuFind/src/VuFind/Search/History.php @@ -118,6 +118,8 @@ public function getSearchHistory($userId = null) $saved = $schedule = $unsaved = []; foreach ($searchHistory as $current) { $search = $current->getSearchObject()->deminify($this->resultsManager); + // $current->saved may be 1 (MySQL) or true (PostgreSQL), so we should + // avoid a strict === comparison here: if ($current->saved == 1) { $saved[] = $search; } else {