Broken events in ownCloud calendar

Suddenly the synchronization with the ownCloud calendar stopped working. It gave me a strange message in the logs:

{“reqId”:”epU4rqrz1maFuP9hBxmu”,”remoteAddr”:”127.0.0.1″,”app”:”calendar”,”message”:”Event (20150807T141714Z-27435_7a94261e27f2b60.ics) contains invalid data: End of document reached prematurely”,”level”:2,”time”:”2015-09-03T06:00:26+00:00″}

The interesting part here is the error message that says “Event contains invalid data: End of document reached prematurely”. Looking around I found out that there are some reports of broken VCalendar events stored in the database. So, using the mighty SQL statement

mysql -u owncloud -p ownclouddb -e “SELECT * FROM oc_clndr_objects WHERE calendardata NOT LIKE ‘%END:VCALENDAR%’;”

I found that the database contains 218 events without a closing END:VCALENDAR statement. All of the events were for the same event that I created recently mercilessly duplicated. And the event was not showing on the calendar, of course.

As soon as I deleted all of those broken entries from the database, everything came back to normal. Sync works again. My guess for the reason? Graphical smileys in the title. Try to stick to the pure ASCII there next time, I guess.… -->

continue reading →

Correcting the WordPress multisite URL when using domain mapping

I have come across a small problem in WordPress multisite. When using a mapping to a custom domain, the domain is apparently mapped but internally the site retains your main domain with a sub-domain as its address. So, while externally it may be “example.com”, internally it is still “example.mysite.net”. Usually, this does not cause any trouble but you may run into unexpected problems with more advanced stuff and some plugins may function incorrectly.

I came across this when trying to configure Facebook with Social Networks Auto-Poster (SNAP) plugin. The plugin will issue an OAuth request to Facebook but the request fails because the plugin uses the “example.mysite.net” instead of “example.com” as you would expect. So Facebook understandably rejects the request to authorize. And this same thing may happen in other places.

The site URL comes from the database, options “siteurl” and “home”. Fire up your favorite SQL tool and head for the database. Find your table wp_XX_options where the site in question is stored (XX being the id of the site, they simply get numbered from 1 up). Change the two options to the correct URLs and things should start looking up.

siteurl http://example.com
home http://example.com

Remember to change the URLs back to “example.mysite.net” when you remove the domain mapping.… -->

continue reading →