WordPress.org

Forums

WP Post to PDF Enhanced
[resolved] warning error (22 posts)

  1. ratputin
    Member
    Posted 1 year ago #

    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
    KO

    https://wordpress.org/plugins/wp-post-to-pdf-enhanced/

  2. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. ratputin
    Member
    Posted 1 year ago #

    Lewis,
    Here are the specs you requested:

    PHP: 5.4.20
    WP: 3.8.1
    Plugin Version: 1.0.3

    BTW - I commented out lines 309 through 318 and the warning disappeared.

  4. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    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

  5. ratputin
    Member
    Posted 1 year ago #

    I appreciate the quick response!
    Thank you for the help.

    KO

  6. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    You bet, KO. After I release 1.0.4, please follow-up to let me know whether this truly has been resolved.

    Cheers

    Lewis

  7. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    Ack... I meant to address this in 1.0.4. Looks like 1.0.5. ;-)

    Sorry about that!

    Lewis

  8. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    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

  9. ratputin
    Member
    Posted 1 year ago #

    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

  10. Lewis Rosenthal
    Member
    Plugin Author

    Posted 1 year ago #

    ;-)

    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:

    http://wordpress.org/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

  11. ratputin
    Member
    Posted 11 months ago #

    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

  12. Lewis Rosenthal
    Member
    Plugin Author

    Posted 11 months ago #

    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

  13. ratputin
    Member
    Posted 11 months ago #

    FYI - I just downloaded/installed Version 1.1.0b20140331 and I believe that the issue has been resolved!

  14. ratputin
    Member
    Posted 10 months ago #

    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.

  15. Lewis Rosenthal
    Member
    Plugin Author

    Posted 10 months ago #

    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

  16. ratputin
    Member
    Posted 10 months ago #

    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.

  17. Lewis Rosenthal
    Member
    Plugin Author

    Posted 9 months ago #

    So sorry for the delay, KO.

    I backported the admin mis-fire fix to 1.0.5. Then, I had difficulty with WordPress' SVN, which decided not to allow my commit to finish - after taking all of the new files <sigh>. Finally, I managed to resolve that. So, please try 1.0.5, which will hopefully address both of your issues until I get the remaining things worked out with the dev version and am able to release that as 1.1.0.

    Cheers

    Lewis

  18. jazoza
    Member
    Posted 9 months ago #

    Hi Lewis,
    I have been trying to use your plugin and failed to make it work twice.
    I have the latest WordPress (3.9.1) and I cloned the plugin code from your git repository. So I have the 1.0.5 version and it's producing the same error as ratputin reported
    TCPDF ERROR: Incorrect unit: p' in /var/www/contour/wordpress/wp-content/plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php
    I changed the unit from 'points' to 'mm' in the wp-admin interface, so the unit is definitely set but what I get is always the same error and in the browser it goes to the http://whatever-post-i-try/?format=pdf and simply hangs there.
    Any advice highly appreciated,
    cheers
    Selena

  19. Lewis Rosenthal
    Member
    Plugin Author

    Posted 9 months ago #

    Hi, Selena...

    Please be aware that I do not host any of my code in git. So, if you pulled anything from there, I am unaware of how it got there. WordPress.org uses its own Subversion repository, and that's where my official code lands.

    Version 1.0.5 does not allow for changing the unit of measurement from the admin panel. Are you certain you are not using the development version?

    Please uninstall the plugin completely and reinstall from here, if you want to try the development version or from the main page for this plugin if you want to use the latest stable build.

    Also, as this thread is actually marked resolved, could you open a fresh thread for this issue, please?

    Thanks

    Lewis

  20. jazoza
    Member
    Posted 9 months ago #

    Hi Lewis,
    Thanks for your answer.
    I deleted the plugin, installed it again using the link you sent and I get more or less the same error.
    PHP Fatal error: Uncaught exception 'Exception' with message 'TCPDF ERROR: Incorrect unit: p'
    referring to line 2912 in plugins/wp-post-to-pdf-enhanced/tcpdf/tcpdf.php
    I can set the units in the admin panel, Settings > Page Size & Units.
    It defaults to 'mm'

  21. jazoza
    Member
    Posted 9 months ago #

    Hi again,
    I was quick on posting the last answer. It actually works when you set the orientation to Portrait (or Landscape) in the same settings menu. It comes originally unset, so I guess that's where the error comes from.
    Thank you again for your feedback,
    Regards,
    Selena

  22. Lewis Rosenthal
    Member
    Plugin Author

    Posted 9 months ago #

    Selena, if you go to your plugin page, could you check the version number of WP Post to PDF Enhanced reported there? I think you'll find that you are using 1.1.0b<something> which is the development build. I'm aware of this issue with the development build.

    Thanks, and glad you figured out the issue. I do have a bug opened for this for the development version.

    Cheers

    Lewis

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic