Comments (8)
Sorry for the delay on that. See if this breaks the world:
--- a/system/ee/legacy/libraries/api/Api_channel_fields.php
+++ b/system/ee/legacy/libraries/api/Api_channel_fields.php
@@ -1537,8 +1537,10 @@ class Api_channel_fields extends Api {
$pfield_chunk = array();
$offset = 0;
$field_name = $prefix.$field_name;
+ $modifier = '';
+ $end = strpos($tagdata, LD.'/'.$field_name, $offset);
- while (($end = strpos($tagdata, LD.'/'.$field_name, $offset)) !== FALSE)
+ while ($end !== FALSE)
{
// This hurts soo much. Using custom fields as pair and single vars in the same
// channel tags could lead to something like this: {field}...{field}inner{/field}
@@ -1582,7 +1584,8 @@ class Api_channel_fields extends Api {
$pfield_chunk[] = $chunk_array;
}
- $offset = $end + 1;
+ $end = strpos($tagdata, LD.'/'.$field_name.$modifier.RD, $offset);
+ $offset = (int) $end + 1;
}
return $pfield_chunk;
from expressionengine.
I forgot all about this until now. I'll try to investigate this soon.
from expressionengine.
Took a stab and added this to my local copy of a large site and it's eventually running out of memory somewhere. I undo the change and everything returns to normal.
Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes)
edit: this is on a page that does not have any issues with tag pairs with similar prefixes, but it does have a lot of tag pairs in general (e.g. Bloqs fields)
from expressionengine.
Poo, thanks for testing. I'm having trouble getting that to happen on my end, would you be able to send me that template text?
from expressionengine.
Thanks for the assist, had some colliding variables that were causing an infinite loop. Here's a slightly modified diff:
--- a/system/ee/legacy/libraries/api/Api_channel_fields.php
+++ b/system/ee/legacy/libraries/api/Api_channel_fields.php
@@ -1537,14 +1537,17 @@ class Api_channel_fields extends Api {
$pfield_chunk = array();
$offset = 0;
$field_name = $prefix.$field_name;
+ $end = strpos($tagdata, LD.'/'.$field_name, $offset);
- while (($end = strpos($tagdata, LD.'/'.$field_name, $offset)) !== FALSE)
+ while ($end !== FALSE)
{
// This hurts soo much. Using custom fields as pair and single vars in the same
// channel tags could lead to something like this: {field}...{field}inner{/field}
// There's no efficient regex to match this case, so we'll find the last nested
// opening tag and re-cut the chunk.
+ $modifier = '';
+
if (preg_match("/".LD."{$field_name}((?::\S+)?)(\s.*?)?".RD."(.*?)".LD.'\/'."{$field_name}\\1".RD."/s", $tagdata, $matches, 0, $offset))
{
$chunk = $matches[0];
@@ -1563,8 +1566,8 @@ class Api_channel_fields extends Api {
$params = $match[1][$idx];
// Cut the chunk at the last opening tag
- $offset = strrpos($chunk, $tag);
- $chunk = substr($chunk, $offset);
+ $chunk_offset = strrpos($chunk, $tag);
+ $chunk = substr($chunk, $chunk_offset);
$chunk = strstr($chunk, LD.$field_name);
$content = substr($chunk, strlen($tag), -strlen(LD.'/'.$field_name.RD));
}
@@ -1582,7 +1585,8 @@ class Api_channel_fields extends Api {
$pfield_chunk[] = $chunk_array;
}
- $offset = $end + 1;
+ $end = strpos($tagdata, LD.'/'.$field_name.$modifier.RD, $offset);
+ $offset = (int) $end + 1;
}
return $pfield_chunk;
from expressionengine.
That fix didn't cause an infinite loop and the page loads fine for me, but I don't have a test case setup right now for the exact scenario reported (the similar prefixes), so I can't confirm that at the moment. I'll try to do that tonight.
from expressionengine.
Kevin, a co-worker just ran into this issue where the blocks were being duplicated as noted in the original report, and he just added your fix to EE and the issue is resolved. I think it's safe to say your patch is safe to merge.
If it helps, before your fix is applied, the tag pairs in the following order did work
{blocks_statistic}{/block_statistic}
{blocks_statistic_group}{/blocks_statistic_group}
But this tag pair order did not work
{blocks_statistic_group}{/blocks_statistic_group}
{blocks_statistic}{/block_statistic}
from expressionengine.
Thanks for trying this out! It's in for the next release.
from expressionengine.
Related Issues (20)
- 7.4 DP When Coilpack is present, upgrade screen does not load HOT 2
- RedactorX - Issue with initialising javascript HOT 4
- 7.4DP - RedactorX erases styling upon re-loading RTE content HOT 4
- 🐛 Bug Report: layout:var_name tag pair leaving stray tags when array has no value
- Issue rolling back upgrade from HOT 1
- 🐛 Bug Report: Branding image file url incorrect after site migration
- File upload field directory dropdown ordered by id rather than alpha
- File Grid - uploading multiple new images
- File Grid - Edit File icon going to Folder listing, not specific File details HOT 1
- Entries - Category filter - list as per Category structure HOT 1
- Member registration, custom member fields, type: select Dropdown
- Color of custom new role its not saved HOT 1
- CP performance issue with relationships in grids HOT 1
- SMTP providers - better support needed
- Entry screen: Sort doesn't stick when filter added/removed HOT 2
- Problem with quoted template code in an redactor field HOT 1
- {count} not incremented in variables pairs HOT 2
- Preflight fails if getFreeDiskSpace returns false
- Not all channels with the same fields and status show up in the "channel" option when editing a channel entry.
- {exp:member:custom_profile_data} gives PHP deprecation error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expressionengine.