ez projects / sqliimport / forum / issues / error: invalid "countryname... / re: error: invalid "country...
You need to be logged in to post messages in the forums. New users may register here.
Member since: Posts: 13 |
Sunday 26 September 2010 4:57:33 pm I've created a custom class to hold ISO country names and codes and I'm trying to import an xml file with the data. I've tried a lot of different things to debug but I keep getting an error:
An error occurred during "countryimporthandler" import process : invalid "countryname" field for current SQLIContent. Country name is just a standard ez text line and I've checked and rechecked to ensure that I haven't misspelled any identifier names. I even tried using the article class instead and putting country name in the title but that didn't work either. Also from the print line I can see that the xml is being parsed correctly. I'd be really grateful for any help debugging. When this input handler is working I think it might be a good example because it imports the ISO country code list which is handy if you don't want to use the country datatype and would rather use objectrelation. Thanks! Fraser The XML File (sample) <ISO3166List xml:lang="en"> <ISO3166Entry> <CountryName>AFGHANISTAN</CountryName> <ISO3166Alpha2Code>AF</ISO3166Alpha2Code> </ISO3166Entry> <ISO3166Entry> <CountryName>ÅLAND ISLANDS</CountryName> <ISO3166Alpha2Code>AX</ISO3166Alpha2Code> </ISO3166Entry> <ISO3166Entry> <CountryName>ALBANIA</CountryName> <ISO3166Alpha2Code>AL</ISO3166Alpha2Code> </ISO3166Entry> </ISO3166List> The INI Override [ImportSettings] AvailableSourceHandlers[]=countryimporthandler [countryimporthandler-HandlerSettings] Enabled=true Name=Country XML Import Handler ClassName=SQLICountryImportHandler Debug=enabled DefaultParentNodeID=469 StreamTimeout= xmlFile=C:/<ezRoot>/extension/issat/stubs/iso3166list.xml The Import Handler <?php /** * File containing demo import handler SQLIRSSImportHandler * @copyright Copyright (C) 2010 - SQLi Agency. All rights reserved * @licence http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2 * @author Jerome Vieilledent * @version 1.1.0 * @package sqliimport * @subpackage sourcehandlers */ class SQLICountryImportHandler extends SQLIImportAbstractHandler implements ISQLIImportHandler { protected $rowIndex = 0; protected $rowCount; protected $currentGUID; /** * Constructor */ public function __construct( SQLIImportHandlerOptions $options = null ) { parent::__construct( $options ); $this->remoteIDPrefix = $this->getHandlerIdentifier().'-'; $this->currentRemoteIDPrefix = $this->remoteIDPrefix; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::initialize() */ public function initialize() { $xmlFile = $this->handlerConfArray['xmlFile']; $xmlOptions = new SQLIXMLOptions( array( 'xml_path' => $xmlFile, 'xml_parser' => 'simplexml' ) ); $xmlParser = new SQLIXMLParser( $xmlOptions ); $this->dataSource = $xmlParser->parse(); } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::getProcessLength() */ public function getProcessLength() { if( !isset( $this->rowCount ) ) { $this->rowCount = count( $this->dataSource->ISO3166Entry ); } return $this->rowCount; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::getNextRow() */ public function getNextRow() { if( $this->rowIndex < $this->rowCount ) { $row = $this->dataSource->ISO3166Entry[$this->rowIndex]; $this->rowIndex++; } else { $row = false; // We must return false if we already processed all rows } return $row; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process() */ public function process( $row ) { // $row is a SimpleXMLElement object $this->currentGUID = $row->ISO3166Alpha2Code; $contentOptions = new SQLIContentOptions( array( 'class_identifier' => 'isocountryentry', 'remote_id' => (string)$row->ISO3166Alpha2Code ) ); print (string)$row->CountryName; $content = SQLIContent::create( $contentOptions ); $content->fields->countryname = (string)$row->CountryName; $content->fields->alpha2code = (string)$row->ISO3166Alpha2Code; // Now publish content $content->addLocation( SQLILocation::fromNodeID( $this->handlerConfArray['DefaultParentNodeID'] ) ); $publisher = SQLIContentPublisher::getInstance(); $publisher->publish( $content ); // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called // @see SQLIContent::__destruct() unset( $content ); } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::cleanup() */ public function cleanup() { // Nothing to clean up return; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::getHandlerName() */ public function getHandlerName() { return 'Country Import Handler'; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::getHandlerIdentifier() */ public function getHandlerIdentifier() { return 'countryimporthandler'; } /** * (non-PHPdoc) * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::getProgressionNotes() */ public function getProgressionNotes() { return 'Currently importing : '.$this->currentGUID; } } |
|
Member since: Posts: 98 |
Sunday 26 September 2010 9:19:48 pm Hi Fraser
This error actually comes from an exception thrown when you want to access to an invalid content field (not present in the content object data map). I can see 2 causes for your problem : - You misspelled the attribute identifier (countryname), but you tell me that you double-checked this - You might have de-synchronized objects from their content classes (see issue #14307 - http://issues.ez.no/IssueView.php?Id=14307). If your are sure that the attribute identifier is correct, try to check for missing object attributes as described in the issue above. My Blog (french) : http://www.lolart.net |
|
Member since: Posts: 13 |
Monday 27 September 2010 11:13:58 pm Hi Jerome,
Thanks for the suggestions. Unfortunately I'm still having problems. I installed ezscriptmonitor, edited the class and ran ezscriptmonitor to synchronize the attributes. Now I'm getting an error: Call to member function attribute() on a non-object. I get this error or the invalid field error every time, even for the example rssimporthandler. Yesterday I did get the example working, but then it stopped for some reason. I tried synching the attributes on the article class and still no luck. When it did work for the example it was awesome! I'd really love to get this working because I need a quick way to upload a lot of content objects. Any other suggestions? Cheers, Fraser |
|
Member since: Posts: 98 |
Monday 27 September 2010 11:32:02 pm Hmm, this is really strange... What do your logs say (error.log, sqliimport-error.log) ?
Did you try the script attached to issue I indicated ? My Blog (french) : http://www.lolart.net |
|
Member since: Posts: 13 |
Tuesday 28 September 2010 10:26:17 am The SQLIImport log just has the same message, that the field is invalid. The error.log file just has a bunch of template override errors (can't find the template file) but I don't think that's related.
I didn't try the script indicated in the post as I had a bit of trouble getting it to run (autoload error). But I did install the ezscriptmonitor extension mentioned as a fix for the same issue. It successfully ran the class synchronization on all the classes I've tried to import too but it didn't help. I'll try to install a clean version of the extension and try the example again. One thing I have discovered is that the non object error seems to go away after clearing all the caches. Thanks, Fraser |
|
Member since: Posts: 7 |
Wednesday 10 November 2010 11:07:06 am Hello
I have the same message and I found that the problem is... the accents ! When I remove them the script run without error... I tried utf8_encode, html_entities, htmlspecialchars, etc... and nothing works !!! Any idea ? Tahnks |
|
Member since: Posts: 98 |
Monday 29 November 2010 5:07:45 pm Hi Solène
Sorry for the delay of my response... Can you please give us a code snippet causing the error (XML + PHP handler) ? Is your XML UTF8 encoded ? Thanks My Blog (french) : http://www.lolart.net |
|
Member since: Posts: 98 |
Tuesday 17 January 2012 4:01:24 pm Hello Fraser
Do you have database Master/slave configured in eZ Publish ? If so, this certainly comes from here... I just resolved a similar case by doing so. Cheers ! My Blog (french) : http://www.lolart.net |
You need to be logged in to post messages in the forums. New users may register here.