Summary
I’m creating my first estate agency website in Modx 3 (many in the past in Modx 2). Everything has transferred more or less seamlessly, the only issue I have is the “resource/update” processor.
I’m getting the below error:
Local travel generated.
EPC processed.
Virtual Tour processed.
Related resource found with the id: 277
PHP Fatal error: Uncaught TypeError: Argument 1 passed to MODX\Revolution\Processors\Resource\Update::checkActionPermission() must be of the type string, null given, called in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/Update.php on line 163 and defined in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/ActionAccessTrait.php:34
Stack trace:
#0 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/Update.php(163): MODX\Revolution\Processors\Resource\Update->checkActionPermission()
#1 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Model/UpdateProcessor.php(59): MODX\Revolution\Processors\Resource\Update->beforeSet()
#2 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Processor.php(189): MODX\Revolution\Processors\Model\UpdateProcessor->process()
#3 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/modX.php(1771): MODX\Revolution\Processors\Processor->run()
#4 /var/www in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/ActionAccessTrait.php on line 34
Fatal error: Uncaught TypeError: Argument 1 passed to MODX\Revolution\Processors\Resource\Update::checkActionPermission() must be of the type string, null given, called in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/Update.php on line 163 and defined in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/ActionAccessTrait.php:34
Stack trace:
#0 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/Update.php(163): MODX\Revolution\Processors\Resource\Update->checkActionPermission()
#1 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Model/UpdateProcessor.php(59): MODX\Revolution\Processors\Resource\Update->beforeSet()
#2 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Processor.php(189): MODX\Revolution\Processors\Model\UpdateProcessor->process()
#3 /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/modX.php(1771): MODX\Revolution\Processors\Processor->run()
#4 /var/www in /var/www/vhosts/why-testing.co.uk/ke-root/core/src/Revolution/Processors/Resource/ActionAccessTrait.php on line 34
The “resource/create” is working just fine. From what I can tell it seems like I’m meant to pass some kind of string but I’m unsure what this should be. Previously I always passed an array of fields.
function updateResource($fields, $id) {
global $modx;
$fields['id'] = $id; // Add the resources id so it can be found
$response = $modx->runProcessor('resource/update', $fields);
handleProcessorError($response);
}
I also add my create function below in case it’s helpful:
function createResource($fields, $parent) {
global $modx;
$fields['parent'] = $parent; // Add the parent id to the fields so it is created in the correct location
$response = $modx->runProcessor('resource/create', $fields); // Create resource
handleProcessorError($response);
}
My fields array as per the below (again working for create)
$fields = array(
'template' => chooseTemplate($property), // Select the first template if this is not a new home and the second if it is.
'pagetitle' => $property->address->display,
'description' => '',
'alias' => createAlias((string)$property->address->display[0], (string)$property->attributes()->id[0]),
'published' => 1,
'content' => $property->description.$property->longDescription,
'tvs' => true, // We are going to be updating template variables
'tv17' => (string)$property->address->name[0], // address > name
'tv18' => (string)$property->address->street[0], // address > street
'tv19' => (string)$property->address->locality[0], // address > locality
'tv20' => (string)$property->address->town[0], // address > town
'tv21' => (string)$property->address->postcode[0], // address > postcode
'tv22' => (string)$property->address->display[0], // address > display
'tv23' => (string)$property->price[0], // price
'tv24' => (string)$property->rm_qualifier[0], // rm_qualifier
'tv25' => (string)$property->available[0], // available
'tv26' => (string)$property->uploaded[0], // uploaded
'tv27' => (string)$property->longitude[0], // longitude
'tv28' => (string)$property->latitude[0], // latitude
'tv29' => (string)$property->easting[0], // easting
'tv30' => (string)$property->northing[0], // northing
'tv31' => (string)$property->streetview->pov_latitude[0], // pov_latitude
'tv32' => (string)$property->streetview->pov_longitude[0], // pov_longitude
'tv33' => (string)$property->streetview->pov_pitch[0], // pov_pitch
'tv34' => (string)$property->streetview->pov_heading[0], // pov_heading
'tv35' => (string)$property->streetview->pov_zoom[0], // pov_zoom
'tv36' => (string)$property->web_status[0], // web_status
'tv37' => (string)$property->furnished[0], // furnished
'tv38' => (string)$property->rm_type[0], // rm_type
'tv39' => (string)$property->let_bond[0], // let_bond
'tv40' => (string)$property->rm_let_type_id[0], // rm_let_type_id
'tv41' => (string)$property->bedrooms[0], // bedrooms
'tv42' => (string)$property->receptions[0], // receptions
'tv43' => (string)$property->bathrooms[0], // bathrooms
'tv44' => (string)$property->newbuild[0], // newbuild
'tv46' => processBullets($property->bullets->bullet), // bullets
'tv47' => processFiles($property->files->file), // files
'tv48' => processMedia($property->files->file), // media
'tv49' => processBrochure($property->files->file), // brochure
'tv50' => (string)$property->type[0], // property_type
'tv51' => processArea($property->area), // area
'tv52' => processEnergyEfficiency($property->hip), // energy_efficiency
'tv53' => processEnviromentalImpact($property->hip), // environmental_impact
'tv54' => (string)$property->solddate[0], // solddate
'tv55' => (string)$property->leaseend[0], // leaseend
'tv56' => (string)$property->instructed[0], // instructed
'tv57' => (string)$property->soldprice[0], // soldprice
'tv58' => (string)$property->garden[0], // garden
'tv59' => (string)$property->parking[0], // parking
'tv60' => (string)$property->groundrent[0], // groundrent
'tv61' => (string)$property->commission[0], // commission
'tv62' => (string)$property->council_tax[0], // council_tax
'tv63' => (string)$property->rentalfees[0], // rentalfees
'tv64' => (string)$property->lettingsfee[0], // lettingsfee
'tv65' => (string)$property->tenure[0], // tenure
'tv66' => (string)$property->attributes()->propertyid[0], // property_id
'tv67' => (string)$property->attributes()->id[0], // property_feed_id
'tv68' => (string)$property->attributes()->system[0], // system
'tv69' => (string)$property->attributes()->firmid[0], // firmid
'tv70' => (string)$property->attributes()->branchid[0], // branchid
'tv71' => (string)$property->attributes()->database[0], // database
'tv72' => (string)$property->attributes()->featured[0], // featured
'tv73' => getLocalTravel((string)$property->latitude[0], (string)$property->longitude[0]), // local_travel
'tv74' => processEPC($property->files->file), // epc
'tv75' => processVirtualTour($property->files->file), // virtual_tour
'tv78' => (string)$property->lettype[0], // lettype
'tv79' => (string)$property->price->attributes()->qualifier[0], // price_qualifier
'tv80' => (string)$property->price->attributes()->currency[0], // price_currency
'tv81' => (string)$property->price->attributes()->display[0], // price_display
'tv82' => (string)$property->price->attributes()->rent[0], // price_rent
'context_key' => 'web'
);
Step to reproduce
Update a resource using the “resource/update” processor. I’m currently using Modx 3.0.0.
Observed behavior
The error at the beginning of the post.
Expected behavior
To update the resources required.
Environment
Apache, PHP 7.4.33