Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error when switching between Jobs and Document search #48

Open
brewt opened this issue Feb 21, 2014 · 1 comment
Open

Fatal error when switching between Jobs and Document search #48

brewt opened this issue Feb 21, 2014 · 1 comment

Comments

@brewt
Copy link
Contributor

brewt commented Feb 21, 2014

Don't know if this is just an issue with the Bricolage install I'm working on, but if I go to perform a Document search, then go to Jobs and search, then go back to the Document search, I get a fatal error:

Can't use string ("%") as an ARRAY ref while "strict refs" in use at bricolage/comp/widgets/listManager/listManager.mc line 681.

And that's happening because $crit = '%'. Didn't dig deep enough to find out why that being set to that.

My fix was to check $crit and $crit_field:

diff --git a/comp/widgets/listManager/listManager.mc b/comp/widgets/listManager/listManager.mc
index 47f7cc6..04b2801 100755
--- a/comp/widgets/listManager/listManager.mc
+++ b/comp/widgets/listManager/listManager.mc
@@ -679,7 +679,9 @@ my $build_constraints = sub {
     my $list_arg   = {};

     # If any criteria were passed then we need to constrain our list.
-    if ($crit && $crit_field) {
+    if ($crit && $crit_field &&
+        ref $crit eq 'ARRAY' && ref $crit_field eq 'ARRAY' &&
+        @$crit == @$crit_field) {
         # If field is an array, build a hash with the fields as the keys and
         # $crit for vals
         if (ref $crit_field) {

But there's obviously some underlying code that's causing the search state to be messed up and should get fixed.

@brewt
Copy link
Contributor Author

brewt commented Feb 21, 2014

Updated patch since there are some cases (eg. User search) where $crit and $crit_field aren't refs:

diff --git a/comp/widgets/listManager/listManager.mc b/comp/widgets/listManager/listManager.mc
index 216a4e4..3067411 100644
--- a/comp/widgets/listManager/listManager.mc
+++ b/comp/widgets/listManager/listManager.mc
@@ -677,7 +677,8 @@ my $build_constraints = sub {
     if ($crit && $crit_field) {
         # If field is an array, build a hash with the fields as the keys and
         # $crit for vals
-        if (ref $crit_field) {
+        if (ref $crit eq 'ARRAY' && ref $crit_field eq 'ARRAY' &&
+            @$crit == @$crit_field) {
             @{$list_arg}{@$crit_field} = @$crit;
         } else {
             $crit_field = $def_sort_field if $crit_field eq '_default';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant