Jump to content

Strange behavior exporting fields


NorbertH
 Share

Recommended Posts

I have trouble exporting fields via the buildin export. 

For example when i export a single field  i get:

{
    "bestellung_status_name": {
        "id": 194,
        "type": "FieldtypeText",
        "flags": 0,
        "name": "bestellung_status_name",
        "label": "Status Intern",
        "textformatters": [
            "TextformatterEntities"
        ],
        "collapsed": 0,
        "minlength": 0,
        "maxlength": 100,
        "showCount": 0,
        "size": 0,
        "pattern": "[a-z\\A-Z\\(\\)]+",
        "showIf": "",
        "themeInputSize": "",
        "themeInputWidth": "",
        "themeOffset": "",
        "themeBorder": "",
        "themeColor": "",
        "themeBlank": "",
        "columnWidth": 100,
        "required": "",
        "requiredAttr": "",
        "requiredIf": "",
        "stripTags": "",
        "placeholder": ""
    }
}

exporting a secon single field i get :

{
    "bestellung_status_name_ext": {
        "id": 195,
        "type": "FieldtypeText",
        "flags": 0,
        "name": "bestellung_status_name_ext",
        "label": "Status Extern",
        "textformatters": [
            "TextformatterEntities"
        ],
        "collapsed": 0,
        "minlength": 0,
        "maxlength": 100,
        "showCount": 0,
        "size": 0,
        "pattern": "[a-z\\A-Z\\(\\)]+",
        "showIf": "",
        "themeInputSize": "",
        "themeInputWidth": "",
        "themeOffset": "",
        "themeBorder": "",
        "themeColor": "",
        "themeBlank": "",
        "columnWidth": 100,
        "required": "",
        "requiredAttr": "",
        "requiredIf": "",
        "stripTags": "",
        "placeholder": ""
    }
}

So far everything works fine .

When i try to export both fields together  i get only an error message :

Call to a member function getModuleInfo() on null 
File: .../wire/modules/Fieldtype/FieldtypeText.module:171

I added " bd($textformatter);" on line 170 to see whats wrong. so have a look at the screenshot i apended to this post.

 

Its perfectly possible that one textformater module got removed by accident while experimenting whith some textformaters but my question is how to fix this maybe somewhere in the DB and possibly what went wrong?

ProcessWire 3.0.120 © 2019
Apache/2.4.25 (FreeBSD) OpenSSL/1.0.2k mod_fcgid/2.3.9
PHP 7.1.2

   

 

Screenshot (1).png

 

Edit: After adding

if ($textformatter ===NULL) continue;

I can export my fields , as there arent any Textformater missing in the fields , i get a perfect result. but still there is one textformater whith a NULL value.  

 

 

Link to comment
Share on other sites

FeildtypeText.module  line 161 ff

		if($this->allowTextFormatters()) {

            $textformatters = $this->modules->find("className^=Textformatter");

            if(count($textformatters)) {

                $f = $this->modules->get('InputfieldAsmSelect');
                $f->setAttribute('name', 'textformatters');
                $f->label = $this->_('Text Formatters');

                foreach($textformatters as $textformatter) {
                    bd($textformatter);
                    $info = $textformatter->getModuleInfo();
                    $f->addOption($textformatter->className(), "$info[title]");
                }

                $f->setAttribute('value', is_array($field->textformatters) ? $field->textformatters : array());

                $f->description = $this->_('If you want to apply any automatic formatting to the field when it is prepared for output, select one or more text formatters above. If you select more than one, drag them into the order they should be applied.');
                $f->notes = $this->_('For plain text fields that will not contain HTML or markup, we recommend selecting the **HTML Entity Encoder** option above.');

                $inputfields->append($f);
            }
        }

As far as i understand this he fetches all  existing textformater modules for each field  and as you can see in the screenshot , the last one is NULL as you can see in the screenshot.

Link to comment
Share on other sites

Have you tried:

bd($textformatter, $field->name);

so you can see which one at the end there is returning null? If you know the field affected, you might be able to check which textformatters are assigned to the field and find the problem that way.

  • Like 2
Link to comment
Share on other sites

Hi again, problem solved(hopefully)

using

bd($textformatter, $field->name);

I found that always after the second field  the last element of $textformatters contained a NULL Element. 

Checking the name of the textformater i found that this always hapened  to this formatter "TextformatterOnly0To9"

After taking a really close look i found that the classname differed from the filename:
"TextformatterOnly0To9"
"TextformatterOnly0to9"

Its only a upper/lower case difference and PHP (as far as i know) normally does not care about that in classnames.

Changing this back lets me reproduce the issue. Still one thing i don't understand is the fact that exporting one field works perfect, i can't get the point why only fetching $textformatters a second time leads to this issue. Btw. i did not experience any other issues whith that wrong named classname  the textformater did what he was expected to do....     

  • Like 2
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

×
×
  • Create New...