Open adrianbj opened 4 years ago
FYI - here is the block of code from the RequestInfo panel that is the trigger of the problem: https://github.com/adrianbj/TracyDebugger/blob/baa07b186f3ac92e9062ec9244ff89d040961b6d/panels/RequestInfoPanel.php#L109-L119
I can confirm this problem, thx for reporting!
@ryancramerdesign - any chance of taking a look at this please. I've tried to code a workaround in Tracy without any success - I think this needs to be fixed in the PW core.
@ryancramerdesign - this also affects modifying options as well. I am also seeing SQL integrity violations which might also be related to this. Can you at least let me know if you can or can't reproduce please?
@adrianbj There have been some changes in the getExportData() method, could you verify if this issue still persists?
I am still seeing that error stack posted above.
Note that initially, $value is null
before it finally becomes the correct string.
I can't replicate this, unfortunately. I'm dumping value, but get this when I create a new field and save it:
After adding another option and saving it again:
Please make sure this option is checked in Tracy's settings.
Aha, now I can replicate the null value, but I still don't get any errors. The question is why is there null in the first place.
I know where null is coming from and fixing that would be easy, but the main issue remains...
It looks like calling $field->getExportData() from the request panel is triggering getConfigInputfields() in SelectableOptionConfig.php which in turn calls process() method, so the process() method is called twice. A warning about deleting options is issued because the post request for the _options
is the same (and not null), but the data in the database is not. For example, when you enter option One and submit the form, it's saved in the database as 1=One (option gets an ID). As both values differ, this is an indication that you want to delete the option.
So, how to solve this? Don't know for sure, but looks like processing a form (post values) inside getConfigInputfields() is causing troubles. I fixed this like this, in process() method:
replaced
if(!is_null($value)) {
// _options has been posted
with
if(!is_null($value) && $session->get($ns, 'processed') != '1') {
// _options has been posted
$session->set($ns, 'processed', '1');
and
} else {
// options not posted, check if there are any pending session activities
with
} else {
// options not posted, check if there are any pending session activities
$session->remove($ns, 'processed');
This is most likely not the correct way, but it demonstrates the issue - moving the process() call out of getConfigInputfields() would be better. I hope it helps, @ryancramerdesign
Regarding null value, I added if($input->post($key) === null) continue;
before $valuesPerLanguage[$language->id] = $input->post($key);
in process() method.
@ryancramerdesign, could you please take a look at this issue? It's been so long that I forgot about it and rediscovered it all over again. The issue would need to be solved before this request can be viable.
Short description of the issue
@ryancramerdesign - this is a weird one. Originally reported by @Toutouwai here: https://github.com/adrianbj/TracyDebugger/issues/47
When Tracy's RequestInfo panel is loaded, you get a warning about deleting options when adding options to a new Select Options field that does not yet have any options.
Turns out it's because the RequestInfo panel calls
$field->getExportData()
and if I remove that call, the problem goes away.Optional: Screenshots/Links that demonstrate the issue
For some reason on my production servers I see the same issue as @Toutouwai, but on my local dev, I actually get this error stack:
Basically the issue seems to be that calling
$field->getExportData()
before / during the setting of the selectable options messes with$deletedOptionIDs
, which on quick inspection is originally coming from thearray_merge()
here: https://github.com/processwire/processwire/blob/51629cdd5f381d3881133baf83e1bd2d9306f867/wire/core/Field.php#L457-L460Please let me know if there is anything additional we can provide, but if you follow the steps in @Toutowai's screencast above, you should see either the described behavior, or the error in the Tracy debug bar.