我有PHP应用程序使用pdf2htmlEX和HTMLpurifier将PDF文档转换为文本格式。 转换过程由几个步骤组成:
1.使用networking浏览器上传图书
2.使用pdf2htmlex将pdf转换为txt
3.使用HTMLPurifer处理txt文件
对于大多数的文件,一切正常,但对于一些文件有很多页面(超过230)第3步失败。 当HTMLpurifier处理页面时,会引发错误:“PHP致命错误:超过最大执行时间0秒”。 在我的configuration中,max_execution_time被设置为0.我已经将strace附加到了Apache进程,这里是终止前的输出:
lstat("/tmp/books/3349/html/78.page", {st_mode=S_IFREG|0644, st_size=40165, ...}) = 0 open("/tmp/books/3349/html/78.page", O_RDONLY) = 20 fstat(20, {st_mode=S_IFREG|0644, st_size=40165, ...}) = 0 lseek(20, 0, SEEK_CUR) = 0 fstat(20, {st_mode=S_IFREG|0644, st_size=40165, ...}) = 0 read(20, "<div class=\"pd w1 h1\"><div id=\"p"..., 8192) = 8192 read(20, "AACAsAQAAQFgCAAAgLAEAABCWAAAACEs"..., 8192) = 8192 read(20, "7\"><span class=\"_ _1f\"> </span>F"..., 8192) = 8192 read(20, "class=\"_ _8\"> </span>of<span cla"..., 8192) = 8192 read(20, "/span></div><div class=\"t m1 x7a"..., 8192) = 7397 read(20, "", 8192) = 0 read(20, "", 8192) = 0 close(20) = 0 lstat("/tmp/books/3349/text/78.txt", 0x7fff115a43f0) = -1 ENOENT (No such file or directory) open("/tmp/books/3349/text/78.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 20 fstat(20, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 lseek(20, 0, SEEK_CUR) = 0 write(20, "66 2. TOPOSESa \357\254\201xed space is a"..., 2157) = 2157 close(20) = 0 lstat("/tmp/books/3349/html/79.page", {st_mode=S_IFREG|0644, st_size=48214, ...}) = 0 open("/tmp/books/3349/html/79.page", O_RDONLY) = 20 fstat(20, {st_mode=S_IFREG|0644, st_size=48214, ...}) = 0 lseek(20, 0, SEEK_CUR) = 0 fstat(20, {st_mode=S_IFREG|0644, st_size=48214, ...}) = 0 read(20, "<div class=\"pd w1 h1\"><div id=\"p"..., 8192) = 8192 read(20, "AWAIAACAsAQAAYN5hAoBPSWIEdtXWCAD"..., 8192) = 8192 read(20, "=\"_ _0\"></span>oof<span class=\"f"..., 8192) = 8192 read(20, "c\"></span>).</span></div><div cl"..., 8192) = 8192 read(20, "lass=\"_ _23\"> </span>sho<span cl"..., 8192) = 8192 read(20, "ls0 ws0 r0\">F<span class=\"ff4\"><"..., 8192) = 7254 read(20, "", 8192) = 0 read(20, "", 8192) = 0 close(20) = 0 --- SIGPROF (Profiling timer expired) @ 0 (0) ---
有趣的是 – 我有两个相同系统configuration的环境 – 一个在AWS中,另一个在VirtualBox中。 两者都有Ubuntu 12.04 + Apache 2.2 + PHP 5.4.13,configuration设置是一样的,但问题只出现在AWS节点上。 任何想法?
问题是max_input_time选项设置的值太小。 当我增加它时,问题就消失了。 这个PHP错误信息是非常具有误导性的。