Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal Offset w:compat #1024

Closed
shad0wfir3 opened this issue Mar 17, 2017 · 5 comments
Closed

Illegal Offset w:compat #1024

shad0wfir3 opened this issue Mar 17, 2017 · 5 comments

Comments

@shad0wfir3
Copy link

shad0wfir3 commented Mar 17, 2017

Issue found when using latest build on PHP7. Reference to #927

Found a empty string in:
PHPOffice\PHPWord\Writer\Word2007\Part\Settings

getSettings():109

private function getSettings()
    {
           .......

            'w:compat' => ' ',

           ........
    }

Updated to

private function getSettings()
    {
           .......

            'w:compat' => array('@attributes' => array('w:val' => '')),

           ........
    }

And it seems to be working. Not sure if this is supposed to be used in the same way though, but this has allowed me to export and generate word docs.

Can anyone who knows more check and see if this is in fact a issue they are experiencing as well, otherwise, is this fix a valid fix for the problem?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@karinegomes
Copy link

This is an issue with PHP 7, getting it here too. You can just replace '' for array() and it will also work fine.
Not sure why they haven't merged it yet.

@SailorMax
Copy link
Contributor

More looks like issue with PHPWord.
In function PhpOffice\PhpWord\Writer\Word2007\Part\Settings\getCompatibility() we can see:

$this->settings['w:compat']['w:compatSetting'] = array(...)

How? if $this->settings['w:compat'] is string?

Same problem in PhpOffice\PhpWord\Writer\Word2007\Part\Settings\writeSetting():

foreach ($settingValue as $childKey => $childValue) { ... }

When $settingValue in case with 'w:compat' is empty string...

PHP 7.x just more strict than early.

@ezintz
Copy link

ezintz commented Sep 23, 2017

#927 - Please release a fix, thank you in advance! I would like to not checkout the development branch on applications that run in production.

I just discovered that there is a open pull request which seems to fix more PHP 7 - #1099. Not sure if it really covers PHP 7 issues... I am not using all the functions in this library.

@mikebronner
Copy link

mikebronner commented Sep 26, 2017

Waiting on this as well. Honestly quite surprised that this project hasn't been updated in over a year (no releases) -- it seems like a great endeavor, clearly filling a niche. Like @ezintz, stale projects don't provide a good confidence level to roll them out into production. Hope you guys are able to update soon, looking forward to it. :)

@troosan
Copy link
Contributor

troosan commented Dec 25, 2017

fixed in 0.14

@troosan troosan closed this as completed Dec 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants