Jump to content

Recommended Posts

Posted
Quote

Error: Exception: Unable to delete from 'field_mamo_length_ft' for field that doesn't exist in fields table (in /Applications/AMPPS/www/CC/wire/core/Fieldtype.php line 1133)

#0 [internal function]: ProcessWire\Fieldtype->___deletePageField(Object(ProcessWire\Page), Object(ProcessWire\Field))
#1 /Applications/AMPPS/www/CC/wire/core/Wire.php(374): call_user_func_array(Array, Array)
#2 /Applications/AMPPS/www/CC/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___deletePageFi...', Array)
#3 /Applications/AMPPS/www/CC/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\FieldtypeInteger), 'deletePageField', Array)
#4 /Applications/AMPPS/www/CC/wire/core/PagesEditor.php(1011): ProcessWire\Wire->__call('deletePageField', Array)
#5 /Applications/AMPPS/www/CC/wire/core/PagesEditor.php(1011): ProcessWire\FieldtypeInteger->deletePageField(Object(ProcessWire\Page), Object(ProcessWire\Field))
#6 /Applications/AMPPS/www/CC/wire/core/Pages.php(490): ProcessWire\PagesEditor->delete(Object(Proces

mamo_length_ft is not a field. I don't see it anywhere in the database neither. Where could this possibly be stemming from?

Posted

I have a cleanup file running before a file that sets up all the fields and templates, that includes the following:

foreach($fields->find('tags*=ccbo') as $f) $fields->delete($f);

When I comment it out, the field is created, yet I still get this error halting the script procession:

Quote

Error: Exception: Field may not be named 'mamo_length_ft' because it is already used by another field (in /Applications/AMPPS/www/CC/wire/core/Field.php line 540)

#0 /Applications/AMPPS/www/CC/wire/core/Field.php(227): ProcessWire\Field->setName('mamo_length_ft')
#1 /Applications/AMPPS/www/CC/wire/core/WireData.php(141): ProcessWire\Field->set('name', 'mamo_length_ft')
#2 /Applications/AMPPS/www/CC/site/modules/ImportShorthand.module(31): ProcessWire\WireData->__set('name', 'mamo_length_ft')
#3 /Applications/AMPPS/www/CC/site/setup/1_makes.inc(253): ProcessWire\ImportShorthand::newField(Array)
#4 /Applications/AMPPS/www/CC/site/setup/1_makes.inc(274): ProcessWire\makeModel()
#5 /Applications/AMPPS/www/CC/site/setup/setup.php(6): include('/Applications/A...')
#6 /Applications/AMPPS/www/CC/site/templates/home.php(5): include('/Applications/A...')
#7 /Applications/AMPPS/www/CC/wire/core/TemplateFile.php(268): require('/Applications/A...')
#8 [internal function]: ProcessWire\TemplateFile-

If I comment out the block of code creating it, the same error is displayed for the next field.

Posted

Apparently it comes from line 6 in this file (vessels.csv)

<?php  namespace ProcessWire;

$mmpid = wire('pages')->get('template.name=mamo_makes')->id;
importCSV(__DIR__.'/manufacturers.csv', 'mamo_manufacturer', $mmpid);
importCSV(__DIR__.'/models.csv', 'mamo_model', 0, $mmpid);
importCSV(__DIR__.'/vessels.csv', 'boat_vessel', wire('pages')->get('template.name=boat_index')->id, 0);

function importCSV($filepath, $template, $parent_id = null, $grandparent_id = null) {
  $csv = array_map('str_getcsv', file($filepath));
  array_walk($csv, function(&$a) use ($csv) {
    $a = array_combine($csv[0], $a);
  });
  array_shift($csv); # remove column header
  //echo '<pre>'; print_r($csv); echo '</pre>';
  foreach($csv as $r) {
    $p = new Page();
    $p->name = wire('sanitizer')->pageName($r['title']);
    $p->template = $template;
    if($parent_id !== 0||null) {
      $p->parent_id = $parent_id;
    } elseif($parent_id == 0||null) {
      //echo $r['parent'].' ';
      $parent = wire('sanitizer')->pageName($r['parent']);
      $parent = str_replace('---','-',$parent);
      //echo $parent.' ';//echo $grandparent_id.'gp ';
      $parent = wire('pages')->get('title=' . $r['parent'] . ', parent_id=' . $grandparent_id)->id;
      //echo $parent.'p ';
      $p->parent_id = $parent;
      unset($r['parent']);
    }
    $p->save();
    foreach($r as $k=>$v) $p->$k = $v;
    // if MapMarker field set to ADDRESS subfield
    $p->save(); //echo '<br>';
  }
}

That's odd because this isn't even supposed to be deleting anything, it's imports. How does this happen? This same code was working before, imported the boats just fine, I would just have to refresh the page once to clear that same error, but it would clear itself.

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
×
×
  • Create New...