- Issue created by @emptyvoid
- 🇺🇸United States emptyvoid
While technically the listed patch is for the 2.x branch applying it to the 3.x branch suppresses the error.
https://www.drupal.org/files/issues/2023-01-26/3336646-2.patch →
- Assigned to mohd sahzad
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 6:46am 5 December 2023 - last update
about 1 year ago 425 pass I'm on
Drupal Version: 10.2.0
Facets 2.0.6and after updating to
PHP 8.2.13 (I also tested with PHP 8.3 -> getting the same results as PHP 8.2)I got multiple deprecated function messages
"Deprecated function: Creation of dynamic property Drupal\facets\Result\Result::$transliterateDisplayValue is deprecated in Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor->sortResults() (line 72)..."
I installed patch fexed-transliterateDisplayValue-15345798.patch
but did not work - composer update was failing to apply the patch, since the sortResults() function in Facets 2.0.6 version is different than the one in the patch (the "get()" function is not defined)This is my current 'sortResults' function defined in "DisplayValueWidgetOrderProcessor"
/** * {@inheritdoc} */ public function sortResults(Result $a, Result $b) { // Get the transliterate values only once. if (!isset($a->transliterateDisplayValue)) { $a->transliterateDisplayValue = $this->transliteration->removeDiacritics($a->getDisplayValue()); } if (!isset($b->transliterateDisplayValue)) { $b->transliterateDisplayValue = $this->transliteration->removeDiacritics($b->getDisplayValue()); } // Return the sort value. if ($a->transliterateDisplayValue == $b->transliterateDisplayValue) { return 0; } return strnatcasecmp($a->transliterateDisplayValue, $b->transliterateDisplayValue); }
so I tweaked the #5 patch (removing the get() function and make it look like:
- * {@inheritdoc} - */ + * {@inheritdoc} + */ public function sortResults(Result $a, Result $b) { // Get the transliterate values only once. - if (!isset($a->transliterateDisplayValue)) { - $a->transliterateDisplayValue = $this->transliteration->removeDiacritics($a->getDisplayValue()); + $transliterateValueA = $a->transliterateDisplayValue; + if (!$transliterateValueA) { + $transliterateValueA = $this->transliteration->removeDiacritics($a->getDisplayValue()); + $a->set('transliterateDisplayValue', $transliterateValueA); } - if (!isset($b->transliterateDisplayValue)) { - $b->transliterateDisplayValue = $this->transliteration->removeDiacritics($b->getDisplayValue()); + + $transliterateValueB = $b->transliterateDisplayValue; + if (!$transliterateValueB) { + $transliterateValueB = $this->transliteration->removeDiacritics($b->getDisplayValue()); + $b->set('transliterateDisplayValue', $transliterateValueB); } // Return the sort value. - if ($a->transliterateDisplayValue == $b->transliterateDisplayValue) { - return 0; + if ($transliterateValueA == $transliterateValueB) { + return 0; } - return strnatcasecmp($a->transliterateDisplayValue, $b->transliterateDisplayValue); + + return strnatcasecmp($transliterateValueA, $transliterateValueB); } }
by doing so, I was able to successfully install the patch through 'composer update'
however, this did not fix the deprecated function message; getting
Deprecated function: Creation of dynamic property Drupal\facets\Result\Result::$transliterateDisplayValue is deprecated in Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor->sortResults() (line 75 ...
- last update
about 1 year ago Patch Failed to Apply - 🇺🇸United States emptyvoid
created a new patch with some missing elements for the results class..
But it looks like I can't upload patches anymore so.. - last update
12 months ago Patch Failed to Apply - last update
12 months ago Patch Failed to Apply - 🇺🇸United States emptyvoid
Re-rolled patch to be based on the root of the module.
- last update
12 months ago 149 pass, 61 fail The last submitted patch, 12: facets-3-beta-3406085-2024-10-10.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- 🇪🇸Spain aleix
Adding new patch with proper CS and resultInterface new methods, for 3.0.0-beta1 .
- last update
11 months ago PHPLint Failed - last update
11 months ago 424 pass, 2 fail - last update
11 months ago 424 pass, 2 fail - 🇫🇷France MacSim
Isn't this issue a duplicate of https://www.drupal.org/project/facets/issues/3336646 🐛 PHP 8.2 compatibility for the 2.0.x branch Fixed ?
Updating patch from #14 was getting below error
Error: Cannot access protected property Drupal\facets\Result\Result::$termWeight in Drupal\facets\Plugin\facets\processor\TermWeightWidgetOrderProcessor->sortResults() (line 91 of modules/contrib/facets/src/Plugin/facets/processor/TermWeightWidgetOrderProcessor.php).
- last update
10 months ago Patch Failed to Apply - 🇬🇧United Kingdom fonant
Patch #18 works for me to stop the watchdog logs filling up with deprecation warnings. Thanks @gurvindersingh!
- 🇧🇪Belgium borisson_ Mechelen, 🇧🇪
Hard disagree that this should be changed to setters/getters. Especially if the properties stay public.
PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines → state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty, especially the name of the module is not helpful at all.Can we add 2 branches, one for 2.x and one for 3.x?
- 🇺🇸United States joshmiller Indianapolis, Indiana, USA
Chiming in here that this error, unnoticed by our team, took down urban.org briefly a few weeks ago when we updated to PHP 8.2.
Whatever the fix is, we're going to test out this patch, and we will need something to resolve this error.
How did this take down our elite Pantheon site? It eventually filled up our database with almost 500 GB of watchdog entries with thousands of warnings per record per user.
- 🇺🇸United States jkwilson
Following. Same issue after moving to PHP 8.2: watchdog logs filled up the server and briefly took the site down. Have applied patch #18. More thanks @gurvindersingh!
- 🇹🇭Thailand Nick Hope
#18 works for me. PHP 8.3.2 (DDEV). Drupal 10.2.6. Facets 3.0.0-beta1.
- 🇸🇬Singapore clairero
Patch #18 is works for me too. I'm running Drupal 10.2.4 with PHP 8.2.18. Thanks @gurvindersingh!
- 🇮🇳India Anita verma
I am unable to add Facets and facing Deprecated php error. I applied Patch #18 it is works to me. I'm running Drupal 10.2.4 with PHP 8.2.
- Status changed to Needs review
7 months ago 7:02am 8 June 2024 - First commit to issue fork.
- Status changed to Postponed: needs info
6 months ago 5:53am 25 June 2024 - 🇫🇮Finland sokru
Isn't this duplicate of 📌 PHP 8.2 compatibility Fixed ? At least based on the issue summary and (failing) MR, this issue should be closed as duplicate.
- 🇧🇪Belgium fernly
Creation of dynamic properties is deprecated since PHP 8.2 and will throw a fatal error as from PHP 9.0.
You can let the class opt in by using the #[\AllowDynamicProperties] attribute as a temp fix.The same notice is thrown for
Drupal\facets\Result\Result::$termWeight
. - Status changed to Needs work
4 months ago 7:04pm 29 August 2024 - 🇺🇸United States mile23 Seattle, WA
Can confirm that this issue still exists for 3.0.0-beta1.
% ddev composer show drupal/facets | grep versions versions : * 3.0.0-beta1
The workaround is don't show deprecation errors to users in production. :-)
I'm not very familiar with the code for this module, but it looks like the solution in #28 is about right.
- Status changed to Closed: duplicate
4 months ago 5:31am 30 August 2024 - 🇫🇮Finland sokru
@mile23: Latest release 3.0.0-beta1 is from 2022, the duplicate issue 📌 PHP 8.2 compatibility Fixed was committed to 3.0.x branch on 2023. So you should either use dev-branch or pick the patch for 3.0.0-beta1 from mentioned issue.
The maintainers should create a new release for Facets
- 🇮🇳India ajit dalal
Adding duplicate variable with 2.x latest version
+ /**
+ * The facet transliterate display value.
+ *
+ * @var string
+ */
+ protected $transliterateDisplayValue;
+
+ /**
+ * The term weight.
+ *
+ * @var int
+ */
+ protected $termWeight;
+