Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
field_expression
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
field_expression
Commits
c47c0c4d
Commit
c47c0c4d
authored
1 year ago
by
Greg Boggs
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3447908
: Evaluating 1,000 breaks
parent
0ac9ebdb
No related branches found
No related tags found
1 merge request
!3
Resolve #3512141 "Drupal 11 readiness"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
src/Plugin/Field/FieldType/ExpressionItem.php
+4
-0
4 additions, 0 deletions
src/Plugin/Field/FieldType/ExpressionItem.php
src/Plugin/Field/FieldType/ExpressionItemTrait.php
+4
-0
4 additions, 0 deletions
src/Plugin/Field/FieldType/ExpressionItemTrait.php
with
9 additions
and
0 deletions
.gitignore
0 → 100644
+
1
−
0
View file @
c47c0c4d
.idea
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldType/ExpressionItem.php
+
4
−
0
View file @
c47c0c4d
...
@@ -167,6 +167,10 @@ class ExpressionItem extends FieldItemBase {
...
@@ -167,6 +167,10 @@ class ExpressionItem extends FieldItemBase {
// Evaluate the final expression
// Evaluate the final expression
$math
=
new
EvalMath
;
$math
=
new
EvalMath
;
$math
->
suppress_errors
=
$this
->
getSetting
(
'suppress_errors'
);
$math
->
suppress_errors
=
$this
->
getSetting
(
'suppress_errors'
);
// remove blank spaces because 1 000 will evaluate to zero instead of 1000
$expression
=
str_replace
(
' '
,
''
,
$expression
);
$value
=
$math
->
evaluate
(
$expression
);
$value
=
$math
->
evaluate
(
$expression
);
// Support debugging expressions with devel module
// Support debugging expressions with devel module
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldType/ExpressionItemTrait.php
+
4
−
0
View file @
c47c0c4d
...
@@ -146,6 +146,10 @@ trait ExpressionItemTrait {
...
@@ -146,6 +146,10 @@ trait ExpressionItemTrait {
$math
->
suppress_errors
=
$this
->
getSetting
(
'suppress_errors'
);
$math
->
suppress_errors
=
$this
->
getSetting
(
'suppress_errors'
);
foreach
(
$expressions
as
$expr
)
{
foreach
(
$expressions
as
$expr
)
{
if
(
$expr
!==
''
)
{
if
(
$expr
!==
''
)
{
// remove blank spaces because 1 000 will evaluate to zero instead of 1000
$expr
=
str_replace
(
' '
,
''
,
$expr
);
$result
=
$math
->
evaluate
(
$expr
);
$result
=
$math
->
evaluate
(
$expr
);
if
(
$result
==
false
)
{
if
(
$result
==
false
)
{
$result
=
0
;
$result
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment