Skip to content

Conversation

@chrisdavenport
Copy link
Contributor

@chrisdavenport chrisdavenport commented May 8, 2016

Under some circumstances a search for a word can result in a "PHP Fatal error: utf8_strpos: Offset must be an integer". This is because the floor function used to calculate the offset can sometimes return a float rather than an int.

Summary of Changes

The return value from the floor is now cast to an int to make sure that the offset (the 3rd argument) passed to JString::strpos, which becomes the offset argument to utf8_strpos, is always an int.

Testing Instructions

This may be tricky to replicate but this is how I encountered the problem in the first place...

  1. Fresh install of Joomla with the Testing sample data set (the last option on the list).
  2. Enable Smart Search and index the content.
  3. From the front-end, go to the Smart Search search component page.
  4. Enter "the" as the search term and click Search.

This should throw the error on one of the search results. For me it happened on "Modules" and "Sample Sites".

Apply this PR and repeat the test.

@chrisdavenport
Copy link
Contributor Author

One more thing: This might be PHP7-related. I don't have access to an earlier PHP release at the moment to test it, but it's strange that I haven't seen this issue until running on PHP7 for the first time.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10303.

@wilsonge wilsonge merged commit a0acdd7 into joomla:staging May 8, 2016
@wilsonge wilsonge modified the milestones: Joomla 4.0, Joomla 3.6.0 May 8, 2016
roland-d added a commit to roland-d/joomla-cms that referenced this pull request May 8, 2016
…leanup-installer-plugins

* 'staging' of https://github.com/joomla/joomla-cms:
  Smart Search: utf8_strpos: Offset must be an integer (joomla#10303)
  Removed an redundant else clause from JFeedParser::processElement (joomla#7961)
  CLEANING-JDataSet (joomla#7947)
  CLEANING-JAdapter (joomla#6679)
  Same  treatment as JArchiveBzip2 and JArchiveGzip (joomla#6515)
  Cleaning up JArchiveBzip2 (joomla#6495)
  Removed the nested conditional switch construct (joomla#6338)
  add edit tooltip to modules (joomla#10295)
  New installer plugins: remove the dot in the plugin name and other language review (joomla#10299)
@zero-24
Copy link
Contributor

zero-24 commented May 8, 2016

I have tested this item ✅ successfully on 4fb9192

👍


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10303.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants