Skip to content

Some fixes to support php 8.?#43

Open
Jack28 wants to merge 7 commits into
turnermm:masterfrom
Jack28:master
Open

Some fixes to support php 8.?#43
Jack28 wants to merge 7 commits into
turnermm:masterfrom
Jack28:master

Conversation

@Jack28
Copy link
Copy Markdown

@Jack28 Jack28 commented Sep 9, 2024

Hey.

It seems to work and generates readable epubs. If I did well I don't know.
I might update this with more fixes in the future and I am happy to make changes, so please comment.

I am not a php developer!!
I just hope this can be useful.

For now I run and test with php 8.2

turnermm and others added 7 commits September 6, 2024 10:05
Before the deprecation log had this message:
 require_once() is deprecated
Before the missing "url" key led to the following error messages:

2024-09-06 11:20:05     /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(337)       E_WARNING: Undefined array key "url"
  0 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(337): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined array...', '/var/www/html/d...', 337)
  1 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(271): renderer_plugin_epub->local_name(Array, '')
  2 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(145): renderer_plugin_epub->_formatLink(Array)
  3 /var/www/html/dokuwiki/inc/parser/xhtml.php(1891): renderer_plugin_epub->_media('Video/felix_rec...', 'felix_recording...', 'center', NULL, NULL, 'cache', true)
  4 /var/www/html/dokuwiki/inc/parser/xhtml.php(1203): Doku_Renderer_xhtml->_getMediaLinkConf('felix:recording...', '', 'center', NULL, NULL, 'cache', true)
  5 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(56): Doku_Renderer_xhtml->internalmedia('felix:recording...', '', 'center', NULL, NULL, 'cache', 'details')
  6 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(187): epub_creator->create(':felix:exploiti...')
  7 {main}
2024-09-06 11:20:05     /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(340)       E_WARNING: Undefined array key "url"
  0 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(340): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined array...', '/var/www/html/d...', 340)
  1 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(271): renderer_plugin_epub->local_name(Array, '')
  2 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(145): renderer_plugin_epub->_formatLink(Array)
  3 /var/www/html/dokuwiki/inc/parser/xhtml.php(1891): renderer_plugin_epub->_media('Video/felix_rec...', 'felix_recording...', 'center', NULL, NULL, 'cache', true)
  4 /var/www/html/dokuwiki/inc/parser/xhtml.php(1203): Doku_Renderer_xhtml->_getMediaLinkConf('felix:recording...', '', 'center', NULL, NULL, 'cache', true)
  5 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(56): Doku_Renderer_xhtml->internalmedia('felix:recording...', '', 'center', NULL, NULL, 'cache', 'details')
  6 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(187): epub_creator->create(':felix:exploiti...')
  7 {main}
2024-09-06 11:20:05     /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(312)       E_WARNING: Undefined array key "url"
  0 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(312): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined array...', '/var/www/html/d...', 312)
  1 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(285): renderer_plugin_epub->set_footnote(Array, 'https://...')
  2 /var/www/html/dokuwiki/lib/plugins/epub/renderer.php(145): renderer_plugin_epub->_formatLink(Array)
  3 /var/www/html/dokuwiki/inc/parser/xhtml.php(1891): renderer_plugin_epub->_media('Video/felix_rec...', 'felix_recording...', 'center', NULL, NULL, 'cache', true)
  4 /var/www/html/dokuwiki/inc/parser/xhtml.php(1203): Doku_Renderer_xhtml->_getMediaLinkConf('felix:recording...', '', 'center', NULL, NULL, 'cache', true)
  5 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(56): Doku_Renderer_xhtml->internalmedia('felix:recording...', '', 'center', NULL, NULL, 'cache', 'details')
  6 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(187): epub_creator->create(':felix:exploiti...')
  7 {main}
list($vara,$varb) receives an array that it assignes to the variables.
If it's too few it's a problem.

Now array_pad expands the array if it hasn't enough members with empty strings to the correct size:
list($file,$rest) = array_pad(explode('|',$file), 2, '');
Before if haystack was an empty string the type error was produced when looking for '*'.

Now with the size check it handles correctly, that in empty string is no '*'
Before this error was produced:

2024-09-06 10:28:31     /var/www/html/dokuwiki/lib/plugins/epub/scripts/epub_utils.php(53)      E_WARNING: Undefined variable $cover_png
  #0 /var/www/html/dokuwiki/lib/plugins/epub/scripts/epub_utils.php(53): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined varia...', '/var/www/html/d...', 53)
  turnermm#1 /var/www/html/dokuwiki/lib/plugins/epub/scripts/ebook.php(169): epub_opf_header(true)
  turnermm#2 {main}

Now cover_png is simply declared empty.
@turnermm
Copy link
Copy Markdown
Owner

turnermm commented Sep 9, 2024 via email

@Jack28
Copy link
Copy Markdown
Author

Jack28 commented Sep 11, 2024

Wow. Thank you.
For now I will just use it the way it is, if that is ok for you.
I don't even know if epub plugin is still used by a lot of people.

The forum you are referring to is https://forum.dokuwiki.org/t/plugins
correct?

I would just leave it like it is for now and see how things evolve.
People can clone my branch and use the plugin the same way I do.
Is that ok for you?

I would even write a paragraph here to let people know:
https://www.dokuwiki.org/plugin:epub

@turnermm
Copy link
Copy Markdown
Owner

turnermm commented Sep 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants