Jump to content

Problems with multiple repeaters


root
 Share

Recommended Posts

Hello everybody,

I want to update my website.

Currently there is a repeater for content paragraphs containing a title, content and a css class. This works for 2 years now without any problems.

I now want to add another repeater for examples that will be rendered as a bootstrap accordion.

That does not work. It seems like two (or maybe more) repeaters lead to problems:

- content is not saved anymore (regardless if it is inside or outside a repeater) - silently (thumbs up)

- no error message or warning is raised

- nothing is logged

- it simply does not save the data :)

If I remove a repeater, everything works again. If I add it again, the problem appeary again.

I'm using Multi-Language Fields and Multi-Language URLs in Processwire 2.6.1.

It works with non-translated field and two repeaters but not if at least one translated field is used in both repeaters if no other translated fields are used.

It happens also if only one repeaters contains translated fields but when other translated fields are used within the template.

Sometimes I see a line in apache's error log:

[Thu Jun 25 18:10:14.864233 2015] [:error] [pid 5692] PHP Notice:  Undefined index: id in /blah/wire/core/Fields.php on line 665

Is this a bug? What can I do to fix it?

Regards from Germany,

Fred

Link to comment
Share on other sites

Sure:

The machine is an i5 with 16 GB of RAM running Ubuntu 15.04 with apache.

PHP version:

$ php --version
PHP 5.6.4-4ubuntu6 (cli) (built: Apr 17 2015 15:47:51) 
Copyright © 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright © 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright © 1999-2014, by Zend Technologies
 
Apache version:
$ apache2 -v
Server version: Apache/2.4.10 (Ubuntu)
Server built:   Mar  9 2015 11:53:48
 
MySQL version:
5.6.24
 
I'm using the following modules:
ProcessPageSearch 106 Page Search
SystemUpdater 10 System Updater
InputfieldSelector 24 Selector
FieldtypeTextLanguage 100 Text (Multi-language)
FieldtypePageTitleLanguage 100 Page Title (Multi-Language)
LanguageSupport 103 Languages Support
LanguageTabs 111 Languages Support - Tabs
LanguageSupportFields 100 Languages Support - Fields
LanguageSupportPageNames 9 Languages Support - Page Names
FieldtypeTextareaLanguage 100 Textarea (Multi-language)
PageRender 103 Page Render
MarkupPageArray 100 PageArray Markup
AdminThemeDefault 13 Default
JqueryUI 195 jQuery UI
JqueryTableSorter 221 jQuery Table Sorter Plugin
JqueryCore 183 jQuery Core
PagePermissions 105 Page Permissions
FieldtypeFieldsetOpen 100 Fieldset (Open)
FieldtypeTextarea 104 Textarea
FieldtypeFile 104 Files
FieldtypeFieldsetTabOpen 100 Fieldset in Tab (Open)
FieldtypePassword 101 Password
FieldtypeCheckbox 101 Checkbox
FieldtypeImage 101 Images
FieldtypeText 100 Text
FieldtypeFieldsetClose 100 Fieldset (Close)
FieldtypeFloat 105 Float
FieldtypeDatetime 104 Datetime
FieldtypePageTitle 100 Page Title
FieldtypeModule 101 Module Reference
FieldtypeEmail 100 E-Mail
FieldtypeURL 100 URL
FieldtypePage 102 Page Reference
FieldtypeRepeater 101 Repeater
EmailObfuscation 103 Email Obfuscation (EMO)
35 modules loaded / 69 not loaded
 
I started the page two years ago and regularly updated to the current stable version. To do that is simply replaced everything under the wire/ directory.
 
I could supply a database dump via email, too.
 
Are there any information I could give you as well?
 
 
Thanks in advance,
 
Fred
Link to comment
Share on other sites

Today I made a fresh installation of 2.6.1. I recreated all fields and templates. The error occurs again so it is perfectly reproducable and it looks like a bug.

I also realized that "Setup>Logs" did not appear in my updated installation.

Link to comment
Share on other sites

I did some more investigation on the problem. After removing the second repeater I am not able to insert more than two repeated Items in the first repeater. The first two items are not editable or deletable after trying to insert a third one.

Link to comment
Share on other sites

Hi Macrura,

there are javascript console errors in chrome but not in firefox. The error occurs in firefox, too.

Chrome says:

Uncaught Error: "create" can only be used in extension processes. See the content scripts documentation for more details.

chromeHidden.onLoad.addListener.apiDefinitions.forEach.apiDef.functions.forEach.apiFunctionextensions/schema_generated_bindings.js:418

(anonymous function)

But I think this is not the problem.

I actually found something strange:

If saving works /page/edit/?id=1042 is called with the formular data as payload answered by a 301 http response (moved permanently) code that redirects to /page/edit/?id=1042&s=1

If it does _not_ work, /page/edit/?id=1042 is requested with the payload but it is answered with 200 http response (ok).

What may lead to this misbehaviour?

I also found out that one repeater is enough and that it does not happen on every page. I will deeper investigate the encoding of the payload now.

And I will also check PageTable.

Thank you.

Regards from Germany,

Fred
Link to comment
Share on other sites

The POST payload is mime multipart encoded and looks "normal" in every case. Maybe there is a situation that skippes the saving and leads to a http 200 response.

Who can help?

How can I debug that?

Link to comment
Share on other sites

So i think you already tested this by using a clean install, but just in case want to point out to replace the entire wire directory when upgrading, and also to be safe, replace your index.php, and your .htaccess file (but with .htaccess, make sure to compare in case you have some specific rules for your site there).

I think your problem may be related possibly to the multiple repeaters, and possibly specific to the fields you are using in those repeaters.

it's definitely more reliable to go with the pagetables instead of the repeaters, especially if this solves the issue.

Did your 2nd repeater use a ckeditor?

Link to comment
Share on other sites

i think you may have just hit upon a situation where you are using multi-language and repeaters, and it's just one of those rare cases where things don't cooperate.

I don't use multi-language at all, and i don't have time/resources to test, but you should keep an eye on the js/network consoles when you click save and report any errors.

I don't think repeaters were ever designed/tested extensively with extreme scenarios of multi-lingual fields, and ck editor, and multiple instances of a repeater;

Many developers have migrated repeater usage to pagetables at this point, except in some simple use cases where it is more convenient to see the fields inline;

if your use case allows it, see if you can migrate to pagetable and if this is a stable solution.

if you believe you have discovered a real bug, you can submit an issue Github;

I would plan on waiting 4-6 weeks or more for your bug report to be addressed, which is why if you can discover a work around, that would be best.

Link to comment
Share on other sites

I managed to replace Repeaters by PageTables. This was easily done.

But now I had another problem again:

When I wanted to store my plain html examples (these are coding examples for Python code generated by Sphinx with syntax highlighting) the html is not stored.

The field is translated and does not use ckeditor.

And again the html status code is 200 and not 301 and no errors are logged and I don't see any javascript errors on the console.

The html snipped that does not save is:

<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="gp">... </span>        <span class="n">xxx</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">xxx</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">serial_number</span> <span class="o">=</span> <span class="n">xxx</span><span class="p">(</span><span class="n">pattern</span><span class="o">=</span><span class="s">"[A-Z]{4}-[0-9]{4}"</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="mi">9</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">"AAAA-0000"</span><span class="p">)</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">hardware_type</span> <span class="o">=</span> <span class="n">xxx</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

If I save the upper or lower parts it works.

It is reproducable in Chrome and Firefox on Linux. Maybe this is the same problem like before?

What is the problem here?!

Link to comment
Share on other sites

I made the TextArea field a non translated and when I try to save the snippet above I get a red error bar on top:

"This request was aborted because it appears to be forged."

The rest of the page includes the menu but no content.

What's up here!? Why is this error not visible in translated fields?

Link to comment
Share on other sites

@root based on this and the other thread, I'm pretty certain that something external (whether Apache module, configuration, or PHP setting) is interfering with the POST requests on your server. Your repeaters scenario should be just fine as is, so I don't think that's the problem. 

You mentioned that you submitted the form, and at one point got a 200 rather than a 301. That indicates that most likely PW didn't detect any POST data at all, though there's something you can do to test. Please enable debug mode (/site/config.php, $config->debug=true), then reproduce that situation where you get a 200 after submitting the form, and no data saved. While on that screen, scroll to the bottom and click on $input->post in the debug accordion. Examine the raw contents of the POST data there. Look for truncated data. If you don't see an $input->post then that means there literally was no POST data at all. At that point I would take PW out of the picture and start experimenting with POST data outside of PW to see if that makes it easier to isolate what is interfering with it. 

Link to comment
Share on other sites

I found it:


 


It seems that on Ubuntu 15.04 (and maybe older versions) the newly shipped libapache2-mod-php5filter module somehow truncates the $_POST data.


 


I removed it and installed libapache2-mod-php5.


 


Now it works again.


 


THAT IS NOT COOL, UBUNTU!   >:D


 


If you have the same problem, run (as root):



apt-get remove libapache2-mod-php5filter

libapache2-mod-php5 will be installed automatically.


 


Thank you for your help. Processwire works perfectly and confidence is there again but not for Ubuntu .. Sorry for my angry post.


 


Regards,


 


Fred

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...