Member
Member
MarkRH   2019-05-31, 23:46
#1

I've noticed when doing certain things I get the following warning:

[31-May-2019 18:26:12 America/Chicago] PHP Warning: strpos(): Empty needle in /home/(path)/zp-core/functions-basic.php on line 1876

The code there is:

    if (defined('WEBPATH') && strpos($redirectTo, WEBPATH) === false) {
        $redirect .= WEBPATH . '/';
    }

I get this when hitting Apply to save an image and when viewing a full-sized image. Doing some debug output, looks like the value for WEBPATH is empty and that's causing the issue.

Administrator
Administrator
acrylian   2019-06-01, 10:58
#2

Please try the support build soon becoming 1.5.3. There are some issues with internal redirections in 1.5.2 that are fixed there that may impact this.

Member
Member
MarkRH   2019-06-01, 20:39
#3

Version 1.5.3b does the same thing.

I also notice that it's not saving emojis.. it's changing them to "????". I seem to remember does something before to save them. Hmmm..

Member
Member
MarkRH   2019-06-01, 21:54
#4

Figured out the emoji thing. Found previous thread on here where I talked about it. Changed the "Entity encoding" option in the tinymce4 plugin to "numeric". Now it keeps the emojis intact.

Administrator
Administrator
acrylian   2019-06-02, 08:51
#5

I cannot reproduce this on my test install. Can ypu try to replace strpos with mb_strpos in that line to see if that fixes it for you? Assuming your server has the multibyte extension.

For now the PHP multibyte extension is not a requirement but probably we could change that in the future to avoid extra checks or even wrapper functions…(Can't understand why this is not default in PHP in the standard functions anyway by now)

Also some multibyte characters and this also applies to emojis require a different database encoding using "mb4" encoding variants. This will be the default in the future (depending on the mysql version) but for now we have chosen not to implement that because it also requires changes to existing tables and columns. Their size needs to be adjusted to be larger because each character requires more space then. So it's on the long TODO list.

Member
Member
MarkRH   2019-06-02, 10:48
#6

Using mb_strpos I get a slightly different warning:

WARNING: mb_strpos(): Empty delimiter in C:(path)\zp-core\functions-basic.php on line 1882

I added some debug lines to log variable values so that's not the original line number for that code.

Should WEBPATH actually contain a value other than "" ? It makes sense that the functions would complain about the item being searched for (needle) is an empty value.

I can suppress the warning message by using @strpos Everything seems to be working otherwise.

Administrator
Administrator
acrylian   2019-06-02, 10:59
#7

Should WEBPATH actually contain a value other than "" ?

Yes, if you installed in the root of your (sub)domain it is empty, if installed in a folder it will containt that folder. Matches the rewrite base in the htaccess file technically.

I previously tested locally which is always in a subfolder but even on our site I don't get this error when saving an image.

@strpos

Supressing errors is generally not a good idea (I know the ZP code has in lots of places which is to be reviewed sometime…)

Member
Member
MarkRH   2019-06-02, 12:00
#8

Well, I changed the code to

if (!empty(WEBPATH)) {
   if (strpos($redirectTo, WEBPATH) === false) {
      $redirect .= WEBPATH . '/';
   }
} 

instead of suppressing the error.

Administrator
Administrator
acrylian   2019-06-02, 13:21
#9

Okay, then we should be able to simplify this to:

if (defined('WEBPATH') && !empty(WEBPATH) && strpos($redirectTo, WEBPATH) === false) {

Administrator
Administrator
acrylian   2019-06-02, 18:19
#10

The fix is in the support build now. I also discovered that on installs with WEBPATH like my localhost installs the function did return an unwanted double slash in the URL which is also fixed.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.