# |
May 5th 2021, 22:03 |
me1367 |
FileEngine has the same error... It works if I disable the routing cache but idk if that's a good idea... |
# |
May 5th 2021, 21:49 |
me1367 |
Error seems to be while adding it to the `plugin.php` |
# |
May 5th 2021, 21:45 |
slackebot |
'/graphql'],function ($routes) { $routes->scope('/', function(RouteBuilder $routes) { $routes->applyMiddleware('bodyParser'); $routes->connect('/', ['plugin' => 'Admiral/GraphQL', 'controller' => 'Graphql', 'action' => 'index', '_name' => 'graphql']); }); $routes->fallbacks(DashedRoute::class); });``` But now I get the error: `Exception: Serialization of 'Closure' is not allowed` In the ApcuEngine... |
# |
May 5th 2021, 21:45 |
me1367 |
hmm... added this to my `plugin.php`: ```public function routes(RouteBuilder $routes): void { // Add BodyParserMiddleware $routes->registerMiddleware('bodyParser', new BodyParserMiddleware()); // Add routes. // By default will load `config/routes.php` in the plugin. parent::routes($routes); }``` And this to my `routes.php` (of the same plugin): ```Router::plugin('Admiral/GraphQL', ['path' => |
# |
May 5th 2021, 21:26 |
me1367 |
oh, I see a lot more stuff in here that's interesting for later *creepy laughter* |
# |
May 5th 2021, 21:26 |
me1367 |
ah |
# |
May 5th 2021, 21:24 |
ndm |
body parser middleware |
# |
May 5th 2021, 21:20 |
me1367 |
So, it appears I can't get POST data anymore? The following code returns an empty array in Xdebug... ```$this->getRequest()->getData();``` In Insomnia, however, I can see it being a POST request *and* it sending a body just fine... |
# |
May 5th 2021, 20:30 |
tyler.adam.lazenby |
As well as create a script that makes the attempt to remove it on success. |
# |
May 5th 2021, 20:29 |
tyler.adam.lazenby |
I have thought about handling the upload seperately, but I hadn't thought about the temp storage idea. I could do that. And then to be safe I would just have a queue job make sure that file itself is cleaned out after a while. |
# |
May 5th 2021, 20:17 |
ndm |
There's variants of basically one and the same concept, which is to temporarily store the (valid) file using a unique identifier, and then just pass around that identifier, and use it to finalize/publish the upload once the form data has been successfully saved. Handling the upload separately and immediately via AJAX is also pretty popular. |
# |
May 5th 2021, 20:00 |
slackebot |
->first(); $this->set(compact('account', 'users', 'states', 'mailing_type', 'billing_type')); return null; }``` |
# |
May 5th 2021, 20:00 |
slackebot |
account could not be saved. Please, try again.')); } $users = $this->Accounts->Users->find('list', ['limit' => 200]); $states = $this->Accounts->Addresses->States->find('list'); $mailing_type = $this->Accounts->Addresses->AddressTypes->find() ->where(['name' => 'mailing']) ->first(); $billing_type = $this->Accounts->Addresses->AddressTypes->find() ->where(['name' => 'billing']) |
# |
May 5th 2021, 20:00 |
slackebot |
process the file.'); $this->log($e->getMessage()); $this->log($e->getTraceAsString()); } $account = $this->Accounts->patchEntity($account, ['logo' => $result['ObjectURL']]); if ($this->Accounts->save($account)) { $this->Flash->success(__('The account has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The |
# |
May 5th 2021, 20:00 |
slackebot |
$this->Authorization->authorize($account); if ($this->request->is(['patch', 'post', 'put'])) { $account = $this->Accounts->patchEntity($account, $this->request->getData()); try { $result = $this->AWS->createFile($this->request->getUploadedFile('logo')) ?? ['ObjectURL' => $logo]; } catch (UploadedFileErrorException $e) { $result['ObjectURL'] = $logo; $this->log('Could not |
# |
May 5th 2021, 20:00 |
tyler.adam.lazenby |
```/** * Edit method * * @param string|null $id Account id. * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function edit(?string $id = null): ?\Cake\Http\Response { $account = $this->Accounts->get($id); $logo = $account->logo; |
# |
May 5th 2021, 19:56 |
slackebot |
if the validations on the front end are disabled, be able to make that logo file upload keep that same file so that they don't have to upload the same file over and over again |
# |
May 5th 2021, 19:56 |
tyler.adam.lazenby |
How would you go about making a logo image upload sticky on the form when the table is meant to store its URL (the logo is uploaded to the webserver and then from there passed to AWS into an s3 bucket and then we store the s3 bucket object url). The name of the file when uploaded gets changed to a securely random name with the mimetype extension. My question is how do you make it so that the system will for example, |
# |
May 5th 2021, 17:27 |
kevin.pfeifer |
na it should |
# |
May 5th 2021, 17:27 |
kevin.pfeifer |
:thinking_face: |
# |
May 5th 2021, 17:26 |
kevin.pfeifer |
oh wait, i guess >= 3.0.0 in the composer constraints don't work when you have 4.0 |
# |
May 5th 2021, 17:22 |
kevin.pfeifer |
but still I dont understand why this composer/installer plugin should install it in the wrong directory. https://github.com/composer/installers/blob/main/src/Composer/Installers/CakePHPInstaller.php#L38 checks for cakephp version >= 3.0.0 |
# |
May 5th 2021, 17:15 |
admad |
Asking the right questions @kevin.pfeifer :) |
# |
May 5th 2021, 17:02 |
kevin.pfeifer |
hmmm, what is easier: change the whole cakephp 3 and 4 plugin ecosystem or tell you to not use an old library which requires an old composer installer module which causes problems :thinking_face: |
# |
May 5th 2021, 16:56 |
erwane |
maybe plugins writed for cakephp 3 and 4 should change `"type": "cakephp-plugin",` to `"type": "library",` |
# |
May 5th 2021, 16:54 |
admad |
`composer/installers` was need for plugins in Cake 2, which is why it tries to install in `Plugin` dir |
# |
May 5th 2021, 16:51 |
erwane |
yes, i will remove this requirements. But i'm really curious about this behavior. Maybe CakePHP team can answer it |
# |
May 5th 2021, 16:50 |
kevin.pfeifer |
i still stand by the fact, that you should handle JS Library dependencies via npm and not composer but otherwise I can't help you :man-shrugging: |
# |
May 5th 2021, 16:48 |
kevin.pfeifer |
mhmm but you dont have the plugin-installer active here |
# |
May 5th 2021, 16:46 |
kevin.pfeifer |
i guess it clashes with composer/installers |
# |
May 5th 2021, 16:46 |
kevin.pfeifer |
which handles how plugins are being managed inside the vendor folder |
# |
May 5th 2021, 16:45 |
kevin.pfeifer |
https://github.com/cakephp/plugin-installer |
# |
May 5th 2021, 16:45 |
kevin.pfeifer |
there is a separte cakephp plugin-installer module |
# |
May 5th 2021, 16:45 |
erwane |
but the discussion is about why if composer/installers is required, composer install should be ran twice ? |
# |
May 5th 2021, 16:45 |
kevin.pfeifer |
well ok |
# |
May 5th 2021, 16:45 |
kevin.pfeifer |
:) |
# |
May 5th 2021, 16:45 |
erwane |
moment/moment :) |
# |
May 5th 2021, 16:45 |
kevin.pfeifer |
which package requires `composer/installers` ? |
# |
May 5th 2021, 16:44 |
kevin.pfeifer |
and there is a https://github.com/composer/installers/blob/main/src/Composer/Installers/CakePHPInstaller.php |
# |
May 5th 2021, 16:44 |
kevin.pfeifer |
`This is for PHP package authors to require in their composer.json. It will install their package to the correct location based on the specified package type.` |
# |
May 5th 2021, 16:43 |
kevin.pfeifer |
ah, then its probably compsoer/installers |