I'm getting strange error in my symfony2 based application. On every page which uses forms I get
E_WARNING: DateTimeZone::__construct(): Unknown or bad timezone (1024)
FYI, I'm invoking
date_default_timezone_set("Europe/Warsaw");
in AppKernel::init(). Any idea how to get rid of this warning? Thanks in advance.
Edit
This is my stack trace from NewRelic
…or/symfony/symfony/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php (542)
…or/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/DateType.php (274)
…or/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/DateType.php (88)
…/shared/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php (167)
…/shared/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php (164)
…/shared/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php (126)
…zy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php (87)
…zy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php (114)
…zy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php (342)
…zy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php (230)
…zy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/in Symfony\Component\Form\FormBuilder::getForm called at /var/www/tumamoczy.pl/shared/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php FormFactory.php (47)
…endor/friendsofsymfony/user-bundle/FOS/UserBundle/Form/Factory/FormFactory.php (33)
…endsofsymfony/user-bundle/FOS/UserBundle/Controller/RegistrationController.php (48)
in FOS\UserBundle\Controller\RegistrationController::registerAction called at ? (?)
…alled at /var/www/tumamoczy.pl/releases/20130602213844/app/bootstrap.php.cache (1003)
…alled at /var/www/tumamoczy.pl/releases/20130602213844/app/bootstrap.php.cache (977)
…alled at /var/www/tumamoczy.pl/releases/20130602213844/app/bootstrap.php.cache (1103)
…alled at /var/www/tumamoczy.pl/releases/20130602213844/app/bootstrap.php.cache (413)
…el::handle called at /var/www/tumamoczy.pl/releases/20130602213844/web/app.php (21)
It looks that warning appears in StubIntlDateFormatter.php, am I right? So is it a Symfony2 problem? Is it even solvable?
Related
I used the following syntax in an TYPO3 6 exbase extension before migrating to 7:
$this->flashMessageContainer->flush();
$this->flashMessageContainer->getAllMessagesAndFlush();
$this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('undefined error', $this->extensionName));
In my new code I would use:
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('undefined error', $this->extensionName));
But I always get this error:
Fatal error: Call to a member function getFlashMessageQueue() on a
non-object in /srv/www/typo3_src-7.6.32/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php on line 190
Any ideas about this behaviour?
Thanks and best regards,
Chris
(Disclaimer: TYPO3 v7.6 reached end-of-life and is not maintained anymore)
In order to understand what's going on, let's have a look into the source code (referring to the error message you posted, checking AbstractController.php)
$this->controllerContext->getFlashMessageQueue()->enqueue($flashMessage);
https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_7-6/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php#L190
$this->controllerContext = $this->buildControllerContext();
https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_7-6/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php#L238
Thus, my assumption(!) is, that you override public function processRequest(...) in your application specific controller without invoking parent::processRequest(...) leading to the situation that $this->controllerContext is not initialized.
I'm trying to login into my WordPress Admin panel, and am getting the following error:
Call to a member function get_cart_subtotal() on a non-object in /home/spicom/public_html/adwinang.com/wp-content/themes/enfold/config-woocommerce/config.php on line 790
This is my code at line 790:
$cart_subtotal = $woocommerce->cart->get_cart_subtotal();
It sounds like you haven't called global $woocommerce;, before trying to access the $woocommerce object.
A better way would be to use WC():
$cart_subtotal = WC()->cart->get_cart_subtotal();
Alternatively, it's possible the WooCommerce hasn't even been installed and activated...make sure to do that, if it's a theme dependency.
I had a very similar message.
[25-Sep-2018 10:24:08 UTC] PHP Fatal error: Uncaught Error:
Call to a member function get_cart_subtotal() on null in
themes\storefront\inc\woocommerce\storefront-woocommerce-template-functions.php:80
It was due to me having the following in my wp-config.php file.
define( 'DOING_CRON', false );
I'd added this line while attempting to run something from the command line with W3 Total Cache activated. I didn't realise that it would completely ruin WooCommerce and didn't notice the side effect until attempting to view the site in my browser.
I had to use axis to generate stubs because the SOAP I am working with uses RPC. After setting up the code to post I am receiving the below stack trace. If anyone has had this issue please help. From using the debug tool in Eclipse I can see that Axis is using default prefixes, but the issue is that one of the prefixes it uses has already been used so it returns null. Does anyone know why this may be happening?
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:275)
at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055)
at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145)
at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
at org.apache.axis.client.Call.invoke(Call.java:2757)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
Though that this question is not answered after one year I thought that it might help you since you are working with RPC and probably a legacy system.
In your generated client stub with Apache Axis under packaging that ends with "_xsd" where the Objects of the web service provider are created open classes one by one.
Somewhere in the middle of the class you will find a static block code like this:
static {
typeDesc.setXmlType(...);
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("prefix");
elemField.setXmlName(new javax.xml.namespace.QName("", "prefix"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
just change the value of nillable to true like this:
elemField.setNillable(true);
You should repeat this action for all classes and all fields of those classes if they do not match with their corresponding values in your WSDL (i.e. based on the definition of your WSDL they are nullable).
I've noticed that Apache Axis 1.2 - 1.4 automatically makes attributes not 'nillable' by default. I don't know why is this the case but I think this is the solution.
Does anyone know how to translate form error messages in Symfony ?
At the moment I write this line in the configure() of the form:
sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
And then I overwrite all error messages with the __() method.
Is there any way for Symfony to translate error messages without calling a helper and overwriting error messages ?
How I do it:
Add to the configure function of the Form to following line:
$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('forms');
Then create a translation file like:
\i18n\forms.nl.xml
(in your application root or the plugin root)
It's also possible to add translations for the default validators (like 'Required.', etc.)
What pattern can I use to display errors on an MVC 2 view that are not related to a single property?
For example, when I call a web service to process form data, the web service may return an error or throw an exception. I would like to display a user-friendly version of that error, but have no logical means to relate the error to any given property of the model.
UPDATE:
Trying to use this code as suggested, but no summary message is displayed:
MyPage.spark:
Html.ValidationSummary(false, "Oopps it didn't work.");
Controller:
ViewData.ModelState.AddModelError("_FORM", "My custom error message.");
// Also tried this: ViewData.ModelState.AddModelError(string.Empty, "My custom error message.");
return View();
UPDATE 2
What does this mean?
next to each field.
Instead of always displaying all
validation errors, the
Html.ValidationSummary helper method
has a new option to display only
model-level errors. This enables
model-level errors to be displayed in
the validation summary and
field-specific errors to be displayed
next to each field.
Source: http://www.asp.net/learn/whitepapers/what-is-new-in-aspnet-mvc#_TOC3_14
Specifically, how does one add a model level error (as opposed to a field-specific error) to the model?
UPDATE 3:
I noticed this morning that Html.ValidationSummary is not displaying any errors at all, not even property errors. Trying to sort out why.
Simply adding a custom error to the ModelState object in conjunction with the ValidationSummary() extension method should do the trick. I use something like "_FORM" for the key... just so it won't conflict with any fields.
As far as patterns go, I have it setup so that my Business Logic Layer (called via services from the controller) will throw a custom exception if anything expected goes wrong that I want to display on the view. This custom exception contains a Dictionary<string, string> property that has any errors that I should add to ModelState.
HTHs,
Charles