EntityMetadataWrapperException: Invalid data value given - drupal

On editing a node with a user of a particular role i get the following error a Drupal site. With only user 1 it works. Can't figure why. I debug the entity file, but it seems that the id disappear after iteration.
EntityMetadataWrapperException : Invalid data value given. Be sure it matches the required data type and format. dans EntityDrupalWrapper->set() (ligne 737 dans /sites/all/modules/entity/includes/entity.wrapper.inc).
No coding yet has been done for this only using contrib modules.

Since you haven't done any coding, it's probably bug of some contrib module, Entity API or you're dealing with malformed entity.
Try applying this patch: Add field information to exception message on validation exception, this will allow you to see on which value it fails.
In case you're using some custom coding, then check Entity metadata wrappers page for some examples. The common mistake is to not use array() for set() when dealing with multi-valued field, or opposite - extra array for single-valued field.
If you can reproduce the problem, you can debug the issue either by step-by-step debugger and do the breakpoint on Exception line, or do it manually by temporary adding: var_dump(debug_backtrace()); exit; just before the exception happens, so PHP can dump the backtrace of your current code with all the argument passed, so you can track your malformed entity or identify the failing contrib module.
See also: How to set a value on a field collection using entity metadata wrapper at DA

Related

Phabricator Issue Unhandled Exception ("AphrontQueryException") - #1048: Column 'description' cannot be null

I recently updated Phabricator and when I try to create a new task, I receive the following error:
Unhandled Exception ("AphrontQueryException") - #1048: Column 'description' cannot be null
It´s important to say that this field isn´t marked as mandatory since this is not a custom field. Also, when I create a task by using another type o form, it works.
This sounds like you updated Phabricator, but didn't fully complete all steps (like updating the database or maybe restarting PHP). See https://secure.phabricator.com/book/phabricator/article/upgrading/

Meteor autoform does not wait for element to exist in DOM

I'm adding a rendered template to the document via:
Blaze.renderWithData(Template.page, Session.get(toAdd[i]), document.getElementById('pages'))
This works great... except sometimes with autoform. I'm unsure what's triggering it to happen but some of my autoforms (that can exist inside Template.page, they're added to that template dynamically via the data passed in) show, while other throw a client error:
Uncaught TypeError: Cannot read property 'formValues' of undefined :: autoform-inputs.js:162
markChanged :: autoform-inputs.js:169
updateTrackedFieldValue :: afFieldInput.js:72
There's a timeout set to 0 in that afFieldInput.js on line 71. Upping this to 500 fixes the error above but is hacky and causes other issues.
The best I can surmise, autoform is attempting to get the form from the DOM by id before it exists in the DOM, probably it exists as a document fragment via Blaze, if I had to guess.
I can confirm that AutoForm.templateInstanceForForm is getting the correct form ID, but that document.getElementById(formId) is returning null.
The other possibility is that Blaze is, for some reason, failing to render the template but not warning me.
I was WAY off.
I had changed the schema, but was trying to open a doc with improper data for the new schema. Going to post this answer in case someone comes across the same error.
Also, don't pass in objects or functions all the way to the template that autoform doesn't expect, apparently. You can access them still, but remove them from the attr object by declaring attr as a function in the helper, returning this.attr sans any objects that don't need to be sent on to the template.

How do I get an ID after saving an ExtBase Model?

After creating a model and adding it to a repository I want to have the new ID for different purposes (creating a mail, updating other fields outside the Extbase world)
$page = t3lib_div::makeInstance('Tx_MyExt_Domain_Model_Page');
$page->setTitle('Hello World');
$this->pageRepository->add($page);
At this point $page hasn't got an ID yet, uid is null.
$page->getUid(); // returns null
When does it get it? And how can I retrieve in on runtime?
In ExtBase, objects are "managed". This means every persistence transaction (add/remove/update) is simply noted in the underlying logic, but not yet executed until the appropriate time (like the end of processing a request). So, just because you add an object to a repository doesn't mean that it's actually added yet. That actually happens once $persistenceManager->persistAll() is called, which isn't something you need to do manually, ever. The point is, your $page object won't have a UID until it's saved and that's why $page->getUid() returns null. Look here for a great explanation.
I suspect that you are trying to do something outside of the ExtBase object/MVC lifecycle. At least, last time I got null when I tried to get the UID of an object, it was because I wasn't operating within the framework appropriately.
However, if you post some more code and give us a bigger picture of what you're trying to achieve, maybe we can help you get to a point where that object actually has a UID. For instance, if you're in a Controller object, tell us which Action method you're in, or if you're in a Repository object, tell us what you're trying to get from the repository and where/how you plan on using the query results.
EDIT
Just guessing here, but I'm assuming you're executing this code in some action of a controller. Since after the controller is executed a view is rendered, you can just pass the page object to the view:
$this->view->assign('page', $page);
And then in your view you can use the page object in a link:
<f:link.action action="show" arguments="{page:page}">
See this page object
</f:link.action>
And then in the show action of your controller you can show the page:
public function showAction(Tx_MyExt_Domain_Model_Page $page) {
// Do whatever you need to show the page in the `Show.html` template
}
I really am just guessing here. If you can give us a larger picture of what you're trying to do, what your action methods are supposed to do and things like that, we can answer your question a little more confidently.
(I'm also assuming that your page object isn't a replacement for the regular TYPO3 pages and that they are something totally different. It's much easier to deal with those TYPO3 pages through the backend interface than at the php level.)
You can call persistence manager explicitly in Your controller like this
#TYPO3 4.x
$persistenceManager = $this->objectManager->create('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();
#TYPO3 6.x
$persistenceManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
$persistenceManager->persistAll();

Help with updating vb.net formview using storedprocedure

I have followed this tutorial for the most part to explain what I am doing. http://www.asp.net/data-access/tutorials/creating-a-business-logic-layer-vb
What i need to do is figure out the best way to approach to be able to update my formview. I do not understand what the tutorial is trying to explain to me so i tried it the way i have updated a gridview before. But I am receiving "No parameterless constructor defined for this object." I tried to debug and view the callstack but it does not really tell me much.
I have my sql stored procedure to update which when executed works fine.
I also have another class in which i reference the application details class
applicant.vb
This is the code in order for when you click the view details link on the gridview it passes you off to another page that shows that applicants details it is within the same applicant.vb class
I am trying to update using the following method on the .aspx page but i receive the following error "No parameterless constructor defined for this object."
Memberdetails.aspx
Without knowing which line of code is causing that error, I can't say for sure, however, my guess is that your error is on this line of code.
_applicantadapter = New applicantTableAdapter
Put an open parentheses after applicantTableAdapter to see the different constructor signatures available to you for that type. I bet you'll see none of the options allow no parameters.
That error means that the object type you are trying to instantiate requires that you include parameter(s) (and you are not).

ASP.NET page change causes an object array in Session to be unable to cast to it's own type?

I am storing an array of a custom serializable class in session on my site. When a page on the site changes, suddenly it renders them invalid, and tells me that it can't cast the type to it's own type. I assume the class version numbers are changing or something?!
I'd appreciate avoiding the "don't use session" answers, unless it's a really simple solution. I'm not trying to redesign this whole process.
Unable to cast object of type 'ShipmentPackages[]' to type 'ShipmentPackages[]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'ShipmentPackages[]' to type 'ShipmentPackages[]'.
Source Error:
Line 21: Else
Line 22: If Not Session("ShipmentList") Is Nothing Then
Line 23: ShipmentList = DirectCast(Session("ShipmentList"), ShipmentPackages()).ToList
Line 24: End If
Line 25: End If
I have seen this message a number of times myself, it is very annoying! As you pointed out, it probably because the assembly version changed. In Asp.Net, when the page changes, the code gets recompiled. Depending on where you put the class will determine if the class gets recompiled with the page or not. I would suggest moving any "model" type classes to a separate project. This will avoid this problem as well as the urge to mix view/controller and model code :).
You can also try serializing the object into session as XML. If you do, you should be able to deserialize it even if the assembly changes, though not if the properties on the object change.
I know you said you didn't want to hear this, but you might also consider not putting objects in the session. This makes it difficult to scale your application if the time ever comes that it is necessary. The sooner you fix this the easier it will be to fix.
A few days ago I got annoyed by this issue too. Alas Brian's first solution will only work as long as you do not need to compile the "model-project" again. If you do that (because of a bugfix, etc.) and update the running application (with users holding their session during the update-process, what is done in my case) you get the exception again :-(!
In my special case the best solution was really easy! I changed "DirectCast" to "TryCast". If the assemblyversion changed and casting fails, trycast will return nothing. In this case, or if I haven't written the dictionary/collection to the session yet, I fetch my data (again) over the database and store afterwards. The next time casting will work ;-)! And another great point, this works also if the interface of the object will change!

Resources