Attribute Keys do not get assigned to a set when using CIF during a package installation

Permalink 4 0 Browser Info Environment
I am using the CIF (Concrete Interchange Format) to install my custom package. During the installation, I am creating serveral new attributes of category collection. After creating them, I want to assign them to an attribute set.

I am using the same code as described here:

<?xml version="1.0"?>
<concrete5-cif version="1.0">
      <attributekey handle="event_location" name="Event Ort" package="jw_events" searchable="1" indexed="1" type="text" category="collection">
         <type placeholder="Bitte Event Ort eingeben" />
        <attributeset handle="jw_events" name="JW Events" package="jw_events" locked="0" category="collection">
            <attributekey handle="event_location"/>

The installation of the package works so far, the attributes get created, but the always end up, not being in the set, but just being in no set at all..

Status: New
View Best Answer
Xianghar replied on at Best Answer Permalink Reply
This is because attribute keys get cached for the same request.
If an attribute is installed, it is first testet with AbstractStandardCategory->getAttributeKeyByHandle(), if it is installed. This returns null, and this null is cached for the rest of the request, so all subsequent calls to getAttributeKeyBHandle by the import routine for the set also returns null instead of the key object for the newly installed attribute.

A workaround is:
Split your xml into two files.
The first file contains all attribute keys.
The second file contains the attribute set.
Flush the cache between installing these files.

Code in your package controller would be like this.

private function installXML() {
janwidmer replied on at Permalink Reply
Thanks, works perfectly
jero replied on at Permalink Reply
Thanks for posting that workaround - and the link from the documentation that brought me here.

concrete5 Environment Information

# concrete5 Version
Core Version - 8.4.3
Version Installed - 8.4.3
Database Version - 20180716000000

# concrete5 Packages
Block Designer (3.2.0), Block Designer Pro (3.0.0), Fileset Attribute (1.1), JW Gallery (1.13), JW News (1.0.2), Migration Tool (0.9.0), Page Selector Attribute (2.0), ThemeTsv (1.00)

# concrete5 Overrides

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software

# Server API

# PHP Version

# PHP Extensions
apcu, bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dba, dom, exif, fileinfo, filter, ftp, gd, geoip, gettext, gmp, gnupg, hash, iconv, imagick, imap, intl, jsmin, json, ldap, libxml, mailparse, mbstring, mcrypt, mongodb, mysqli, mysqlnd, odbc, openssl, pcntl, pcre, PDFlib, PDO, pdo_dblib, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, readline, recode, Reflection, scrypt, session, SimpleXML, snmp, soap, sockets, SPL, sqlite3, ssh2, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, yaml, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 16M
upload_max_filesize - 16M
ldap.max_links - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 4000
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36