Jump to content
Sign in to follow this  
celfred

[solved] Contains all words selector "~=" triggers an error since updating to 3.0.165

Recommended Posts

Hello,

I've just upgraded to 3.0.165 (and updated my Ubuntu version as well) and on my localhost, I am facing a weird issue : all my requests having the ~= selector cause a Mysql error with this message :

	PDOException #HY000
	SQLSTATE[HY000]: General error: 3685 Illegal argument to a regular expression.
	

I have no idea what is going on. If I change my request from

	$visualizer = $pages->get("name~=visualizer"); // Triggers the error
	

to

	$visualizer = $pages->get("name=visualizer");
	

or

	$visualizer = $pages->get("name~*=visualizer");
	

My code works fine again.

Any idea ? Shall I change all my requests (but from what I understand by reading the documentation, ~= exists and fits my needs : all words in any order [though I do understand that in my example above it may be useless since I have only one word])

Thanks !

Share this post


Link to post
Share on other sites

Maybe this can help. The error points to this file/line.

	File: .../wire/core/WireDatabasePDOStatement.php:166
	

Share this post


Link to post
Share on other sites

So nobody has any clue for me 😞 ?

On my localhost, I have :

PHP version is 7.4.3.

MySQL version is 8.0.21.

Maybe this can help...

I have a feeling if it was just a configuration problem, all requests should end up with the 'illegal argument to a regular expression' error ? But I can't imagine PW would be the cause (otherwise I vould get some clue from the community, I'm sure 😉)

 

Share this post


Link to post
Share on other sites
44 minutes ago, celfred said:

MySQL version is 8.0.21.

Some have experienced issues before with MySQL 8+ with latter versions of ProcessWire, though I cannot recall if it had to do with selectors. Hopefully you get better answers than this one.

Share this post


Link to post
Share on other sites

@kongondo Thanks for your reply.

23 hours ago, kongondo said:

Some have experienced issues before with MySQL 8+ with latter versions of ProcessWire, though I cannot recall if it had to do with selectors. Hopefully you get better answers than this one.

Ah... And downgrading MySql doesn't seem possible (at least for my low skills... - https://dev.mysql.com/doc/refman/8.0/en/downgrading.html

So I guess I'm gonna be in trouble here...

Share this post


Link to post
Share on other sites

@kongondo Thanks for your reply.

23 hours ago, kongondo said:

Some have experienced issues before with MySQL 8+ with latter versions of ProcessWire, though I cannot recall if it had to do with selectors. Hopefully you get better answers than this one.

Ah... And downgrading MySql doesn't seem possible (at least for my low skills... - https://dev.mysql.com/doc/refman/8.0/en/downgrading.html

So I guess I'm gonna be in trouble here...

Share this post


Link to post
Share on other sites

@kongondo I'm just noticing that my previous message didn't go through... I was saying that for your information, I had replaced all  my ~= operators with either ^=, ~*= or = depending on my use cases. It did the trick although I'm losing the original 'whole words' searching capability... but at least I'm not stuck 😉

I wen tahead and submitted a 'bug' issue as you advised. Not sure this is a real bug since I have a feeling somebody else would reproduce it if it was, but I di dmy best explaining the issue and I hope it can help !

If anybody needs more information about it, just ask. I'll keep an eye on this issue since I would like to understand and solve it in a better way !

But thanks again for your help !

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, kongondo said:

For completeness, here's the link to the bug report

https://github.com/processwire/processwire-issues/issues/1240

Btw, @celfred, is the error only when you do a $pages->get("name.....), i.e only on the 'name' field or other fields as well? e.g. $pages->get("another_text_field...)

@kongondo Great idea ! I've just tested and it works with other fields : title, summary... No problems (apparently). As soon as I change to "name~=", the error triggers.

I'll go ahead and write this as well on the 'bug' report.

Share this post


Link to post
Share on other sites

As a follow-up, @ryan had a look at this and made a patch that somehow  tests the Mysql version and does something that makes it work fine (at least on my localhost).

Technically speaking, I am unable to explain all this, so I prefer let the pros give details if needed, but just know the issue seems solved.

As I said on Github, I am quite glad I have been able to somehow contribute to the community. You all have provided me with so much help since I have discovered PW.

THANKS again !

  • Like 3

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SwimToWin
      I want to add a dependent SELECT field on my template page that lists pages from a parent "sub-page" in the current parent node.
      On /product1/page I have the field "photo" which is a SELECT field.
      I want the SELECT to list pages from /ROOTPARENT/photos.
      The idea is that I can reuse the same photo in many places - but only need to keep it update it once under /product1/photos.
      My page structure looks like so:
      /product1/page /product1/photos/photo3 (template=photos) /product2/photos/photo9 I have tried adding these Selector Strings on the Field (Setup -> Fields -> PHOTO -> Input tab -> Selectable Pages field group -> Selector String):
      parent=/product1/page, template=photos, sort=name WORKS (but only on children of current product). parent=page.rootParent ... parent=$page.rootParent ... parent=$page.rootParent parent=$parent ... parent=$parent1 When using a SELECT Input Field Type, the editing pages gives the fatal error "Unrecognized operator: $". parent=parent ... parent=. Returns an empty list How might I find child pages from the current "/product1/photos/ page"?
      Your inputs are appreciated. Thanks.
    • By Anders
      I want to allow full text search on my site. There is a very nice solution that comes right out of the box:
      $selector = "title|body~=$q, limit=50"; This works, but to make it even better I would want to give higher weight to pages where the search term occurs in the title, than if it just occurs in the body. After all, a page with the title "Wine from France" is probably the best match for the search "france wine". How do I accomplish this in ProcessWire?
      I can see three possible paths, but I am not very fond of any of them:
      Do a direct SQL query, circumventing the API, along these lines. But I would prefer to abstract away the database layout if at all possible. Use something like ElasticSearch, but to be honest that would be to complicated to set up and maintain in the long run. Make multiple lookups, first for matches in the title, then for matches in the body, and merge and sort in PHP. My suspicion is that this would get complicated quite quickly. For instance, how do you deal with a page that has two of the three search terms in the title and the third in the body? Is there a magic option four I should look into? Or are any of the above options better than the others? Any input is welcome!
    • By iipa
      Hi!
      I have two Page Reference fields: Category and Subcategory. Category is parent of Subcategory, and can have 0 to n Subcategories. Fields are selected by dropdown selection.
      I'm trying to achieve following logic:
      1. Select Category (obviously works)
      2. Change Subcategory options based on selected Category (this works)
      3. Hide the Subcategory field if Category has no Subcategories (to prevent weird dropdown with nothing to select)
      I have tried to investigate two possible alternatives to achieve step 3:
      A) Make dynamic condition into Subcategory selection's "Only visible if..." field
      B) Make a hook that fires when Category changes, then hides Subcategory field if Category has no children
      So far I haven't been successful in either. Conditions I've tried always lead to hidden field, and I haven't been able to find set up a hook that fires on field change.
      So here's the question (finally): Is there a way to alter field visibility in API, for example in ready.php or inside a hook? In API I could loop through categories, find the ones that have children and then make a selector based on their IDs.
    • By schwarzdesign
      I'm working on a news feed that will show the most recent news in a full teaser grid, and all older news as a simpler archive-type list view. My selectors so far:
      $news_full = $page->children("template=news, limit={$page->feed_count_full}"); $news_archive = $page->children("template=news, start={$page->feed_count_full}, limit=9999"); The $page->feed_count_full field controls how many items to show in the teaser grid (I've confirmed it contains the correct value, and the $news_full selector works as intended).
      This works, but I don't like the limit in the second selector. Unfortunately, if I leave it out (i.e. I only specify a start, not a limit), the start is ignored and I get all news instead. Not a big problem as we will never have more than 9999 news, but it still bothers me, as semantically speaking I don't want to set a limit in this case.
      Is this the intended behaviour of start/limit selectors? Is there a cleaner way to specify an offset (start selector) without a limit?
      ProcessWire Version 3.0.123
      Thanks!
    • By pwFoo
      I played with the Selectors object and would like to use it for a special use case...
      That is a custom Selectors object with dummy data converted to an php array to see the structure (Selectors object is a WireArray with "fields" added)
      Array ( [0] => Array ( [0] => Array ( [field] => seg1 [value] => val1 [not] => [group] => [quote] => [forceMatch] => ) [1] => Array ( [field] => seg2 [value] => val2 [not] => [group] => [quote] => [forceMatch] => ) ) )  
      But instead of "seg1" the field name is "field" with value "seg1" (= my field name).
       
      So I can't search the Selectors WireArray (= custom WireArray with added Selectors objects) with PW "find('seg1=val1')", Is there a way to search with "find()" or build a simple wrapper to make the elements searchable / filterable with find()?
×
×
  • Create New...