bobbingwide / oik-batch

Batch interface to WordPress
https://www.oik-plugins.com/oik-plugins/oik-batch
GNU General Public License v2.0
0 stars 0 forks source link

Handle directories with spaces in them #39

Closed bobbingwide closed 4 years ago

bobbingwide commented 4 years ago

In the PHPUnit tests for WordPress there are a couple of files in the data directory

phpunit/data/themedir1/subdir/theme with spaces/index.php
phpunit/data/themedir1/subdir/theme with spaces/style.css

Two file entries are erroneously created for: spaces and spaces/index.php

Note: The source file is rubbish anyway. It just contains one line: <?php

bobbingwide commented 4 years ago

Workaround

Remove the generated posts from the API reference.

bobbingwide commented 4 years ago

I added a folder with a space to foobar and got this when parsing

File:11,12,space,space,11
Parsing file: space
Processing: space
File:12,12,dir/fileinspacedir.php,dir/fileinspacedir.php,11
Parsing file: fileinspacedir
Processing: dir/fileinspacedir.php
Processing file: foobar,dir/fileinspacedir.php
Continue to process file? ( y=yes/n=no/s=skip/g=go/q=quit )
Processing: dir/fileinspacedir.php, foobar, plugin
<p>Creating file: dir/fileinspacedir.php</p><p>Creating file: dir</p>
Warning: file(C:\apache\htdocs\oikcom/wp-content/plugins/foobar/dir/fileinspacedir.php): failed to open stream: No such file or directory in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\oik-listapis2.php on line 131

Warning: file(C:\apache\htdocs\oikcom/wp-content/plugins/foobar/dir/fileinspacedir.php): failed to open stream: No such file or directory in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\oik-listapis2.php on line 131

Warning: Invalid argument supplied for foreach() in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\admin\oik-files.php on line 11

Warning: Invalid argument supplied for foreach() in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\class-oiksc-file-loader.php on line 70
<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> [Column &#039;post_content&#039; cannot be null]<br /><code>INSERT INTO `wp_posts` (`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_content_filtered`, `post_title`, `post_excerpt`, `post_status`, `post_type`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_parent`, `menu_order`, `post_mime_type`, `guid`) VALUES (0, &#039;2019-12-27 17:31:06&#039;, &#039;2019-12-27 17:31:06&#039;, NULL, &#039;&#039;, &#039;Parsed: 43692&#039;, &#039;&#039;, &#039;publish&#039;, &#039;oik_parsed_source&#039;, &#039;closed&#039;, &#039;closed&#039;, &#039;&#039;, &#039;parsed-43692&#039;, &#039;&#039;, &#039;&#039;, &#039;2019-12-27 17:31:06&#039;, &#039;2019-12-27 17:31:06&#039;, 0, 0, &#039;&#039;, &#039;&#039;)</code></p></div>
Processing file: foobar,dir/fileinspacedir.php ended
Processing valid: foobar dir/fileinspacedir.php plugin

Warning: file(C:\apache\htdocs\oikcom/wp-content/plugins/foobar/dir/fileinspacedir.php): failed to open stream: No such file or directory in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\oik-listapis2.php on line 131

Warning: Invalid argument supplied for foreach() in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\admin\oik-create-apis.php on line 310
bobbingwide commented 4 years ago

Explanation

The problem is caused by the logic that converts the result of a Git command into separate lines. It was splitting on blanks, having previously converted tabs, CR’s and LFs to blanks. This logic is in oik-batch’s ‘lib/class-git.php’