Jump to content

Results of a selector different after switching web host - why?


Violet
 Share

Recommended Posts

This is probably something I'm doing wrong or don't understand, but I've seen on several of my websites some slight differences in PW selector results after switching my web host. Would anyone please be able to explain why this is so? It's resulted in a few unintended ramifications, although it was easy enough to fix these.

In switching hosts I've also changed several things at once - the PHP version went from 5.6 ? (I know! part of why I was switching!) to 7.4. The mysql version may have changed too, but I wasn't able to look up the old one now because the domain is pointing to the new host. The new MySQL version is 10.3.27-MariaDB. I have zero SQL knowledge, and I simply look at  the processwire selector docs when I want to use a PW selector, without worrying or considering what sort of SQL that might translate to. The PW version was the same at both the old and new host, 3.0.165 i.e. at the time of writing the latest master (but not dev) version.

The specific problem as far as I can boil things down from tests I've done, is that on my old host, the ~= selector when used in findOne would return a page that contained all the specified words even if there were additional words to the specified one (example coming). But on the new host, the ~= selector seems to fail if there are additional words present in the field besides the ones specified.

Here is an example:

$adstr = "Article body end";
$thatspotinfo = $pages->findOne("template=banner-slot-info, title~=$adstr");

This will NOT on my new host allow the finding of the intended page, which is titled (without the quotes) "Article body end position 300x250". It comes up with nothing on the new host, even though on the old host this exact same selector came up with the page I mentioned.

On the other hand, if $adstr is set to "Leaderboard position", then it does in fact find the intended page titled (again without the quotes) "Leaderboard position". So it seems like the extra words of "position 300x250" on the first page I mentioned is causing the selector not to find that page (although this was not the case on the old host, also I didn't change the page titles).

Both of the page titles I mentioned will be found correctly if I instead use the "contains phrase/text" selector of *=

Example:

$adstr = "Article body end";
$thatspotinfo = $pages->findOne("template=banner-slot-info, title*=$adstr");

and

$adstr = "Leaderboard position";
$thatspotinfo = $pages->findOne("template=banner-slot-info, title*=$adstr");

These find the intended pages of:

Article body end position 300x250

and

Leaderboard position

Likewise, the intended pages are also found if I use the "starts with" selector ^= For example, title^=$adstr

Am I correct in saying that the ~= selector on my new host  means "contains all the desired words but only with no additional words present?" If not, what am I doing wrong?

Ultimately, what selector SHOULD I be using to say "contains these words in any desired order, additional words are allowed to be present too?"

For now, the workaround of "starts with" selector ^= is fine, but I'm keen to know what's going on. BTW here is a pic of the title field of the pages of interest in phpMyAdmin, which looks correct to me, I mean nothing got garbled from the looks of it.

Screenshot_phpmyadmin_Jan2020ed.png.62b61449092f36fe2856f5f8bd76c33d.png

ADDED: I'm also getting the same sort of thing from moving another site from a different old host to this new one. In that case, for the record, the PHP version of the old is 7.2.34 and the MYSQL version is 10.1.40-MariaDB. The new host has PHP version 7.4.14 and MYSQL version is 10.3.27-MariaDB.

Edited by Violet
ADDED
Link to comment
Share on other sites

17 hours ago, Violet said:

Am I correct in saying that the ~= selector on my new host  means "contains all the desired words but only with no additional words present?" If not, what am I doing wrong?

Hi,

it sounds like you are correct ? the docs say "Matches whole words only" and these different results between your hosts could come from a "little" less accurate use of full text in the older versions of php and mysql ?

have a nice day

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...