Call to undefined method DateTime::getTimezone() - laravel

For some reason most of my pages are giving this error "Call to undefined method DateTime::getTimezone()". I'm kind of positive that the pages that have this error got a ->created_at->diffForHumans() function. I still have no idea whats causing this.. It has been working fine since forever.
I tried updating my packages but there was no luck there.. Searched around for the function itself or inside my controllers.. also no luck. Checked my time zone in config/app.php and it had the same time zone that I've always had which is Asia/Amman

Check this discussion please:
https://github.com/laravel/framework/issues/24886
As it say there:
This issue is closed as it is not an issue with Laravel; it was an
issue with the PHP docs at the time, which have since been updated. I
would suggest you review your own code and make sure it's not a
namespace problem (i.e. use new \DateTime instead of new DateTime) and
if you still can't figure it out, post a question on StackOverflow
with the minimum amount of code needed to reproduce the error.
Edit:
Since this was after a Composer update, I would guess that the problem
lies with one of the packages that were updated. The error message
should give you the exact line number producing the error, which
should help you determine what package is causing the error. Then file
a bug report (or pull request) against that package if possible.
I hope it helps.

I kept changing the php version and it eventually worked. It was 7.1.22 and I changed it to 7.2.* and it worked just fine...

Related

Where does the output of dd() and dump() get written when developing Laravel in VS Code?

I'm developing a Laravel 8.x app in the current version of VS Code. I have a dump() statement in a Controller that I've written so that I can determine precisely what's in the $request that is being handled because I suspect that my date isn't exactly what I think it is. I've added this to the store() method: $request->dump() and I'm pretty sure it has executed but I can't find the output from the dump() function anywhere. I've got Debugbar installed and it does not show the dump() output. Ditto for any window of the browser like the console, inspector, etc. I've looked in the laravel.log but it's not there either. I've checked each of my terminal windows - the ones dedicated to php artisan serve and npm run watch and the one I use for all other commands but I can't find anything there. I'm out of ideas on where to look.
If the Laravel docs tell you where to find the output, I missed it; they describe what dump() and dd() do but I can't find where they describe where the output is written.
I'm pretty new to Laravel and I'm working alone so I have no work colleagues to ask. Could someone kindly tell me where to find the output of dump() so that I can debug this program?
None of the comments pointed me to precisely where I eventually found the dd() output so I'm posting it here for the sake of any future person who has the same issue. I finally found it in the browser, in the console tab (I'm using Firefox) and within the Response to the Axios statement that tried to write the new record to the database. Here's a picture:
I had assumed that the information wouldn't require me to drill down as far as I did; I thought it would be as visible as normal console.log() output.
I'm very grateful to those who replied to my question; you finally got me looking in the exact right place. I've never used dd() or dump() before, even in vanilla PHP, so I really had no idea where the output got written.

Error getting valid response from API. Check log file for error details

I cant seem to find the error log of authorize.net api.
I have Laravel application which uses "authorizenet/authorizenet" package and the code where I try to create a customer profile, I get following error:
"Error getting valid response from API. Check log file for error details"
Can anyone tell me whereto find these logs? and what it's name?
I tried in /var/logs folder but i cant seem to find it.
if someone else has this issue, here is the solution.
The authorize.net has changed their endpoints from https://api.authorize.net to https://api2.authorize.net which is one of the possible reasons that you might get this error.
So if you are hardcoding these endpoints in your code then update it to the new one or if you are using library constant for it, same as me:
\net\authorize\api\constants\ANetEnvironment::SANDBOX
\net\authorize\api\constants\ANetEnvironment::PRODUCTION
Then simply update your library by running:
composer update authorizenet/authorizenet
This is how I resolved it and it seems to be the best way so far because it will update their library to take everything up to date if they have changes something else and you started experiencing this issue.
I hope it helps

Trouble with Codeigniter Cron Job

I am haveing trouble with getting a cron job to work with codeigniter
I have used these instructions.
https://www.codeigniter.com/user_guide/general/cli.html
But it is not working
Here is what I have.
php /home4/markwolf/public_html/propalert.asia/index.php admin_notifications index
But it is not finding the right controller or the method, instead it is going to the "default_controler". Everything else I've tried gets a 404 not found error.
I've been pulling my hair out for two days trying to get this to work so any help would be greatly appreciated.
Thanks
EDIT
This works:
wget -q http://propalert.asia/admin_notifications
But the problem with this method is that Codeigniter's method for protecting the script by checking whether it is accessed by cli returns false.
I came across this post at CI's forum describing the same problem.
https://ellislab.com/forums/viewthread/236475/#1055830
Unfortunately he never got an answer there either.
I finally found the solution:
/usr/bin/php-cli -q /home4/markwolf/public_html/propalert.asia/index.php admin_notifications index
the key is "php-cli" instead of "php".
But then there is a bug in the CI core that needs to be fixed. You can find the solution to that here:
https://ellislab.com/forums/viewthread/227672/

Magento can't save new products anymore

Everything was fine 'til this morning. I've tried clearing cache, re indexing, all tips I could find on the internet.
Here is the message I'm getting
Fatal error: Call to a member function getId() on a non-object in /home5/rockbott/public_html/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 578
here is line 577 and 578:
if (Mage::app()->isSingleStoreMode()) {
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
A newly created product gives me Fatal Error message. Duplicated product gives me the same, but when I go to manage products it appears, but without SKU# and 0 stock count. When I try to edit that product again - I get Fatal Error.
Please help me with my problem.
Thanks in advance.
Thanks for your response.
Someone suggested that I clear log file and I did. I'm sorry I don't have the log file. Compiler is disabled as well. Would you be kind enough to take a look here: http://www.magentocommerce.com/boards/viewthread/347764/ I've posted more information there including reports.
Thank you
Anna
I realize this is old, but on a Magento 1.9.0.1 install i was having the same problem. I'm not sure what is happening but enabling the cache allowed it to work for me. Weird.
What appears to be causing it in my case is a remnant logging line in Mage.php that I was using to track events.
On line 447 I had:
Mage::log($name, null, 'events.log');
Removing this logging line resolved the issue.
With your informations is difficult to find the problem.
Can you paste your system.log file?
One question: Do you have the compiler enabled? Try to disable it.
I had the same error. Solution turned out to be very simple: you need to replace getStore(true) to getStore(1).
Its very strange because in PHP true same as 1 ... but in this it was a mistake. If you make a "more correct" and write:
$product->setWebsiteIds(array(Mage::app()->getStore(Mage::app()->getStore()->getId())->getWebsite()->getId()));
Magento give you not true website. Was too lazy to look for, as well as programmers Magento (getStore (true)) :)) so I decided to leave it

Facebook Application - Url-rewriting with fbml?

I have an app that I'm creating with CakePHP, which rewrites the url from something illegible to most users to something a little easier to comprehend. I'm having a problem when I use the FBML canvas.
When I try to access, say, http://apps.facebook.com/myapp/articles, I get the following error:
Received HTTP error code 404 while
loading
http://www.myapp.com/myapparticles/
I did notice that when I try to access http://apps.facebook.com/myapp/articles/posts, it changes the error to show the following url, which is slightly different: http://www.myapp.com/myapparticles/posts
Which lead me to try accessing it with this: http://apps.facebook.com/myapp//articles, which does work most of the time, though for some reason sometimes it will give the previous error. (And it also seems like a hack-y way of getting it to work).
I'm at a loss for how to fix this.
Turns out I was missing the trailing slash (http://www.myapp.com/myapp/) on the url that I specified as my canvas callback, which is in the app settings. Putting it there fixes the problem.
This happens when you are not using semantic markup or you have an error or some code not supported by fb. Also that famous error is generated by fb when it is down or slow too.
I would suggest you checking your code thoroughly and going through fb documentation. That should help you the most. thanks

Resources