warning error
-
I am using this plugin on a Multisite install. It is not network activated as i am not using it across the board. The single site I am using it on is experiencing a strange error. It only occurs when I hit the save button in the Menus dashboard. The error is:
Warning: Creating default object from empty value in /home/{site root}/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/wp-post-to-pdf-enhanced.php on line 312
Any ideas as to what is causing this? Or how to fix it?
TIA
KOhttps://www.ads-software.com/plugins/wp-post-to-pdf-enhanced/
-
Which version of the plugin are you using?
Please bear in mind that this plugin is *not* yet multisite-enabled. If I actually do find the time to make that happen, it will likely be something of a “pro” upgrade.
That said, I don’t think the issue you are seeing is related to multisite, but more likely to some sloppy coding (or editing, as the case may be). Please also give me your PHP version and WP version, and I’ll have a look.
Cheers
Lewis
Lewis,
Here are the specs you requested:PHP: 5.4.20
WP: 3.8.1
Plugin Version: 1.0.3BTW – I commented out lines 309 through 318 and the warning disappeared.
Hmmm…
Ah, yes, this is a PHP 5.4 thing. I’ll need to add it to my to-do list. I’ll fix that and release a 1.0.4 version.
(By commenting that code, you have effectively disabled the options for processing shortcodes and content from other plugins. No worries; I should have this out in the next day or so – I need to get to a point where I can break from my regular work to do this.)
I really need to test against PHP 5.4 regularly. My production server runs 5.3, but I do have a few systems running 5.4 so that I can at least test.
Thanks for bringing this to my attention, KO, and glad you have a temporary workaround in place. Let’s leave this as unresolved until I release the bugfix.
Cheers
Lewis
I appreciate the quick response!
Thank you for the help.KO
You bet, KO. After I release 1.0.4, please follow-up to let me know whether this truly has been resolved.
Cheers
Lewis
Ack… I meant to address this in 1.0.4. Looks like 1.0.5. ??
Sorry about that!
Lewis
My initial assessment of this was in error.
The real problem is that when saving menus in the admin area, we should not even be doing anything. Apparently, the action hook triggered when saving menus causes us to fire an event to update a phantom post/page, just as if editing that page and saving the edit would.
I’ve implemented what I consider to be an ugly workaround for this, where we only set those hooks when we are not on the menu admin screen.
I’ve landed this on trunk, so if you’d like to give the development version a spin, KO, please do so and let me know how it works for you. If no issues, I’ll backport this code to a 1.0.5 release.
I’ve tested under PHP 5.3.28, 5.4.23, 5.4.25, and 5.5.9, and things seem to be tight.
Cheers, thanks again for bringing this to my attention, and apologies for misdiagnosing it from the start. I should have read your initial report more closely!
Lewis
I’ll give the dev version a go. Forgive me for being daft, but do you have a link i can grab it from?
KO
??
Nothing to forgive. Until I published this plugin here, there were lots of things about the WordPress site with which I was unfamiliar.
On the main page for this plugin, there is a Developers menu item. That link will take you here:
https://www.ads-software.com/plugins/wp-post-to-pdf-enhanced/developers/
Scroll down the page to Other Versions, and click the link for Development Version (svn). That will produce (on the fly) a zip of the trunk build. Save that, go to your plugin area in your site, and install via upload. It should just upgrade your existing version.
Watch for possible option issues in the new admin interface for the plugin, as I’ve received (so far) one report of other plugins not rendering in the PDF, which I suspect is due to something getting reset. If something doesn’t look right, just toggle the option, save, toggle back, and save again, to be sure we don’t have any junk floating around in the database.
Cheers, and good luck!
Lewis
Lewis,
I finally had a chance to use the dev build on my multisite install. However, when attempting to create a PDF I received the following error…Fatal error: Uncaught exception ‘Exception’ with message ‘TCPDF ERROR: Incorrect unit: p’ in /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php:2912 Stack trace: #0 /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php(2024): TCPDF->Error(‘Incorrect unit:…’) #1 /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php(1899): TCPDF->setPageUnit(‘P’) #2 /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/wp-post-to-pdf-enhanced.php(261): TCPDF->__construct(NULL, ‘P’, ‘LETTER’, true, ‘UTF-8’, false) #3 /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/wp-post-to-pdf-enhanced.php(139): wpptopdfenh->generate_pdf_file(93) #4 [internal function]: wpptopdfenh->generate_pdf(Object(WP)) #5 /home/removed-for-privacy/public_html/wp-includes/plugin.php(507): call_user_func_array(Array, Array) #6 /home/removed-for-privacy/public_html/wp-includes/class-wp.php(616): do_action_ref_array(‘wp’, Array) #7 /home/removed-for-privacy/public_html/wp-inc in /home/removed-for-privacy/public_html/wp-content/plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php on line 2912
Please go into the admin area and ensure that the unit parameter is set to something. There are still a number of new settings which are not getting properly initialized upon activation of the plugin, and if just downloading and unzipping without deactivating, deleting, and then installing the new build, I can see how a number of things might not get set in the plugin options.
It looks like the unit of measure is not being set. The first line number referenced in the error is the exception handler in tcpdf. The first hit in the stack trace refers to this bit of code:
public function setPageUnit($unit) { $unit = strtolower($unit); //Set scale factor switch ($unit) { // points case 'px': case 'pt': { $this->k = 1; break; } // millimeters case 'mm': { $this->k = $this->dpi / 25.4; break; } // centimeters case 'cm': { $this->k = $this->dpi / 2.54; break; } // inches case 'in': { $this->k = $this->dpi; break; } // unsupported unit default : { $this->Error('Incorrect unit: '.$unit); break; } }
I thought that I had the fallback unit set to mm, but it’s possible that during my internal testing, I left that out, expecting that the database would always have something usable set in it.
So, access settings, poke around, save, and try again. That should at least get the new settings primed into the db.
Thanks for reporting this, and good luck!
Lewis
FYI – I just downloaded/installed Version 1.1.0b20140331 and I believe that the issue has been resolved!
Lewis,
I spoke to soon. I uploaded Version: 1.1.0b20140331 and although the settings took and I could publish/update posted without the error displaying, The PDFs that were exported were blank (and a single page turned into 153 blank ones.)I have gone back to 1.0.4, but have to deactivate/reactivate it every time we make content edits.
Hmmm… So, you’re not getting any errors reported with the dev build, but you do get garbage in the PDF (multiple blank pages). I’ll need to backtrack through this and see what this issue is. This is different than the initial symptom you reported, so we may want to open a different thread.
Initially, the issue had to do with us firing a PDF generation when saving menus. This is fixed in the development version, where we specifically do not fire in the admin area.
However, now we have a different issue where we are not generating proper content under the dev version, but where we *are* generating it properly with the release version (1.0.4), so we need to find out what we’re doing differently to cause this (as I haven’t seen it on anything else, yet).
Have you introduced any other plugins into the mix, KO? That’s usually what causes us to grab the wrong data to throw into the PDF.
Thanks for the report, and apologies for the trouble. I could (may) release an interim fix for your initial problem, as that one’s fairly simple to backport (IIRC).
Cheers
Lewis,
No new plugins. Same build as before.Point of clarification-
The original error was a result of saving a menu. However it also occurs when saving a post/page. I didn’t realize that I had not stipulated that…my bad.And you are correct in the analogy of the second issue, however as I said that only occurred while using the Dev version.
- The topic ‘warning error’ is closed to new replies.