[2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 666) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1264) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1289) Could not get table name for class: UserCommentFlags [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1840) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1336) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1341) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1438) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1361) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1573) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1584) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 618) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 621) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 661) PHP warning: Illegal offset type in isset or empty [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1594) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/xpdo.class.php : 1603) PHP warning: Illegal offset type [2018-09-28 17:29:34] (ERROR @ core_dev/xpdo/om/mysql/xpdomanager.class.php : 256) Could not create table SQL: CREATE TABLE () ENGINE=InnoDB ERROR: Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() ENGINE=InnoDB' at line 1 ) [2018-09-28 17:29:34] (ERROR in schemaToDatabase @ /var/www/cannacle/Oxg9v_core_dev/cache/includes/elements/modsnippet/224.include.cache.php : 44) Error: Could not generate Table/s!
<?xml version="1.0" encoding="UTF-8"?> <model package="Social" baseClass="xPDOObject" platform="mysql" defaultEngine="InnoDB" version="1.1"> <object class="UserCommentFlags" table="user_comment_flags" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="reason" dbtype="int" precision="1" phptype="integer" null="false" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="reviewed" dbtype="timestamp" phptype="timestamp" null="true" /> </object> <object class="UserCommentLikes" table="user_comment_likes" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" index="unique" /> <field key="liked_by" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="liked_on" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="id" name="id" primary="false" unique="true" type="BTREE" > <column key="item_id" length="" collation="A" null="false" /> </index> </object> <object class="UserFollowers" table="user_followers" extends="xPDOObject"> <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" /> <field key="list" dbtype="longtext" phptype="string" null="false" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> <object class="UserGroupAdmins" table="user_group_admins" extends="xPDOSimpleObject"> <field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="group_id" dbtype="int" precision="12" phptype="integer" null="false" /> <field key="moderate" dbtype="int" precision="1" phptype="integer" null="false" default="1" /> <field key="kick" dbtype="int" precision="1" phptype="integer" null="false" default="1" /> <field key="ban" dbtype="int" precision="1" phptype="integer" null="false" default="1" /> <field key="added" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="id" name="id" primary="false" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> <object class="UserGroups" table="user_groups" extends="xPDOSimpleObject"> <field key="owner_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="name" dbtype="varchar" precision="32" phptype="string" null="false" /> <field key="descrption" dbtype="int" precision="140" phptype="integer" null="false" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="privacy" dbtype="int" precision="2" phptype="integer" null="false" default="0" /> <index alias="id" name="id" primary="false" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> <object class="UserPostFlags" table="user_post_flags" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="reason" dbtype="int" precision="1" phptype="integer" null="false" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="reviewed" dbtype="timestamp" phptype="timestamp" null="true" /> </object> <object class="UserPostLikes" table="user_post_likes" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="liked_by" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="liked_on" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> </object> <object class="UserPostShares" table="user_post_shares" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="shared_by" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="shared_on" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> </object> <object class="UserPosts" table="user_posts" extends="xPDOSimpleObject"> <field key="owner_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="wall" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="type" dbtype="varchar" precision="32" phptype="string" null="false" default="wall" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="deleted" dbtype="timestamp" phptype="timestamp" null="true" /> <field key="content" dbtype="text" phptype="string" null="false" /> <field key="privacy" dbtype="int" precision="2" phptype="integer" null="false" default="0" /> <field key="flagged" dbtype="int" precision="11" phptype="integer" null="false" default="0" /> <field key="liked" dbtype="bigint" precision="20" phptype="integer" null="false" default="0" /> <index alias="id" name="id" primary="false" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> <object class="UserProfileFlags" table="user_profile_flags" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="reason" dbtype="int" precision="1" phptype="integer" null="false" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="reviewed" dbtype="timestamp" phptype="timestamp" null="true" /> </object> <object class="UserProfileLikes" table="user_profile_likes" extends="xPDOObject"> <field key="id" dbtype="bigint" precision="20" phptype="integer" null="false" index="pk" /> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="liked_by" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="liked_on" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> <object class="UserReplyFlags" table="user_reply_flags" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" /> <field key="user_id" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="reason" dbtype="int" precision="1" phptype="integer" null="false" /> <field key="created" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="reviewed" dbtype="timestamp" phptype="timestamp" null="true" /> </object> <object class="UserReplyLikes" table="user_reply_likes" extends="xPDOSimpleObject"> <field key="item_id" dbtype="bigint" precision="20" phptype="integer" null="false" index="unique" /> <field key="liked_by" dbtype="int" precision="11" phptype="integer" null="false" /> <field key="liked_on" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <index alias="id" name="id" primary="false" unique="true" type="BTREE" > <column key="item_id" length="" collation="A" null="false" /> </index> </object> <object class="UserStreams" table="user_streams" extends="xPDOObject"> <field key="owner_id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" /> <field key="following" dbtype="longtext" phptype="string" null="true" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="owner_id" length="" collation="A" null="false" /> </index> <index alias="owner_id" name="owner_id" primary="false" unique="true" type="BTREE" > <column key="owner_id" length="" collation="A" null="false" /> </index> </object> <object class="UserWalls" table="user_walls" extends="xPDOObject"> <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" /> <field key="username" dbtype="varchar" precision="64" phptype="string" null="false" /> <field key="privacy" dbtype="int" precision="2" phptype="integer" null="false" default="0" /> <field key="whitelist" dbtype="longtext" phptype="string" null="true" /> <field key="blacklist" dbtype="mediumtext" phptype="string" null="true" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="id" length="" collation="A" null="false" /> </index> </object> </model>
<?php $xpdo_meta_map['UserCommentFlags']= array ( 'package' => 'Social', 'version' => '1.1', 'table' => 'user_comment_flags', 'extends' => 'xPDOSimpleObject', 'tableMeta' => array ( 'engine' => 'InnoDB', ), 'fields' => array ( 'item_id' => NULL, 'user_id' => NULL, 'reason' => NULL, 'created' => 'CURRENT_TIMESTAMP', 'reviewed' => NULL, ), 'fieldMeta' => array ( 'item_id' => array ( 'dbtype' => 'bigint', 'precision' => '20', 'phptype' => 'integer', 'null' => false, ), 'user_id' => array ( 'dbtype' => 'int', 'precision' => '11', 'phptype' => 'integer', 'null' => false, ), 'reason' => array ( 'dbtype' => 'int', 'precision' => '1', 'phptype' => 'integer', 'null' => false, ), 'created' => array ( 'dbtype' => 'timestamp', 'phptype' => 'timestamp', 'null' => false, 'default' => 'CURRENT_TIMESTAMP', ), 'reviewed' => array ( 'dbtype' => 'timestamp', 'phptype' => 'timestamp', 'null' => true, ), ), );
[[FormIt?&hooks=`schemaParser,schemaToDatabase`]] <p style="padding-bottom:10px;">[[+std.response]]</p> <form name="stdForm" action="" method="post" class="form"> <label>Prefix <input type="text" name="stdPrefix" id="stdPrefix" value="[[+std.prefix]]"/></label> <label>Package <input type="text" name="stdPackage" id="stdPackage" value="[[+std.package]]"/></label> <input type="submit" name="makeItHappen" value="STD It!"/> </form>
<?php // Get the perameters passed by FormIt $parameters = $hook->getValues(); // Set variables for the passed perameters $packagename = $parameters['stdPackage']; // Set the modelpath for addPackage to use later $modelpath = MODX_CORE_PATH.'components/'.$packagename.'/model/'; // Set the filename of the schema from the package name $filepath = $modelpath.'schema/'.$packagename.'.mysql.schema.xml'; // Get the manager $manager = $modx->getManager(); // Get the generator $generator = $manager->getGenerator(); // Generate or update the class and map files $result = $generator->parseSchema($filepath,$modelpath); return $result;
<?php /* ----------------------------------------------------------------- * Extension: STD (Schema to Database) * ----------------------------------------------------------------- * Version: 1.0.0 * Since: September. 26, 2018 * Author: Aaron Kent <[email protected]> * License: GNU GPLv2 (or later) * * This will create database table/s for a Single Package * based on a schema file. * * schemaToDatabase * * @package schemaToDatabase * @subpackage schemaToDatabase snippet */ // Get the perameters passed by FormIt $parameters = $hook->getValues(); // Set variables for the passed perameters $prefix = $parameters['stdPrefix']; $packagename = $parameters['stdPackage']; // Set the modelpath for addPackage to use later $modelpath = MODX_CORE_PATH.'components/'.$packagename.'/model/'; // Set the filename of the schema from the package name $filename = $packagename.'.mysql.schema.xml'; // Set the package path for the XML file to object conversion $packagePath = $modelpath.'schema/'.$filename; // Set the object $xmlObj = simplexml_load_string(file_get_contents($packagePath)); // Get the manager $manager = $modx->getManager(); // Add the package for manager to use $modx->addPackage($packagename,$modelpath,$prefix); // Empty the output vriable $op = ''; // Iterate through the object created from the schema file foreach ($xmlObj->object as $object) { // Catch errors that occur with 'if !' check if (!$manager->createObjectContainer($object['class'])) { // Error control start $response = 'Error: Could not generate Table/s!'; $modx->log(modX::LOG_LEVEL_ERROR, $response, '', 'schemaToDatabase'); $modx->setPlaceholders( array( 'response' => $response, 'prefix' => $prefix, 'package' => $packagename, ), 'std.' ); // End error control, and return return false; } else { // Concat the output for display and logging $op .= 'created '.$object['table'].' - '; } } // Log passing result - for development only, remove in production $modx->log( modX::LOG_LEVEL_WARN, 'schemaToDatabase '.$op. ' tables for package: '.$packagename, '', 'schemaToDatabase' ); // Set passing response $response = 'STD '.$op.'the table/s for packagename: '.$packagename; // Set passing placeholders $modx->setPlaceholders( array( 'response' => $response.' Package:'.$package, 'prefix' => $prefix, 'package' => $packagename, ), 'std.' ); // Return return true;
This question has been answered by BobRay. See the first response.
It might help to look at the code at the end of this article.
As you've found, it's very difficult to debug stuff like this.
One method is to create a local install of MODX, move your code to a file where you instantiate MODX first, then step through the code in a debugger that's part of a good code editor like PhpStorm.
Another approach I usually use is to create the DB tables manually, use the script in the first link above to create the schema files, then modify them to include the object relationships and run the code again with $createSchema=false to create the class and map files.
Another thought: PHP 7.0 has some known problems, so upgrading it couldn't hurt.
[2018-09-29 16:43:12] (ERROR @ /home/m1chaelkent/public_html/rhythm.auction/core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct(): core/components/Social/model/schema/Social.mysql.schema.xml:40: parser error : Premature end of data in tag object line 39
[2018-09-29 16:43:12] (ERROR @ core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct(): eld key="owner_id" dbtype="int" precision="11" phptype="integer" null="false" /> [2018-09-29 16:43:12] (ERROR @ core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct(): ^ [2018-09-29 16:43:12] (ERROR @ core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct(): core/components/Social/model/schema/Social.mysql.schema.xml:40: parser error : Premature end of data in tag model line 2
[2018-09-29 16:43:12] (ERROR @ core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct(): eld key="owner_id" dbtype="int" precision="11" phptype="integer" null="false" /> [2018-09-29 16:43:12] (ERROR @ core/xpdo/om/xpdogenerator.class.php : 203) PHP warning: SimpleXMLElement::__construct():
if (empty(someFunction())) { }
$x = someFunction(); if (empty($x)) { }
$parameters = $hook->getValues(); $modx->log(modX::LOG_LEVEL_ERROR, "PARAMETERS: " . print_r($parameters, true));
$er = print_r($this->map); $this->log(xPDO::LOG_LEVEL_ERROR, $er);