Filters failing after update to 1.3.0

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
b.weber
Posts: 1
Joined: 29 Aug 2016, 10:18

Filters failing after update to 1.3.0

Post by b.weber »

Hi,

we had some issues getting filters to work after an upgrade to 1.3.0. It seems that the database upgrade did not change the format of field filter_string in the filter table. Since the previous version used serialize instead of the current json format reading/using older filters resulted in an error message.

Argument 1 passed to filter_ensure_valid_filter() must be of the type array, ... (as described in [https://www.mantisbt.org/bugs/view.php?id=21404])

This should be fixed within the database upgrade procedure. Meanwhile the following patch of the two files filter_api.php and user_api.php may be helpful.
Use at your own risk if you know what you are doing...

Regards

Bernd Weber

diff -Naur mantisbt-1.3.0/core/filter_api.php mantisbt-1.3.0_new/core/filter_api.php
--- mantisbt-1.3.0/core/filter_api.php 2016-07-09 23:09:52.000000000 +0200
+++ mantisbt-1.3.0_new/core/filter_api.php 2016-08-29 11:28:57.546384120 +0200
@@ -851,6 +851,9 @@
$t_filter_array = array();
if( isset( $t_setting_arr[1] ) ) {
$t_filter_array = json_decode( $t_setting_arr[1], true );
+ if (is_null($t_filter_array)) {
+ $t_filter_array = unserialize($t_setting_arr[1]);
+ }
} else {
return false;
}
@@ -861,7 +864,6 @@

return $t_filter_array;
}
-
/**
* Check if the filter cookie exists and is of the correct version.
* @return boolean
diff -Naur mantisbt-1.3.0/core/user_api.php mantisbt-1.3.0_new/core/user_api.php
--- mantisbt-1.3.0/core/user_api.php 2016-07-09 23:09:52.000000000 +0200
+++ mantisbt-1.3.0_new/core/user_api.php 2016-08-29 11:23:31.093636913 +0200
@@ -1406,7 +1406,9 @@
}

$t_filter = json_decode( $t_cookie_detail[1], true );
-
+ if (is_null($t_filter)) {
+ $t_filter = unserialize($t_cookie_detail[1]);
+ }
$t_filter = filter_ensure_valid_filter( $t_filter );

return $t_filter;
Post Reply