The simpler media website CMS
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.
Comments
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.
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..
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.
I cannot reproduce this on my test install. Can ypu try to replace
strpos
withmb_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.
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.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.
Supressing errors is generally not a good idea (I know the ZP code has in lots of places which is to be reviewed sometime…)
Well, I changed the code to
instead of suppressing the error.
Okay, then we should be able to simplify this to:
if (defined('WEBPATH') && !empty(WEBPATH) && strpos($redirectTo, WEBPATH) === false) {
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.