• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed "break" missing in a switch loop

cclaerhout

Well-known member
#1
Class: XenResource_Search_DataHandler_Update
PHP:
      case 'resprefix':
         if ($constraintInfo)
         {
           return array(
             'metadata' => array('resprefix', preg_split('/\D+/', strval($constraintInfo))),
           );
         }

       case 'is_resource':
The $constraintInfo has no reason not to be there, but since there's a conditional, a break would be safer.
 

cclaerhout

Well-known member
#2
I'm going to take the opportunity of the above post to ask if there's any reason to use a preg_split instead of an explode since the constraintInfo have been created/checked from the input using an implode with a blank space just a little above in the code?
 

Mike

XenForo developer
Staff member
#3
This happened in the post data handler as well, so I've fixed that too.

As for the preg_split, it's probably unnecessary in the default code, but from my reading, the constraints aren't guaranteed to be filtered particularly well, so it is more defensive than just a plain explode.