Version Description
= 3.3.1 =
- Fixes a bug that would prevent downloading backups since 3.3.0 - please update.
= 3.2.5 =
- Security fixes related to add_query_arg
= 3.2.1 =
- Important bug fixes. Please upgrade to this version to avoid incomplete or broken backups.
= 3.1.3 =
- Fixes backwards compatibility for add-ons and avoids a Fatal Error. Please upgrade straight to this version before upgrading your add-ons.
= 3.0.4 =
- Fixes a few minor bugs. Immediate update is recommended.
= 3.0.2 =
- Important: we have dropped support for PHP 5.2, you will not be able to activate BackUpWordPress on a server running PHP versions older than PHP 5.3.29
= 3.0.1 =
- This is a critical update. Fixes a bug in the core backup library. Please update immediately.
Download this release
Release Info
Developer | pauldewouters |
Plugin | BackUpWordPress |
Version | 3.3.3 |
Comparing to | |
See all releases |
Code changes from version 3.3.2 to 3.3.3
- admin/constants.php +2 -2
- admin/faq.php +8 -8
- admin/page.php +1 -1
- admin/schedule-form-excludes.php +0 -1
- assets/hmbkp.js +1 -1
- assets/hmbkp.min.js +1 -1
- backupwordpress.php +1 -1
- classes/class-backup.php +98 -291
- classes/class-email-service.php +3 -3
- classes/class-plugin.php +1 -1
- classes/class-schedule.php +4 -10
- composer.json +2 -1
- composer.lock +60 -10
- functions/interface.php +1 -1
- languages/backupwordpress.pot +79 -74
- phpunit.xml +25 -0
- readme.txt +22 -14
- vendor/composer/autoload_psr4.php +1 -0
- vendor/composer/installed.json +61 -10
- vendor/ifsnop/mysqldump-php/composer.json +26 -0
- vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php +1717 -0
- vendor/symfony/finder/Adapter/PhpAdapter.php +11 -12
- vendor/symfony/finder/Finder.php +0 -42
- vendor/symfony/finder/Iterator/CustomFilterIterator.php +2 -2
- vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php +39 -9
- vendor/symfony/finder/Iterator/PathFilterIterator.php +1 -1
- vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php +24 -1
- vendor/symfony/finder/Tests/Comparator/ComparatorTest.php +0 -64
- vendor/symfony/finder/Tests/Comparator/DateComparatorTest.php +0 -63
- vendor/symfony/finder/Tests/Comparator/NumberComparatorTest.php +0 -107
- vendor/symfony/finder/Tests/Expression/ExpressionTest.php +0 -68
- vendor/symfony/finder/Tests/Expression/GlobTest.php +0 -47
- vendor/symfony/finder/Tests/Expression/RegexTest.php +0 -143
- vendor/symfony/finder/Tests/FakeAdapter/DummyAdapter.php +0 -57
- vendor/symfony/finder/Tests/FakeAdapter/FailingAdapter.php +0 -45
- vendor/symfony/finder/Tests/FakeAdapter/NamedAdapter.php +0 -57
- vendor/symfony/finder/Tests/FakeAdapter/UnsupportedAdapter.php +0 -44
- vendor/symfony/finder/Tests/FinderTest.php +0 -866
- vendor/symfony/finder/Tests/Fixtures/A/B/C/abc.dat +0 -0
- vendor/symfony/finder/Tests/Fixtures/A/B/ab.dat +0 -0
- vendor/symfony/finder/Tests/Fixtures/A/a.dat +0 -0
- vendor/symfony/finder/Tests/Fixtures/copy/A/B/C/abc.dat.copy +0 -0
- vendor/symfony/finder/Tests/Fixtures/copy/A/B/ab.dat.copy +0 -0
- vendor/symfony/finder/Tests/Fixtures/copy/A/a.dat.copy +0 -0
- vendor/symfony/finder/Tests/Fixtures/dolor.txt +0 -2
- vendor/symfony/finder/Tests/Fixtures/ipsum.txt +0 -2
- vendor/symfony/finder/Tests/Fixtures/lorem.txt +0 -2
- vendor/symfony/finder/Tests/Fixtures/one/a +0 -0
- vendor/symfony/finder/Tests/Fixtures/one/b/c.neon +0 -0
- vendor/symfony/finder/Tests/Fixtures/one/b/d.neon +0 -0
- vendor/symfony/finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat +0 -0
- vendor/symfony/finder/Tests/Fixtures/with space/foo.txt +0 -0
- vendor/symfony/finder/Tests/GlobTest.php +0 -24
- vendor/symfony/finder/Tests/Iterator/CustomFilterIteratorTest.php +0 -46
- vendor/symfony/finder/Tests/Iterator/DateRangeFilterIteratorTest.php +0 -72
- vendor/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +0 -80
- vendor/symfony/finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +0 -64
- vendor/symfony/finder/Tests/Iterator/FilePathsIteratorTest.php +0 -69
- vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php +0 -72
- vendor/symfony/finder/Tests/Iterator/FilecontentFilterIteratorTest.php +0 -86
- vendor/symfony/finder/Tests/Iterator/FilenameFilterIteratorTest.php +0 -54
- vendor/symfony/finder/Tests/Iterator/FilterIteratorTest.php +0 -50
- vendor/symfony/finder/Tests/Iterator/Iterator.php +0 -55
- vendor/symfony/finder/Tests/Iterator/IteratorTestCase.php +0 -98
- vendor/symfony/finder/Tests/Iterator/MockFileListIterator.php +0 -21
- vendor/symfony/finder/Tests/Iterator/MockSplFileInfo.php +0 -134
- vendor/symfony/finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php +0 -67
- vendor/symfony/finder/Tests/Iterator/PathFilterIteratorTest.php +0 -83
- vendor/symfony/finder/Tests/Iterator/RealIteratorTestCase.php +0 -109
- vendor/symfony/finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php +0 -83
- vendor/symfony/finder/Tests/Iterator/SizeRangeFilterIteratorTest.php +0 -68
- vendor/symfony/finder/Tests/Iterator/SortableIteratorTest.php +0 -169
- vendor/symfony/finder/Tests/Shell/CommandTest.php +0 -162
- vendor/symfony/finder/composer.json +0 -3
admin/constants.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
<p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_PATH ) . '</code>' ); ?></p>
|
15 |
<?php } ?>
|
16 |
|
17 |
-
<p><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( hmbkp_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
|
18 |
|
19 |
</td>
|
20 |
|
@@ -122,4 +122,4 @@
|
|
122 |
|
123 |
</table>
|
124 |
|
125 |
-
</div>
|
14 |
<p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_PATH ) . '</code>' ); ?></p>
|
15 |
<?php } ?>
|
16 |
|
17 |
+
<p><?php printf( __( 'The path to the folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( hmbkp_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
|
18 |
|
19 |
</td>
|
20 |
|
122 |
|
123 |
</table>
|
124 |
|
125 |
+
</div>
|
admin/faq.php
CHANGED
@@ -21,7 +21,7 @@ echo '<p><strong>' . __( 'Where does BackUpWordPress store the backup files?', '
|
|
21 |
|
22 |
'<p><strong>' . __( 'I\'m not receiving my backups by email', 'backupwordpress' ) . '</strong></p>' .
|
23 |
|
24 |
-
'<p>' . __( 'Most servers have a filesize limit on email attachments, it\'s generally about 10mb. If your backup file is over that limit it won\'t be sent attached to the email,
|
25 |
|
26 |
'<p><strong>' . __( 'How many backups are stored by default?', 'backupwordpress' ) . '</strong></p>' .
|
27 |
|
@@ -29,11 +29,11 @@ echo '<p><strong>' . __( 'Where does BackUpWordPress store the backup files?', '
|
|
29 |
|
30 |
'<p><strong>' . __( 'How long should a backup take?', 'backupwordpress' ) . '</strong></p>' .
|
31 |
|
32 |
-
'<p>' . __( 'Unless your site is very large (many gigabytes) it should only take a few minutes to perform a
|
33 |
|
34 |
'<p><strong>' . __( 'What do I do if I get the wp-cron error message?', 'backupwordpress' ) . '</strong></p>' .
|
35 |
|
36 |
-
'<p>' . __( 'The issue is that your <code>wp-cron.php</code> is not returning a <code>200</code> response when hit with a HTTP request originating from your own server, it could be several things
|
37 |
|
38 |
'<p>' . __( 'There are some things you can test to confirm this is the issue.', 'backupwordpress' ) . '</p>' .
|
39 |
|
@@ -41,13 +41,13 @@ echo '<p><strong>' . __( 'Where does BackUpWordPress store the backup files?', '
|
|
41 |
|
42 |
'<li>' . __( 'Are you hosted on Heart Internet? (wp-cron may not be supported by Heart Internet, see below for work-around.)', 'backupwordpress' ) . '</li>' .
|
43 |
|
44 |
-
'<li>' . __( 'If you click manual backup does it work?', 'backupwordpress' ) . '</li>' .
|
45 |
|
46 |
-
'<li>' . __( 'Try adding <code>define( \'ALTERNATE_WP_CRON\', true );</code> to your <code>wp-config.php</code
|
47 |
|
48 |
-
'<li>' . __( 'Is your site private (i.e. is it behind some kind of authentication, maintenance plugin, .htaccess)? If so wp-cron won\'t work until you remove it. If you are and you temporarily remove the authentication, do backups start working?', 'backupwordpress' ) . '</li></ul>' .
|
49 |
|
50 |
-
'<p>' . __( 'Report the results to our support team for further help. To do this, either enable
|
51 |
|
52 |
'<p><strong>' . __( 'How to get BackUpWordPress working in Heart Internet', 'backupwordpress' ) . '</strong></p>' .
|
53 |
|
@@ -55,4 +55,4 @@ echo '<p><strong>' . __( 'Where does BackUpWordPress store the backup files?', '
|
|
55 |
|
56 |
'<p><strong>' . __( 'My backups seem to be failing?', 'backupwordpress' ) . '</strong></p>' .
|
57 |
|
58 |
-
'<p>' . __( 'If your backups are failing, it\'s commonly caused by a lack of available resources on your server.
|
21 |
|
22 |
'<p><strong>' . __( 'I\'m not receiving my backups by email', 'backupwordpress' ) . '</strong></p>' .
|
23 |
|
24 |
+
'<p>' . __( 'Most servers have a filesize limit on email attachments, it\'s generally about 10mb. If your backup file is over that limit, it won\'t be sent attached to the email. Instead, you should receive an email with a link to download the backup. If you aren\'t even receiving that, then you likely have a mail issue on your server that you\'ll need to contact your host about.', 'backupwordpress' ) . '</p>' .
|
25 |
|
26 |
'<p><strong>' . __( 'How many backups are stored by default?', 'backupwordpress' ) . '</strong></p>' .
|
27 |
|
29 |
|
30 |
'<p><strong>' . __( 'How long should a backup take?', 'backupwordpress' ) . '</strong></p>' .
|
31 |
|
32 |
+
'<p>' . __( 'Unless your site is very large (many gigabytes) it should only take a few minutes to perform a backup. If your back up has been running for longer than an hour, it\'s safe to assume that something has gone wrong. Try de-activating and re-activating the plugin. If it keeps happening, contact support.', 'backupwordpress' ) . '</p>' .
|
33 |
|
34 |
'<p><strong>' . __( 'What do I do if I get the wp-cron error message?', 'backupwordpress' ) . '</strong></p>' .
|
35 |
|
36 |
+
'<p>' . __( 'The issue is that your <code>wp-cron.php</code> is not returning a <code>200</code> response when hit with a HTTP request originating from your own server, it could be several things. In most cases, it\'s an issue with the server / site.', 'backupwordpress' ) . '</p>' .
|
37 |
|
38 |
'<p>' . __( 'There are some things you can test to confirm this is the issue.', 'backupwordpress' ) . '</p>' .
|
39 |
|
41 |
|
42 |
'<li>' . __( 'Are you hosted on Heart Internet? (wp-cron may not be supported by Heart Internet, see below for work-around.)', 'backupwordpress' ) . '</li>' .
|
43 |
|
44 |
+
'<li>' . __( 'If you click manual backup, does it work?', 'backupwordpress' ) . '</li>' .
|
45 |
|
46 |
+
'<li>' . __( 'Try adding <code>define( \'ALTERNATE_WP_CRON\', true );</code> to your <code>wp-config.php</code>. Do automatic backups work?', 'backupwordpress' ) . '</li>' .
|
47 |
|
48 |
+
'<li>' . __( 'Is your site private (i.e. is it behind some kind of authentication, maintenance plugin, .htaccess)? If so, wp-cron won\'t work until you remove it. If you are and you temporarily remove the authentication, do backups start working?', 'backupwordpress' ) . '</li></ul>' .
|
49 |
|
50 |
+
'<p>' . __( 'Report the results to our support team for further help. To do this, either enable support from your Admin Dashboard (recommended), or email backupwordpress@hmn.md', 'backupwordpress' ) . '</p>' .
|
51 |
|
52 |
'<p><strong>' . __( 'How to get BackUpWordPress working in Heart Internet', 'backupwordpress' ) . '</strong></p>' .
|
53 |
|
55 |
|
56 |
'<p><strong>' . __( 'My backups seem to be failing?', 'backupwordpress' ) . '</strong></p>' .
|
57 |
|
58 |
+
'<p>' . __( 'If your backups are failing, it\'s commonly caused by a lack of available resources on your server. To establish this is the case, exclude the complete (or parts of the) uploads folder and run a backup. If that succeeds, you know it\'s probably a server issue. If it does not succeed, report the results to our support team for further help. You can contact support by enabling support from your Admin Dashboard (recommended), or emailing backupwordpress@hmn.md', 'backupwordpress' ) . '</p>';
|
admin/page.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
BackUpWordPress
|
5 |
|
6 |
<?php if ( get_option( 'hmbkp_enable_support' ) ) { ?>
|
7 |
-
<a class="page-title-action" href="mailto:backupwordpress@hmn.md"><?php _e( 'Support', 'backupwordpress' ); ?></a>
|
8 |
<?php } else {
|
9 |
add_thickbox(); ?>
|
10 |
<a id="intercom-info" class="thickbox page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'load_enable_support', 'width' => '600', 'height' => '420' ), self_admin_url( 'admin-ajax.php' ) ), 'hmbkp_nonce' ) ); ?>"><span class="dashicons dashicons-admin-users"></span> <?php _e( 'Enable Support', 'backupwordpress' ); ?></a>
|
4 |
BackUpWordPress
|
5 |
|
6 |
<?php if ( get_option( 'hmbkp_enable_support' ) ) { ?>
|
7 |
+
<a id="intercom" class="page-title-action" href="mailto:backupwordpress@hmn.md"><?php _e( 'Support', 'backupwordpress' ); ?></a>
|
8 |
<?php } else {
|
9 |
add_thickbox(); ?>
|
10 |
<a id="intercom-info" class="thickbox page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'load_enable_support', 'width' => '600', 'height' => '420' ), self_admin_url( 'admin-ajax.php' ) ), 'hmbkp_nonce' ) ); ?>"><span class="dashicons dashicons-admin-users"></span> <?php _e( 'Enable Support', 'backupwordpress' ); ?></a>
|
admin/schedule-form-excludes.php
CHANGED
@@ -34,7 +34,6 @@
|
|
34 |
|
35 |
<td>
|
36 |
<code><?php echo esc_html( str_ireplace( $schedule->backup->get_root(), '', $exclude ) ); ?></code>
|
37 |
-
|
38 |
</td>
|
39 |
|
40 |
<td>
|
34 |
|
35 |
<td>
|
36 |
<code><?php echo esc_html( str_ireplace( $schedule->backup->get_root(), '', $exclude ) ); ?></code>
|
|
|
37 |
</td>
|
38 |
|
39 |
<td>
|
assets/hmbkp.js
CHANGED
@@ -52,7 +52,7 @@ jQuery( document ).ready( function ( $ ) {
|
|
52 |
|
53 |
// Run a backup
|
54 |
$( document ).on( 'click', '.hmbkp-run', function ( e ) {
|
55 |
-
|
56 |
$( this ).closest( '.hmbkp-schedule-sentence' ).addClass( 'hmbkp-running' );
|
57 |
|
58 |
$( '.hmbkp-error' ).removeClass( 'hmbkp-error' );
|
52 |
|
53 |
// Run a backup
|
54 |
$( document ).on( 'click', '.hmbkp-run', function ( e ) {
|
55 |
+
wp.heartbeat.interval( 'fast' );
|
56 |
$( this ).closest( '.hmbkp-schedule-sentence' ).addClass( 'hmbkp-running' );
|
57 |
|
58 |
$( '.hmbkp-error' ).removeClass( 'hmbkp-error' );
|
assets/hmbkp.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function hmbkpToggleScheduleFields(a){a="undefined"!=typeof a?a:"manually";var b=jQuery(".recurring-setting"),c=jQuery("#schedule-start"),d=jQuery(".twice-js");switch(a){case"manually":b.hide();break;case"hourly":b.hide();break;case"daily":b.hide(),c.show(),d.hide();break;case"twicedaily":b.hide(),c.show(),d.show();break;case"weekly":case"fortnightly":b.hide(),jQuery("#start-day").show(),c.show(),d.hide();break;case"monthly":b.hide(),c.show(),jQuery("#start-date").show(),d.hide()}}function hmbkpCatchResponseAndOfferToEmail(a){a&&0!==a?(jQuery(".hmbkp-schedule-sentence.hmbkp-running").removeClass("hmbkp-running").addClass("hmbkp-error"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_backup_error",hmbkp_error:a},function(a){a&&0!==a&&location.reload(!0)})):location.reload(!0),jQuery(document).one("click",".hmbkp_send_error_via_email",function(b){b.preventDefault(),jQuery(this).addClass("hmbkp-ajax-loading").attr("disabled","disabled"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_email_error",hmbkp_error:a},function(){})})}jQuery(document).ready(function(a){"use strict";var b=a("select#hmbkp_schedule_recurrence_type");a.ajaxSetup({cache:!1}),b.length&&(hmbkpToggleScheduleFields(b.val()),a(document).on("change","select#hmbkp_schedule_recurrence_type",function(){hmbkpToggleScheduleFields(a(this).val())})),a(document).on("click",".hmbkp-schedule-actions .delete-action",function(a){confirm(hmbkp.delete_schedule)||a.preventDefault()}),a(document).on("click",".hmbkp_manage_backups_row .delete-action",function(a){confirm(hmbkp.delete_backup)||a.preventDefault()}),a(document).on("click",".hmbkp-edit-schedule-excludes-form .delete-action",function(a){confirm(hmbkp.remove_exclude_rule)||a.preventDefault()}),a.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_cron_test"},function(b){"1"!==b&&a(".wrap > h2").after(b)}),a(document).on("click",".hmbkp-run",function(b){a(this).closest(".hmbkp-schedule-sentence").addClass("hmbkp-running"),a(".hmbkp-error").removeClass("hmbkp-error");var c=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id");a.post(ajaxurl,{hmbkp_run_schedule_nonce:hmbkp.hmbkp_run_schedule_nonce,action:"hmbkp_run_schedule",hmbkp_schedule_id:c}),b.preventDefault()}),a(document).on("heartbeat-send",function(b,c){c.hmbkp_schedule_id=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id"),a(".hmbkp-schedule-sentence.hmbkp-running").length?c.hmbkp_is_in_progress=!0:c.hmbkp_client_request="site_size"}),a(document).on("heartbeat-tick",function(b,c){if(0!==c.hmbkp_schedule_status||a(".hmbkp-error").length||location.reload(!0),0!==c.hmbkp_schedule_status&&void 0!==c.hmbkp_schedule_status&&a(".hmbkp-status").replaceWith(c.hmbkp_schedule_status),void 0!==c.hmbkp_site_size&&a("code.calculating").length){a("code.calculating").text(c.hmbkp_site_size);var d=a(".hmbkp-exclude-settings");d.length&&d.replaceWith(c.hmbkp_dir_sizes)}}),a(document).on("click",".hmbkp-thickbox-close",function(a){a.preventDefault(),window.parent.tb_remove()})});
|
1 |
+
function hmbkpToggleScheduleFields(a){a="undefined"!=typeof a?a:"manually";var b=jQuery(".recurring-setting"),c=jQuery("#schedule-start"),d=jQuery(".twice-js");switch(a){case"manually":b.hide();break;case"hourly":b.hide();break;case"daily":b.hide(),c.show(),d.hide();break;case"twicedaily":b.hide(),c.show(),d.show();break;case"weekly":case"fortnightly":b.hide(),jQuery("#start-day").show(),c.show(),d.hide();break;case"monthly":b.hide(),c.show(),jQuery("#start-date").show(),d.hide()}}function hmbkpCatchResponseAndOfferToEmail(a){a&&0!==a?(jQuery(".hmbkp-schedule-sentence.hmbkp-running").removeClass("hmbkp-running").addClass("hmbkp-error"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_backup_error",hmbkp_error:a},function(a){a&&0!==a&&location.reload(!0)})):location.reload(!0),jQuery(document).one("click",".hmbkp_send_error_via_email",function(b){b.preventDefault(),jQuery(this).addClass("hmbkp-ajax-loading").attr("disabled","disabled"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_email_error",hmbkp_error:a},function(){})})}jQuery(document).ready(function(a){"use strict";var b=a("select#hmbkp_schedule_recurrence_type");a.ajaxSetup({cache:!1}),b.length&&(hmbkpToggleScheduleFields(b.val()),a(document).on("change","select#hmbkp_schedule_recurrence_type",function(){hmbkpToggleScheduleFields(a(this).val())})),a(document).on("click",".hmbkp-schedule-actions .delete-action",function(a){confirm(hmbkp.delete_schedule)||a.preventDefault()}),a(document).on("click",".hmbkp_manage_backups_row .delete-action",function(a){confirm(hmbkp.delete_backup)||a.preventDefault()}),a(document).on("click",".hmbkp-edit-schedule-excludes-form .delete-action",function(a){confirm(hmbkp.remove_exclude_rule)||a.preventDefault()}),a.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_cron_test"},function(b){"1"!==b&&a(".wrap > h2").after(b)}),a(document).on("click",".hmbkp-run",function(b){wp.heartbeat.interval("fast"),a(this).closest(".hmbkp-schedule-sentence").addClass("hmbkp-running"),a(".hmbkp-error").removeClass("hmbkp-error");var c=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id");a.post(ajaxurl,{hmbkp_run_schedule_nonce:hmbkp.hmbkp_run_schedule_nonce,action:"hmbkp_run_schedule",hmbkp_schedule_id:c}),b.preventDefault()}),a(document).on("heartbeat-send",function(b,c){c.hmbkp_schedule_id=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id"),a(".hmbkp-schedule-sentence.hmbkp-running").length?c.hmbkp_is_in_progress=!0:c.hmbkp_client_request="site_size"}),a(document).on("heartbeat-tick",function(b,c){if(0!==c.hmbkp_schedule_status||a(".hmbkp-error").length||location.reload(!0),0!==c.hmbkp_schedule_status&&void 0!==c.hmbkp_schedule_status&&a(".hmbkp-status").replaceWith(c.hmbkp_schedule_status),void 0!==c.hmbkp_site_size&&a("code.calculating").length){a("code.calculating").text(c.hmbkp_site_size);var d=a(".hmbkp-exclude-settings");d.length&&d.replaceWith(c.hmbkp_dir_sizes)}}),a(document).on("click",".hmbkp-thickbox-close",function(a){a.preventDefault(),window.parent.tb_remove()})});
|
backupwordpress.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BackUpWordPress
|
4 |
Plugin URI: http://bwp.hmn.md/
|
5 |
Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools → Backups</strong>. On multisite, you'll find me under the Network Settings menu.
|
6 |
-
Version: 3.3.
|
7 |
Author: Human Made Limited
|
8 |
Author URI: http://hmn.md/
|
9 |
License: GPL-2+
|
3 |
Plugin Name: BackUpWordPress
|
4 |
Plugin URI: http://bwp.hmn.md/
|
5 |
Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools → Backups</strong>. On multisite, you'll find me under the Network Settings menu.
|
6 |
+
Version: 3.3.3
|
7 |
Author: Human Made Limited
|
8 |
Author URI: http://hmn.md/
|
9 |
License: GPL-2+
|
classes/class-backup.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace HM\BackUpWordPress;
|
4 |
use Symfony\Component\Finder\Finder;
|
|
|
5 |
|
6 |
/**
|
7 |
* Generic file and database backup class
|
@@ -66,13 +67,6 @@ class Backup {
|
|
66 |
*/
|
67 |
private $root = '';
|
68 |
|
69 |
-
/**
|
70 |
-
* Holds the current db connection
|
71 |
-
*
|
72 |
-
* @var resource
|
73 |
-
*/
|
74 |
-
private $db;
|
75 |
-
|
76 |
/**
|
77 |
* An array of all the files in root
|
78 |
* excluding excludes and unreadable files
|
@@ -83,27 +77,27 @@ class Backup {
|
|
83 |
|
84 |
/**
|
85 |
* An array of all the files in root
|
86 |
-
* that
|
87 |
*
|
88 |
* @var array
|
89 |
*/
|
90 |
-
private $
|
91 |
|
92 |
/**
|
93 |
* An array of all the files in root
|
94 |
-
* that
|
95 |
*
|
96 |
* @var array
|
97 |
*/
|
98 |
-
|
99 |
|
100 |
/**
|
101 |
* An array of all the files in root
|
102 |
-
* that
|
103 |
*
|
104 |
* @var array
|
105 |
*/
|
106 |
-
|
107 |
|
108 |
/**
|
109 |
* Contains an array of errors
|
@@ -249,7 +243,7 @@ class Backup {
|
|
249 |
public static function get_home_path() {
|
250 |
|
251 |
if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT ) {
|
252 |
-
|
253 |
}
|
254 |
|
255 |
$home_url = home_url();
|
@@ -259,10 +253,10 @@ class Backup {
|
|
259 |
|
260 |
// If site_url contains home_url and they differ then assume WordPress is installed in a sub directory
|
261 |
if ( $home_url !== $site_url && strpos( $site_url, $home_url ) === 0 ) {
|
262 |
-
|
263 |
}
|
264 |
|
265 |
-
|
266 |
|
267 |
}
|
268 |
|
@@ -320,14 +314,14 @@ class Backup {
|
|
320 |
|
321 |
if ( empty( $this->archive_filename ) ) {
|
322 |
$this->set_archive_filename( implode( '-', array(
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
}
|
332 |
|
333 |
return $this->archive_filename;
|
@@ -410,7 +404,7 @@ class Backup {
|
|
410 |
public function get_root() {
|
411 |
|
412 |
if ( empty( $this->root ) ) {
|
413 |
-
|
414 |
}
|
415 |
|
416 |
return $this->root;
|
@@ -430,7 +424,7 @@ class Backup {
|
|
430 |
return new \WP_Error( 'invalid_directory_path', sprintf( __( 'Invalid root path <code>%s</code> must be a valid directory path', 'backupwordpress' ), $path ) );
|
431 |
}
|
432 |
|
433 |
-
|
434 |
|
435 |
}
|
436 |
|
@@ -456,7 +450,7 @@ class Backup {
|
|
456 |
return new \WP_Error( 'invalid_existing_archive_filepath', sprintf( __( 'Invalid existing archive filepath <code>%s</code> must be a non-empty (string)', 'backupwordpress' ), $existing_archive_filepath ) );
|
457 |
}
|
458 |
|
459 |
-
|
460 |
|
461 |
}
|
462 |
|
@@ -572,7 +566,7 @@ class Backup {
|
|
572 |
|
573 |
// Find the first one which works
|
574 |
foreach ( $mysqldump_locations as $location ) {
|
575 |
-
|
576 |
$this->set_mysqldump_command_path( $location );
|
577 |
break; // Found one
|
578 |
}
|
@@ -635,7 +629,7 @@ class Backup {
|
|
635 |
|
636 |
// Find the first one which works
|
637 |
foreach ( $zip_locations as $location ) {
|
638 |
-
|
639 |
$this->set_zip_command_path( $location );
|
640 |
break; // Found one
|
641 |
}
|
@@ -858,42 +852,87 @@ class Backup {
|
|
858 |
|
859 |
$this->do_action( 'hmbkp_mysqldump_started' );
|
860 |
|
861 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
862 |
|
863 |
-
|
864 |
-
$this->db = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
865 |
}
|
866 |
|
867 |
-
|
868 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
869 |
}
|
870 |
|
871 |
-
|
|
|
|
|
|
|
|
|
|
|
872 |
|
873 |
-
if (
|
874 |
-
|
|
|
|
|
875 |
}
|
876 |
|
877 |
-
|
878 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
879 |
|
880 |
-
|
881 |
-
$sql_file .= "#\n";
|
882 |
-
$sql_file .= "# Generated: " . date( 'l j. F Y H:i T' ) . "\n";
|
883 |
-
$sql_file .= "# Hostname: " . DB_HOST . "\n";
|
884 |
-
$sql_file .= "# Database: " . $this->sql_backquote( DB_NAME ) . "\n";
|
885 |
-
$sql_file .= "# --------------------------------------------------------\n";
|
886 |
|
887 |
-
|
|
|
888 |
|
889 |
-
$
|
890 |
|
891 |
-
|
892 |
-
$sql_file .= "# --------------------------------------------------------\n";
|
893 |
-
$sql_file .= "# Table: " . $this->sql_backquote( $curr_table ) . "\n";
|
894 |
-
$sql_file .= "# --------------------------------------------------------\n";
|
895 |
|
896 |
-
|
|
|
|
|
897 |
|
898 |
}
|
899 |
|
@@ -967,7 +1006,7 @@ class Backup {
|
|
967 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_path() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -q ' . escapeshellarg( $this->get_archive_filepath() ) . ' ' . escapeshellarg( $this->get_database_dump_filename() ) . ' 2>&1' );
|
968 |
|
969 |
if ( ! empty ( $stderr ) ) {
|
970 |
-
|
971 |
}
|
972 |
}
|
973 |
|
@@ -1053,14 +1092,14 @@ class Backup {
|
|
1053 |
}
|
1054 |
|
1055 |
// Excludes
|
1056 |
-
|
1057 |
continue;
|
1058 |
}
|
1059 |
|
1060 |
if ( $file->isDir() ) {
|
1061 |
-
|
1062 |
} elseif ( $file->isFile() ) {
|
1063 |
-
|
1064 |
}
|
1065 |
|
1066 |
if ( ++ $files_added % 500 === 0 ) {
|
@@ -1204,7 +1243,7 @@ class Backup {
|
|
1204 |
}
|
1205 |
|
1206 |
// Excludes
|
1207 |
-
|
1208 |
continue;
|
1209 |
}
|
1210 |
|
@@ -1244,7 +1283,7 @@ class Backup {
|
|
1244 |
}
|
1245 |
|
1246 |
// Excludes
|
1247 |
-
|
1248 |
$this->excluded_files[] = $file;
|
1249 |
}
|
1250 |
|
@@ -1373,7 +1412,7 @@ class Backup {
|
|
1373 |
}
|
1374 |
|
1375 |
// Strip $this->root and conform
|
1376 |
-
|
1377 |
|
1378 |
// Strip the preceeding slash
|
1379 |
if ( in_array( substr( $rule, 0, 1 ), array( '\\', '/' ) ) ) {
|
@@ -1421,237 +1460,6 @@ class Backup {
|
|
1421 |
|
1422 |
}
|
1423 |
|
1424 |
-
/**
|
1425 |
-
* Add backquotes to tables and db-names in SQL queries. Taken from phpMyAdmin.
|
1426 |
-
*
|
1427 |
-
* @param mixed $a_name
|
1428 |
-
*
|
1429 |
-
* @return array|string
|
1430 |
-
*/
|
1431 |
-
private function sql_backquote( $a_name ) {
|
1432 |
-
|
1433 |
-
if ( ! empty( $a_name ) && $a_name !== '*' ) {
|
1434 |
-
|
1435 |
-
if ( is_array( $a_name ) ) {
|
1436 |
-
|
1437 |
-
$result = array();
|
1438 |
-
|
1439 |
-
reset( $a_name );
|
1440 |
-
|
1441 |
-
while ( list( $key, $val ) = each( $a_name ) ) {
|
1442 |
-
$result[ $key ] = '`' . $val . '`';
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
return $result;
|
1446 |
-
|
1447 |
-
} else {
|
1448 |
-
return '`' . $a_name . '`';
|
1449 |
-
}
|
1450 |
-
|
1451 |
-
} else {
|
1452 |
-
return $a_name;
|
1453 |
-
}
|
1454 |
-
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
/**
|
1458 |
-
* Reads the Database table in $table and creates
|
1459 |
-
* SQL Statements for recreating structure and data
|
1460 |
-
* Taken partially from phpMyAdmin and partially from
|
1461 |
-
* Alain Wolf, Zurich - Switzerland
|
1462 |
-
* Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
|
1463 |
-
*
|
1464 |
-
* @param string $sql_file
|
1465 |
-
* @param string $table
|
1466 |
-
*/
|
1467 |
-
private function make_sql( $sql_file, $table ) {
|
1468 |
-
|
1469 |
-
// Add SQL statement to drop existing table
|
1470 |
-
$sql_file .= "\n";
|
1471 |
-
$sql_file .= "\n";
|
1472 |
-
$sql_file .= "#\n";
|
1473 |
-
$sql_file .= "# Delete any existing table " . $this->sql_backquote( $table ) . "\n";
|
1474 |
-
$sql_file .= "#\n";
|
1475 |
-
$sql_file .= "\n";
|
1476 |
-
$sql_file .= "DROP TABLE IF EXISTS " . $this->sql_backquote( $table ) . ";\n";
|
1477 |
-
|
1478 |
-
/* Table Structure */
|
1479 |
-
|
1480 |
-
// Comment in SQL-file
|
1481 |
-
$sql_file .= "\n";
|
1482 |
-
$sql_file .= "\n";
|
1483 |
-
$sql_file .= "#\n";
|
1484 |
-
$sql_file .= "# Table structure of table " . $this->sql_backquote( $table ) . "\n";
|
1485 |
-
$sql_file .= "#\n";
|
1486 |
-
$sql_file .= "\n";
|
1487 |
-
|
1488 |
-
// Get table structure
|
1489 |
-
$query = 'SHOW CREATE TABLE ' . $this->sql_backquote( $table );
|
1490 |
-
$result = mysql_query( $query, $this->db );
|
1491 |
-
|
1492 |
-
if ( $result ) {
|
1493 |
-
|
1494 |
-
if ( mysql_num_rows( $result ) > 0 ) {
|
1495 |
-
$sql_create_arr = mysql_fetch_array( $result );
|
1496 |
-
$sql_file .= $sql_create_arr[1];
|
1497 |
-
}
|
1498 |
-
|
1499 |
-
mysql_free_result( $result );
|
1500 |
-
$sql_file .= ' ;';
|
1501 |
-
|
1502 |
-
}
|
1503 |
-
|
1504 |
-
/* Table Contents */
|
1505 |
-
|
1506 |
-
// Get table contents
|
1507 |
-
$query = 'SELECT * FROM ' . $this->sql_backquote( $table );
|
1508 |
-
$result = mysql_query( $query, $this->db );
|
1509 |
-
|
1510 |
-
$fields_cnt = 0;
|
1511 |
-
$rows_cnt = 0;
|
1512 |
-
|
1513 |
-
if ( $result ) {
|
1514 |
-
$fields_cnt = mysql_num_fields( $result );
|
1515 |
-
$rows_cnt = mysql_num_rows( $result );
|
1516 |
-
}
|
1517 |
-
|
1518 |
-
// Comment in SQL-file
|
1519 |
-
$sql_file .= "\n";
|
1520 |
-
$sql_file .= "\n";
|
1521 |
-
$sql_file .= "#\n";
|
1522 |
-
$sql_file .= "# Data contents of table " . $table . " (" . $rows_cnt . " records)\n";
|
1523 |
-
$sql_file .= "#\n";
|
1524 |
-
|
1525 |
-
$field_set = $field_num = array();
|
1526 |
-
|
1527 |
-
// Checks whether the field is an integer or not
|
1528 |
-
for ( $j = 0; $j < $fields_cnt; $j ++ ) {
|
1529 |
-
|
1530 |
-
$field_set[ $j ] = $this->sql_backquote( mysql_field_name( $result, $j ) );
|
1531 |
-
$type = mysql_field_type( $result, $j );
|
1532 |
-
|
1533 |
-
if ( $type === 'tinyint' || $type === 'smallint' || $type === 'mediumint' || $type === 'int' || $type === 'bigint' ) {
|
1534 |
-
$field_num[ $j ] = true;
|
1535 |
-
} else {
|
1536 |
-
$field_num[ $j ] = false;
|
1537 |
-
}
|
1538 |
-
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
// Sets the scheme
|
1542 |
-
$entries = 'INSERT INTO ' . $this->sql_backquote( $table ) . ' VALUES (';
|
1543 |
-
$search = array( '\x00', '\x0a', '\x0d', '\x1a' ); //\x08\\x09, not required
|
1544 |
-
$replace = array( '\0', '\n', '\r', '\Z' );
|
1545 |
-
$current_row = 0;
|
1546 |
-
$batch_write = 0;
|
1547 |
-
|
1548 |
-
$values = array();
|
1549 |
-
|
1550 |
-
while ( $row = mysql_fetch_row( $result ) ) {
|
1551 |
-
|
1552 |
-
$current_row ++;
|
1553 |
-
|
1554 |
-
// build the statement
|
1555 |
-
for ( $j = 0; $j < $fields_cnt; $j ++ ) {
|
1556 |
-
|
1557 |
-
if ( ! isset( $row[ $j ] ) ) {
|
1558 |
-
$values[] = 'NULL';
|
1559 |
-
|
1560 |
-
} elseif ( $row[ $j ] === '0' || $row[ $j ] !== '' ) {
|
1561 |
-
|
1562 |
-
// a number
|
1563 |
-
if ( $field_num[ $j ] ) {
|
1564 |
-
$values[] = $row[ $j ];
|
1565 |
-
} else {
|
1566 |
-
$values[] = "'" . str_replace( $search, $replace, $this->sql_addslashes( $row[ $j ] ) ) . "'";
|
1567 |
-
}
|
1568 |
-
|
1569 |
-
} else {
|
1570 |
-
$values[] = "''";
|
1571 |
-
}
|
1572 |
-
|
1573 |
-
}
|
1574 |
-
|
1575 |
-
$sql_file .= " \n" . $entries . implode( ', ', $values ) . ") ;";
|
1576 |
-
|
1577 |
-
// write the rows in batches of 100
|
1578 |
-
if ( $batch_write === 100 ) {
|
1579 |
-
$batch_write = 0;
|
1580 |
-
$this->write_sql( $sql_file );
|
1581 |
-
$sql_file = '';
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
$batch_write ++;
|
1585 |
-
|
1586 |
-
unset( $values );
|
1587 |
-
|
1588 |
-
}
|
1589 |
-
|
1590 |
-
mysql_free_result( $result );
|
1591 |
-
|
1592 |
-
// Create footer/closing comment in SQL-file
|
1593 |
-
$sql_file .= "\n";
|
1594 |
-
$sql_file .= "#\n";
|
1595 |
-
$sql_file .= "# End of data contents of table " . $table . "\n";
|
1596 |
-
$sql_file .= "# --------------------------------------------------------\n";
|
1597 |
-
$sql_file .= "\n";
|
1598 |
-
|
1599 |
-
$this->write_sql( $sql_file );
|
1600 |
-
|
1601 |
-
}
|
1602 |
-
|
1603 |
-
/**
|
1604 |
-
* Better addslashes for SQL queries.
|
1605 |
-
* Taken from phpMyAdmin.
|
1606 |
-
*
|
1607 |
-
* @param string $a_string (default: '')
|
1608 |
-
* @param bool $is_like (default: false)
|
1609 |
-
*
|
1610 |
-
* @return mixed
|
1611 |
-
*/
|
1612 |
-
private function sql_addslashes( $a_string = '', $is_like = false ) {
|
1613 |
-
|
1614 |
-
if ( $is_like ) {
|
1615 |
-
$a_string = str_replace( '\\', '\\\\\\\\', $a_string );
|
1616 |
-
} else {
|
1617 |
-
$a_string = str_replace( '\\', '\\\\', $a_string );
|
1618 |
-
}
|
1619 |
-
|
1620 |
-
$a_string = str_replace( '\'', '\\\'', $a_string );
|
1621 |
-
|
1622 |
-
return $a_string;
|
1623 |
-
}
|
1624 |
-
|
1625 |
-
/**
|
1626 |
-
* Write the SQL file
|
1627 |
-
*
|
1628 |
-
* @param string $sql
|
1629 |
-
*
|
1630 |
-
* @return null|boolean
|
1631 |
-
*/
|
1632 |
-
private function write_sql( $sql ) {
|
1633 |
-
|
1634 |
-
$sqlname = $this->get_database_dump_filepath();
|
1635 |
-
|
1636 |
-
// Actually write the sql file
|
1637 |
-
if ( is_writable( $sqlname ) || ! file_exists( $sqlname ) ) {
|
1638 |
-
|
1639 |
-
if ( ! $handle = @fopen( $sqlname, 'a' ) ) {
|
1640 |
-
return;
|
1641 |
-
}
|
1642 |
-
|
1643 |
-
if ( ! fwrite( $handle, $sql ) ) {
|
1644 |
-
return;
|
1645 |
-
}
|
1646 |
-
|
1647 |
-
fclose( $handle );
|
1648 |
-
|
1649 |
-
return true;
|
1650 |
-
|
1651 |
-
}
|
1652 |
-
|
1653 |
-
}
|
1654 |
-
|
1655 |
/**
|
1656 |
* Get the errors
|
1657 |
*
|
@@ -1853,4 +1661,3 @@ class Backup {
|
|
1853 |
}
|
1854 |
|
1855 |
}
|
1856 |
-
|
2 |
|
3 |
namespace HM\BackUpWordPress;
|
4 |
use Symfony\Component\Finder\Finder;
|
5 |
+
use Ifsnop\Mysqldump as IMysqldump;
|
6 |
|
7 |
/**
|
8 |
* Generic file and database backup class
|
67 |
*/
|
68 |
private $root = '';
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
/**
|
71 |
* An array of all the files in root
|
72 |
* excluding excludes and unreadable files
|
77 |
|
78 |
/**
|
79 |
* An array of all the files in root
|
80 |
+
* that are unreadable
|
81 |
*
|
82 |
* @var array
|
83 |
*/
|
84 |
+
private $unreadable_files = array();
|
85 |
|
86 |
/**
|
87 |
* An array of all the files in root
|
88 |
+
* that will be included in the backup
|
89 |
*
|
90 |
* @var array
|
91 |
*/
|
92 |
+
protected $included_files = array();
|
93 |
|
94 |
/**
|
95 |
* An array of all the files in root
|
96 |
+
* that match the exclude rules
|
97 |
*
|
98 |
* @var array
|
99 |
*/
|
100 |
+
private $excluded_files = array();
|
101 |
|
102 |
/**
|
103 |
* Contains an array of errors
|
243 |
public static function get_home_path() {
|
244 |
|
245 |
if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT ) {
|
246 |
+
return wp_normalize_path( HMBKP_ROOT );
|
247 |
}
|
248 |
|
249 |
$home_url = home_url();
|
253 |
|
254 |
// If site_url contains home_url and they differ then assume WordPress is installed in a sub directory
|
255 |
if ( $home_url !== $site_url && strpos( $site_url, $home_url ) === 0 ) {
|
256 |
+
$home_path = trailingslashit( substr( wp_normalize_path( ABSPATH ), 0, strrpos( wp_normalize_path( ABSPATH ), str_replace( $home_url, '', $site_url ) ) ) );
|
257 |
}
|
258 |
|
259 |
+
return wp_normalize_path( $home_path );
|
260 |
|
261 |
}
|
262 |
|
314 |
|
315 |
if ( empty( $this->archive_filename ) ) {
|
316 |
$this->set_archive_filename( implode( '-', array(
|
317 |
+
sanitize_title( str_ireplace( array(
|
318 |
+
'http://',
|
319 |
+
'https://',
|
320 |
+
'www'
|
321 |
+
), '', home_url() ) ),
|
322 |
+
'backup',
|
323 |
+
current_time( 'Y-m-d-H-i-s' )
|
324 |
+
) ) . '.zip' );
|
325 |
}
|
326 |
|
327 |
return $this->archive_filename;
|
404 |
public function get_root() {
|
405 |
|
406 |
if ( empty( $this->root ) ) {
|
407 |
+
$this->set_root( wp_normalize_path( self::get_home_path() ) );
|
408 |
}
|
409 |
|
410 |
return $this->root;
|
424 |
return new \WP_Error( 'invalid_directory_path', sprintf( __( 'Invalid root path <code>%s</code> must be a valid directory path', 'backupwordpress' ), $path ) );
|
425 |
}
|
426 |
|
427 |
+
$this->root = wp_normalize_path( $path );
|
428 |
|
429 |
}
|
430 |
|
450 |
return new \WP_Error( 'invalid_existing_archive_filepath', sprintf( __( 'Invalid existing archive filepath <code>%s</code> must be a non-empty (string)', 'backupwordpress' ), $existing_archive_filepath ) );
|
451 |
}
|
452 |
|
453 |
+
$this->existing_archive_filepath = wp_normalize_path( $existing_archive_filepath );
|
454 |
|
455 |
}
|
456 |
|
566 |
|
567 |
// Find the first one which works
|
568 |
foreach ( $mysqldump_locations as $location ) {
|
569 |
+
if ( (is_null( shell_exec( 'hash ' . wp_normalize_path( $location ) . ' 2>&1' ) ) ) && @is_executable( wp_normalize_path( $location ) ) ) {
|
570 |
$this->set_mysqldump_command_path( $location );
|
571 |
break; // Found one
|
572 |
}
|
629 |
|
630 |
// Find the first one which works
|
631 |
foreach ( $zip_locations as $location ) {
|
632 |
+
if ( @is_executable( wp_normalize_path( $location ) ) ) {
|
633 |
$this->set_zip_command_path( $location );
|
634 |
break; // Found one
|
635 |
}
|
852 |
|
853 |
$this->do_action( 'hmbkp_mysqldump_started' );
|
854 |
|
855 |
+
// Guess port or socket connection type
|
856 |
+
$port_or_socket = strstr( DB_HOST, ':' );
|
857 |
+
|
858 |
+
$host = DB_HOST;
|
859 |
+
|
860 |
+
if ( ! empty( $port_or_socket ) ) {
|
861 |
+
|
862 |
+
$host = substr( DB_HOST, 0, strpos( DB_HOST, ':' ) );
|
863 |
+
|
864 |
+
$port_or_socket = substr( $port_or_socket, 1 );
|
865 |
+
|
866 |
+
if ( 0 !== strpos( $port_or_socket, '/' ) ) {
|
867 |
+
|
868 |
+
$port = intval( $port_or_socket );
|
869 |
+
|
870 |
+
$maybe_socket = strstr( $port_or_socket, ':' );
|
871 |
+
|
872 |
+
if ( ! empty( $maybe_socket ) ) {
|
873 |
+
|
874 |
+
$socket = substr( $maybe_socket, 1 );
|
875 |
+
|
876 |
+
}
|
877 |
+
|
878 |
+
} else {
|
879 |
+
|
880 |
+
$socket = $port_or_socket;
|
881 |
|
882 |
+
}
|
|
|
883 |
}
|
884 |
|
885 |
+
// PDO connection string formats:
|
886 |
+
// mysql:host=localhost;port=3307;dbname=testdb
|
887 |
+
// mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
|
888 |
+
|
889 |
+
if ( $port_or_socket ) {
|
890 |
+
if ( isset( $port ) ) {
|
891 |
+
$dsn = 'mysql:host=' . DB_HOST . ';port=' . $port . ';dbname=' . DB_NAME;
|
892 |
+
} elseif ( isset( $socket ) ) {
|
893 |
+
$dsn = 'mysql:unix_socket=' . $socket . ';dbname=' . DB_NAME;
|
894 |
+
}
|
895 |
+
} else {
|
896 |
+
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
|
897 |
}
|
898 |
|
899 |
+
// Get character set from constant if it is declared.
|
900 |
+
if ( defined( 'DB_CHARSET' ) && DB_CHARSET ) {
|
901 |
+
$charset = DB_CHARSET;
|
902 |
+
} else {
|
903 |
+
$charset = 'utf8';
|
904 |
+
}
|
905 |
|
906 |
+
if ( defined( 'DB_PASSWORD' ) && DB_PASSWORD ) {
|
907 |
+
$pwd = DB_PASSWORD;
|
908 |
+
} else {
|
909 |
+
$pwd = '';
|
910 |
}
|
911 |
|
912 |
+
if ( ! defined( 'HMBKP_MYSQLDUMP_SINGLE_TRANSACTION' ) || false !== HMBKP_MYSQLDUMP_SINGLE_TRANSACTION ) {
|
913 |
+
$single_transaction = true;
|
914 |
+
} else {
|
915 |
+
$single_transaction = false;
|
916 |
+
}
|
917 |
+
|
918 |
+
$dump_settings = array(
|
919 |
+
'default-character-set' => $charset,
|
920 |
+
'hex-blob' => true,
|
921 |
+
'single-transaction' => $single_transaction,
|
922 |
+
);
|
923 |
|
924 |
+
try {
|
|
|
|
|
|
|
|
|
|
|
925 |
|
926 |
+
// Allow passing custom options to dump process.
|
927 |
+
$dump_settings = apply_filters( 'hmbkp_mysqldump_fallback_dump_settings', $dump_settings );
|
928 |
|
929 |
+
$dump = new IMysqldump\Mysqldump( $dsn, DB_USER, $pwd, $dump_settings );
|
930 |
|
931 |
+
$dump->start( $this->get_database_dump_filepath() );
|
|
|
|
|
|
|
932 |
|
933 |
+
} catch ( \Exception $e ) {
|
934 |
+
|
935 |
+
return new \WP_Error( 'mysql-fallback-error', sprintf( __( 'mysqldump fallback error %s', 'backupwordpress' ), $e->getMessage() ) );
|
936 |
|
937 |
}
|
938 |
|
1006 |
$stderr = shell_exec( 'cd ' . escapeshellarg( $this->get_path() ) . ' && ' . escapeshellcmd( $this->get_zip_command_path() ) . ' -q ' . escapeshellarg( $this->get_archive_filepath() ) . ' ' . escapeshellarg( $this->get_database_dump_filename() ) . ' 2>&1' );
|
1007 |
|
1008 |
if ( ! empty ( $stderr ) ) {
|
1009 |
+
$this->warning( $this->get_archive_method(), $stderr );
|
1010 |
}
|
1011 |
}
|
1012 |
|
1092 |
}
|
1093 |
|
1094 |
// Excludes
|
1095 |
+
if ( $excludes && preg_match( '(' . $excludes . ')', str_ireplace( trailingslashit( $this->get_root() ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
1096 |
continue;
|
1097 |
}
|
1098 |
|
1099 |
if ( $file->isDir() ) {
|
1100 |
+
$zip->addEmptyDir( trailingslashit( str_ireplace( trailingslashit( $this->get_root() ), '', wp_normalize_path( $file->getPathname() ) ) ) );
|
1101 |
} elseif ( $file->isFile() ) {
|
1102 |
+
$zip->addFile( $file->getPathname(), str_ireplace( trailingslashit( $this->get_root() ), '', wp_normalize_path( $file->getPathname() ) ) );
|
1103 |
}
|
1104 |
|
1105 |
if ( ++ $files_added % 500 === 0 ) {
|
1243 |
}
|
1244 |
|
1245 |
// Excludes
|
1246 |
+
if ( $excludes && preg_match( '(' . $excludes . ')', str_ireplace( trailingslashit( $this->get_root() ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
1247 |
continue;
|
1248 |
}
|
1249 |
|
1283 |
}
|
1284 |
|
1285 |
// Excludes
|
1286 |
+
if ( $excludes && preg_match( '(' . $excludes . ')', str_ireplace( trailingslashit( $this->get_root() ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
1287 |
$this->excluded_files[] = $file;
|
1288 |
}
|
1289 |
|
1412 |
}
|
1413 |
|
1414 |
// Strip $this->root and conform
|
1415 |
+
$rule = str_ireplace( $this->get_root(), '', untrailingslashit( wp_normalize_path( $rule ) ) );
|
1416 |
|
1417 |
// Strip the preceeding slash
|
1418 |
if ( in_array( substr( $rule, 0, 1 ), array( '\\', '/' ) ) ) {
|
1460 |
|
1461 |
}
|
1462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1463 |
/**
|
1464 |
* Get the errors
|
1465 |
*
|
1661 |
}
|
1662 |
|
1663 |
}
|
|
classes/class-email-service.php
CHANGED
@@ -177,8 +177,8 @@ class Email_Service extends Service {
|
|
177 |
}
|
178 |
|
179 |
$subject = sprintf( __( 'Backup of %s Failed', 'backupwordpress' ), $domain );
|
180 |
-
|
181 |
-
$message = sprintf( __( 'BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Here are the errors that we\'
|
182 |
|
183 |
wp_mail( $this->get_email_address_array(), $subject, $message, $headers );
|
184 |
|
@@ -200,7 +200,7 @@ class Email_Service extends Service {
|
|
200 |
// If we didn't send the email above then send just the notification
|
201 |
if ( ! $sent ) {
|
202 |
|
203 |
-
$message = sprintf( __( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Unfortunately the backup file was too large to attach to this email.', 'backupwordpress' ) . "\n\n" . __( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $download );
|
204 |
|
205 |
wp_mail( $this->get_email_address_array(), $subject, $message, $headers );
|
206 |
|
177 |
}
|
178 |
|
179 |
$subject = sprintf( __( 'Backup of %s Failed', 'backupwordpress' ), $domain );
|
180 |
+
|
181 |
+
$message = sprintf( __( 'BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Here are the errors that we\'ve encountered:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( 'If the errors above look like Martian, forward this email to %3$s and we\'ll take a look', 'backupwordpress' ) . "\n\n" . __( "Kind Regards,\nThe Apologetic BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $error_message, 'backupwordpress@hmn.md' );
|
182 |
|
183 |
wp_mail( $this->get_email_address_array(), $subject, $message, $headers );
|
184 |
|
200 |
// If we didn't send the email above then send just the notification
|
201 |
if ( ! $sent ) {
|
202 |
|
203 |
+
$message = sprintf( __( 'BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress' ) . "\n\n" . __( 'Unfortunately, the backup file was too large to attach to this email.', 'backupwordpress' ) . "\n\n" . __( 'You can download the backup file by clicking the link below:', 'backupwordpress' ) . "\n\n" . '%2$s' . "\n\n" . __( "Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress' ), home_url(), $download );
|
204 |
|
205 |
wp_mail( $this->get_email_address_array(), $subject, $message, $headers );
|
206 |
|
classes/class-plugin.php
CHANGED
@@ -6,7 +6,7 @@ namespace HM\BackUpWordPress;
|
|
6 |
* Class Plugin
|
7 |
*/
|
8 |
final class Plugin {
|
9 |
-
const PLUGIN_VERSION = '3.3.
|
10 |
|
11 |
/**
|
12 |
* @var Plugin The singleton instance.
|
6 |
* Class Plugin
|
7 |
*/
|
8 |
final class Plugin {
|
9 |
+
const PLUGIN_VERSION = '3.3.3';
|
10 |
|
11 |
/**
|
12 |
* @var Plugin The singleton instance.
|
classes/class-schedule.php
CHANGED
@@ -468,6 +468,7 @@ class Scheduled_Backup {
|
|
468 |
|
469 |
}
|
470 |
|
|
|
471 |
$files = $this->backup->get_files();
|
472 |
|
473 |
foreach ( $files as $file ) {
|
@@ -480,9 +481,6 @@ class Scheduled_Backup {
|
|
480 |
|
481 |
}
|
482 |
|
483 |
-
// This will be the total size of the included folders MINUS default excludes.
|
484 |
-
$directory_sizes[ $this->backup->get_root() ] = array_sum( $directory_sizes );
|
485 |
-
|
486 |
set_transient( 'hmbkp_directory_filesizes', $directory_sizes, DAY_IN_SECONDS );
|
487 |
|
488 |
delete_transient( 'hmbkp_directory_filesizes_running' );
|
@@ -537,10 +535,6 @@ class Scheduled_Backup {
|
|
537 |
|
538 |
}
|
539 |
|
540 |
-
if ( $this->backup->get_root() === $file->getPathname() ) {
|
541 |
-
return $directory_sizes[ $file->getPathname() ];
|
542 |
-
}
|
543 |
-
|
544 |
$current_pathname = trailingslashit( $file->getPathname() );
|
545 |
$root = trailingslashit( $this->backup->get_root() );
|
546 |
|
@@ -569,7 +563,7 @@ class Scheduled_Backup {
|
|
569 |
}
|
570 |
|
571 |
// Directory size is now just a sum of all files across all sub directories
|
572 |
-
return array_sum( $directory_sizes );
|
573 |
|
574 |
}
|
575 |
|
@@ -647,7 +641,7 @@ class Scheduled_Backup {
|
|
647 |
|
648 |
// Check it's valid
|
649 |
if ( ! is_string( $reoccurrence ) || ! trim( $reoccurrence ) || ( ! in_array( $reoccurrence, array_keys( $hmbkp_schedules ) ) ) && 'manually' !== $reoccurrence ) {
|
650 |
-
return new \WP_Error( 'hmbkp_invalid_argument_error', sprintf( __( 'Argument 1 for %s must be a valid cron
|
651 |
}
|
652 |
|
653 |
// If the recurrence is already set to the same thing then there's no need to continue
|
@@ -975,7 +969,7 @@ class Scheduled_Backup {
|
|
975 |
|
976 |
default:
|
977 |
|
978 |
-
return new \WP_Error( 'unexpected-error', __( 'An unexpected error
|
979 |
|
980 |
endswitch;
|
981 |
|
468 |
|
469 |
}
|
470 |
|
471 |
+
// If we don't have it cached then we'll need to re-calculate
|
472 |
$files = $this->backup->get_files();
|
473 |
|
474 |
foreach ( $files as $file ) {
|
481 |
|
482 |
}
|
483 |
|
|
|
|
|
|
|
484 |
set_transient( 'hmbkp_directory_filesizes', $directory_sizes, DAY_IN_SECONDS );
|
485 |
|
486 |
delete_transient( 'hmbkp_directory_filesizes_running' );
|
535 |
|
536 |
}
|
537 |
|
|
|
|
|
|
|
|
|
538 |
$current_pathname = trailingslashit( $file->getPathname() );
|
539 |
$root = trailingslashit( $this->backup->get_root() );
|
540 |
|
563 |
}
|
564 |
|
565 |
// Directory size is now just a sum of all files across all sub directories
|
566 |
+
return absint( array_sum( $directory_sizes ) );
|
567 |
|
568 |
}
|
569 |
|
641 |
|
642 |
// Check it's valid
|
643 |
if ( ! is_string( $reoccurrence ) || ! trim( $reoccurrence ) || ( ! in_array( $reoccurrence, array_keys( $hmbkp_schedules ) ) ) && 'manually' !== $reoccurrence ) {
|
644 |
+
return new \WP_Error( 'hmbkp_invalid_argument_error', sprintf( __( 'Argument 1 for %s must be a valid cron recurrence or "manually"', 'backupwordpress' ), __METHOD__ ) );
|
645 |
}
|
646 |
|
647 |
// If the recurrence is already set to the same thing then there's no need to continue
|
969 |
|
970 |
default:
|
971 |
|
972 |
+
return new \WP_Error( 'unexpected-error', __( 'An unexpected error occurred', 'backupwordpress' ) );
|
973 |
|
974 |
endswitch;
|
975 |
|
composer.json
CHANGED
@@ -19,6 +19,7 @@
|
|
19 |
"issues": "https://github.com/humanmade/backupwordpress/issues"
|
20 |
},
|
21 |
"require": {
|
22 |
-
"symfony/finder": "~2.6"
|
|
|
23 |
}
|
24 |
}
|
19 |
"issues": "https://github.com/humanmade/backupwordpress/issues"
|
20 |
},
|
21 |
"require": {
|
22 |
+
"symfony/finder": "~2.6",
|
23 |
+
"ifsnop/mysqldump-php":"2.*"
|
24 |
}
|
25 |
}
|
composer.lock
CHANGED
@@ -4,27 +4,77 @@
|
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
-
"hash": "
|
|
|
8 |
"packages": [
|
9 |
{
|
10 |
-
"name": "
|
11 |
-
"version": "v2.
|
12 |
"source": {
|
13 |
"type": "git",
|
14 |
-
"url": "https://github.com/
|
15 |
-
"reference": "
|
16 |
},
|
17 |
"dist": {
|
18 |
"type": "zip",
|
19 |
-
"url": "https://api.github.com/repos/
|
20 |
-
"reference": "
|
21 |
"shasum": ""
|
22 |
},
|
23 |
"require": {
|
24 |
-
"php": ">=5.3.
|
25 |
},
|
26 |
"require-dev": {
|
27 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
},
|
29 |
"type": "library",
|
30 |
"extra": {
|
@@ -53,7 +103,7 @@
|
|
53 |
],
|
54 |
"description": "Symfony Finder Component",
|
55 |
"homepage": "https://symfony.com",
|
56 |
-
"time": "2015-
|
57 |
}
|
58 |
],
|
59 |
"packages-dev": [],
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
+
"hash": "a5d481f4e8a2c50cc0c488d199f4c83e",
|
8 |
+
"content-hash": "77f3dd81e4007d746a29f10fd5dce8af",
|
9 |
"packages": [
|
10 |
{
|
11 |
+
"name": "ifsnop/mysqldump-php",
|
12 |
+
"version": "v2.1",
|
13 |
"source": {
|
14 |
"type": "git",
|
15 |
+
"url": "https://github.com/ifsnop/mysqldump-php.git",
|
16 |
+
"reference": "701024dd160f15796bed8130c3bdeb26c634785a"
|
17 |
},
|
18 |
"dist": {
|
19 |
"type": "zip",
|
20 |
+
"url": "https://api.github.com/repos/ifsnop/mysqldump-php/zipball/701024dd160f15796bed8130c3bdeb26c634785a",
|
21 |
+
"reference": "701024dd160f15796bed8130c3bdeb26c634785a",
|
22 |
"shasum": ""
|
23 |
},
|
24 |
"require": {
|
25 |
+
"php": ">=5.3.0"
|
26 |
},
|
27 |
"require-dev": {
|
28 |
+
"phpunit/phpunit": "3.7.*",
|
29 |
+
"squizlabs/php_codesniffer": "1.*"
|
30 |
+
},
|
31 |
+
"type": "library",
|
32 |
+
"autoload": {
|
33 |
+
"psr-4": {
|
34 |
+
"Ifsnop\\": "src/Ifsnop/"
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"notification-url": "https://packagist.org/downloads/",
|
38 |
+
"license": [
|
39 |
+
"MIT"
|
40 |
+
],
|
41 |
+
"authors": [
|
42 |
+
{
|
43 |
+
"name": "Diego Torres",
|
44 |
+
"homepage": "https://github.com/ifsnop",
|
45 |
+
"role": "Developer"
|
46 |
+
}
|
47 |
+
],
|
48 |
+
"description": "This is a php version of linux's mysqldump in terminal \"$ mysqldump -u username -p...\"",
|
49 |
+
"homepage": "https://github.com/ifsnop/mysqldump-php",
|
50 |
+
"keywords": [
|
51 |
+
"backup",
|
52 |
+
"database",
|
53 |
+
"dump",
|
54 |
+
"export",
|
55 |
+
"mysql",
|
56 |
+
"mysqldump",
|
57 |
+
"pdo",
|
58 |
+
"sqlite"
|
59 |
+
],
|
60 |
+
"time": "2015-10-19 15:58:11"
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"name": "symfony/finder",
|
64 |
+
"version": "v2.7.6",
|
65 |
+
"source": {
|
66 |
+
"type": "git",
|
67 |
+
"url": "https://github.com/symfony/finder.git",
|
68 |
+
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d"
|
69 |
+
},
|
70 |
+
"dist": {
|
71 |
+
"type": "zip",
|
72 |
+
"url": "https://api.github.com/repos/symfony/finder/zipball/2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
|
73 |
+
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
|
74 |
+
"shasum": ""
|
75 |
+
},
|
76 |
+
"require": {
|
77 |
+
"php": ">=5.3.9"
|
78 |
},
|
79 |
"type": "library",
|
80 |
"extra": {
|
103 |
],
|
104 |
"description": "Symfony Finder Component",
|
105 |
"homepage": "https://symfony.com",
|
106 |
+
"time": "2015-10-11 09:39:48"
|
107 |
}
|
108 |
],
|
109 |
"packages-dev": [],
|
functions/interface.php
CHANGED
@@ -354,7 +354,7 @@ function hmbkp_translated_schedule_title( $slug, $title ) {
|
|
354 |
'file-hourly' => esc_html__( 'File Hourly', 'backupwordpress' ),
|
355 |
'database-hourly' => esc_html__( 'Database Hourly', 'backupwordpress' ),
|
356 |
'complete-twicedaily' => esc_html__( 'Complete Twice Daily', 'backupwordpress' ),
|
357 |
-
'file-twicedaily' => esc_html__( 'File
|
358 |
'database-twicedaily' => esc_html__( 'Database Twice Daily', 'backupwordpress' ),
|
359 |
'complete-daily' => esc_html__( 'Complete Daily', 'backupwordpress' ),
|
360 |
'file-daily' => esc_html__( 'File Daily', 'backupwordpress' ),
|
354 |
'file-hourly' => esc_html__( 'File Hourly', 'backupwordpress' ),
|
355 |
'database-hourly' => esc_html__( 'Database Hourly', 'backupwordpress' ),
|
356 |
'complete-twicedaily' => esc_html__( 'Complete Twice Daily', 'backupwordpress' ),
|
357 |
+
'file-twicedaily' => esc_html__( 'File Twice Daily', 'backupwordpress' ),
|
358 |
'database-twicedaily' => esc_html__( 'Database Twice Daily', 'backupwordpress' ),
|
359 |
'complete-daily' => esc_html__( 'Complete Daily', 'backupwordpress' ),
|
360 |
'file-daily' => esc_html__( 'File Daily', 'backupwordpress' ),
|
languages/backupwordpress.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the GPL-2+.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: BackUpWordPress 3.3.
|
6 |
"Report-Msgid-Bugs-To: backupwordpress@hmn.md\n"
|
7 |
-
"POT-Creation-Date: 2015-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -80,11 +80,11 @@ msgid ""
|
|
80 |
"for manual backups. See the %3$s for more details."
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: admin/backups-table.php:8 admin/schedule-form-excludes.php:
|
84 |
msgid "Size"
|
85 |
msgstr ""
|
86 |
|
87 |
-
#: admin/backups-table.php:9 admin/schedule-form-excludes.php:
|
88 |
msgid "Type"
|
89 |
msgstr ""
|
90 |
|
@@ -122,8 +122,8 @@ msgstr ""
|
|
122 |
|
123 |
#: admin/constants.php:17
|
124 |
msgid ""
|
125 |
-
"The path to folder you would like to store your backup files in,
|
126 |
-
"to %s."
|
127 |
msgstr ""
|
128 |
|
129 |
#: admin/constants.php:17 admin/constants.php:33 admin/constants.php:49
|
@@ -259,10 +259,11 @@ msgstr ""
|
|
259 |
#: admin/faq.php:24
|
260 |
msgid ""
|
261 |
"Most servers have a filesize limit on email attachments, it's generally "
|
262 |
-
"about 10mb. If your backup file is over that limit it won't be sent "
|
263 |
-
"attached to the email,
|
264 |
-
"download the backup
|
265 |
-
"a mail issue on your server that you'll need to contact your host
|
|
|
266 |
msgstr ""
|
267 |
|
268 |
#: admin/faq.php:26
|
@@ -280,9 +281,9 @@ msgstr ""
|
|
280 |
#: admin/faq.php:32
|
281 |
msgid ""
|
282 |
"Unless your site is very large (many gigabytes) it should only take a few "
|
283 |
-
"minutes to perform a
|
284 |
-
"than an hour it's safe to assume that something has gone wrong
|
285 |
-
"de-activating and re-activating the plugin
|
286 |
"support."
|
287 |
msgstr ""
|
288 |
|
@@ -294,7 +295,7 @@ msgstr ""
|
|
294 |
msgid ""
|
295 |
"The issue is that your <code>wp-cron.php</code> is not returning a "
|
296 |
"<code>200</code> response when hit with a HTTP request originating from "
|
297 |
-
"your own server, it could be several things
|
298 |
"with the server / site."
|
299 |
msgstr ""
|
300 |
|
@@ -313,19 +314,19 @@ msgid ""
|
|
313 |
msgstr ""
|
314 |
|
315 |
#: admin/faq.php:44
|
316 |
-
msgid "If you click manual backup does it work?"
|
317 |
msgstr ""
|
318 |
|
319 |
#: admin/faq.php:46
|
320 |
msgid ""
|
321 |
"Try adding <code>define( 'ALTERNATE_WP_CRON', true );</code> to your "
|
322 |
-
"<code>wp-config.php</code
|
323 |
msgstr ""
|
324 |
|
325 |
#: admin/faq.php:48
|
326 |
msgid ""
|
327 |
"Is your site private (i.e. is it behind some kind of authentication, "
|
328 |
-
"maintenance plugin, .htaccess)? If so wp-cron won't work until you remove "
|
329 |
"it. If you are and you temporarily remove the authentication, do backups "
|
330 |
"start working?"
|
331 |
msgstr ""
|
@@ -333,7 +334,7 @@ msgstr ""
|
|
333 |
#: admin/faq.php:50
|
334 |
msgid ""
|
335 |
"Report the results to our support team for further help. To do this, either "
|
336 |
-
"enable
|
337 |
"backupwordpress@hmn.md"
|
338 |
msgstr ""
|
339 |
|
@@ -357,12 +358,12 @@ msgstr ""
|
|
357 |
#: admin/faq.php:58
|
358 |
msgid ""
|
359 |
"If your backups are failing, it's commonly caused by a lack of available "
|
360 |
-
"resources on your server.
|
361 |
-
"
|
362 |
-
"
|
363 |
-
"report the results to our support team for further help.
|
364 |
-
"
|
365 |
-
"backupwordpress@hmn.md"
|
366 |
msgstr ""
|
367 |
|
368 |
#: admin/menu.php:13 admin/menu.php:17
|
@@ -417,82 +418,82 @@ msgid ""
|
|
417 |
"Systems\">VCS</abbr> folders and other backup plugin folders."
|
418 |
msgstr ""
|
419 |
|
420 |
-
#: admin/schedule-form-excludes.php:
|
421 |
msgid "Default rule"
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: admin/schedule-form-excludes.php:
|
425 |
msgid "Defined in wp-config.php"
|
426 |
msgstr ""
|
427 |
|
428 |
-
#: admin/schedule-form-excludes.php:
|
429 |
msgid "Stop excluding"
|
430 |
msgstr ""
|
431 |
|
432 |
-
#: admin/schedule-form-excludes.php:
|
433 |
msgid "Your Site"
|
434 |
msgstr ""
|
435 |
|
436 |
-
#: admin/schedule-form-excludes.php:
|
437 |
msgid ""
|
438 |
"Here's a directory listing of all files on your site, you can browse "
|
439 |
"through and exclude files or folders that you don't want included in your "
|
440 |
"backup."
|
441 |
msgstr ""
|
442 |
|
443 |
-
#: admin/schedule-form-excludes.php:
|
444 |
msgid "Name"
|
445 |
msgstr ""
|
446 |
|
447 |
-
#: admin/schedule-form-excludes.php:
|
448 |
msgid "Permissions"
|
449 |
msgstr ""
|
450 |
|
451 |
-
#: admin/schedule-form-excludes.php:
|
452 |
msgid "Status"
|
453 |
msgstr ""
|
454 |
|
455 |
-
#: admin/schedule-form-excludes.php:
|
456 |
msgid "Refresh"
|
457 |
msgstr ""
|
458 |
|
459 |
-
#: admin/schedule-form-excludes.php:
|
460 |
msgid "Symlink"
|
461 |
msgstr ""
|
462 |
|
463 |
-
#: admin/schedule-form-excludes.php:
|
464 |
msgid "Folder"
|
465 |
msgstr ""
|
466 |
|
467 |
-
#: admin/schedule-form-excludes.php:
|
468 |
msgid "Recalculate the size of this directory"
|
469 |
msgstr ""
|
470 |
|
471 |
-
#: admin/schedule-form-excludes.php:
|
472 |
msgid "File"
|
473 |
msgstr ""
|
474 |
|
475 |
-
#: admin/schedule-form-excludes.php:
|
476 |
msgid "Unreadable files won't be backed up."
|
477 |
msgstr ""
|
478 |
|
479 |
-
#: admin/schedule-form-excludes.php:
|
480 |
msgid "Unreadable"
|
481 |
msgstr ""
|
482 |
|
483 |
-
#: admin/schedule-form-excludes.php:
|
484 |
msgid "Excluded"
|
485 |
msgstr ""
|
486 |
|
487 |
-
#: admin/schedule-form-excludes.php:
|
488 |
msgid "Exclude →"
|
489 |
msgstr ""
|
490 |
|
491 |
-
#: admin/schedule-form-excludes.php:
|
492 |
msgid "This folder is empty"
|
493 |
msgstr ""
|
494 |
|
495 |
-
#: admin/schedule-form-excludes.php:
|
496 |
#: admin/schedule-settings.php:88
|
497 |
msgid "Done"
|
498 |
msgstr ""
|
@@ -695,51 +696,55 @@ msgstr ""
|
|
695 |
msgid "BackUpWordPress Error"
|
696 |
msgstr ""
|
697 |
|
698 |
-
#: classes/class-backup.php:
|
699 |
msgid "archive filename must be a non-empty string"
|
700 |
msgstr ""
|
701 |
|
702 |
-
#: classes/class-backup.php:
|
703 |
msgid "invalid file extension for archive filename <code>%s</code>"
|
704 |
msgstr ""
|
705 |
|
706 |
-
#: classes/class-backup.php:
|
707 |
msgid "database dump filename must be a non-empty string"
|
708 |
msgstr ""
|
709 |
|
710 |
-
#: classes/class-backup.php:
|
711 |
msgid "invalid file extension for database dump filename <code>%s</code>"
|
712 |
msgstr ""
|
713 |
|
714 |
-
#: classes/class-backup.php:
|
715 |
msgid "Invalid root path <code>%s</code> must be a valid directory path"
|
716 |
msgstr ""
|
717 |
|
718 |
-
#: classes/class-backup.php:
|
719 |
msgid ""
|
720 |
"Invalid existing archive filepath <code>%s</code> must be a non-empty "
|
721 |
"(string)"
|
722 |
msgstr ""
|
723 |
|
724 |
-
#: classes/class-backup.php:
|
725 |
msgid ""
|
726 |
"Invalid backup type <code>%s</code> must be one of (string) file, database "
|
727 |
"or complete"
|
728 |
msgstr ""
|
729 |
|
730 |
-
#: classes/class-backup.php:
|
|
|
|
|
|
|
|
|
731 |
msgid "Zip command is not available."
|
732 |
msgstr ""
|
733 |
|
734 |
-
#: classes/class-backup.php:
|
735 |
msgid "ZipArchive method is not available."
|
736 |
msgstr ""
|
737 |
|
738 |
-
#: classes/class-backup.php:
|
739 |
msgid "No valid archive method found."
|
740 |
msgstr ""
|
741 |
|
742 |
-
#: classes/class-backup.php:
|
743 |
msgid "Could not connect to mysql"
|
744 |
msgstr ""
|
745 |
|
@@ -801,7 +806,7 @@ msgid "BackUpWordPress was unable to backup your site %1$s."
|
|
801 |
msgstr ""
|
802 |
|
803 |
#: classes/class-email-service.php:181
|
804 |
-
msgid "Here are the errors that we'
|
805 |
msgstr ""
|
806 |
|
807 |
#: classes/class-email-service.php:181
|
@@ -839,7 +844,7 @@ msgid ""
|
|
839 |
msgstr ""
|
840 |
|
841 |
#: classes/class-email-service.php:203
|
842 |
-
msgid "Unfortunately the backup file was too large to attach to this email."
|
843 |
msgstr ""
|
844 |
|
845 |
#: classes/class-path.php:249
|
@@ -888,68 +893,68 @@ msgstr ""
|
|
888 |
msgid "Argument 1 for %s must be a valid integer"
|
889 |
msgstr ""
|
890 |
|
891 |
-
#: classes/class-schedule.php:
|
892 |
msgid "Argument 1 for %s must be a valid future timestamp"
|
893 |
msgstr ""
|
894 |
|
895 |
-
#: classes/class-schedule.php:
|
896 |
-
msgid "Argument 1 for %s must be a valid cron
|
897 |
msgstr ""
|
898 |
|
899 |
-
#: classes/class-schedule.php:
|
900 |
msgid "Starting Backup"
|
901 |
msgstr ""
|
902 |
|
903 |
-
#: classes/class-schedule.php:
|
904 |
msgid "Error writing to file. (%s)"
|
905 |
msgstr ""
|
906 |
|
907 |
-
#: classes/class-schedule.php:
|
908 |
msgid "Dumping Database %s"
|
909 |
msgstr ""
|
910 |
|
911 |
-
#: classes/class-schedule.php:
|
912 |
msgid "Verifying Database Dump %s"
|
913 |
msgstr ""
|
914 |
|
915 |
-
#: classes/class-schedule.php:
|
916 |
msgid "Creating zip archive %s"
|
917 |
msgstr ""
|
918 |
|
919 |
-
#: classes/class-schedule.php:
|
920 |
msgid "Verifying Zip Archive %s"
|
921 |
msgstr ""
|
922 |
|
923 |
-
#: classes/class-schedule.php:
|
924 |
msgid "Finishing Backup"
|
925 |
msgstr ""
|
926 |
|
927 |
-
#: classes/class-schedule.php:
|
928 |
-
msgid "An unexpected error
|
929 |
msgstr ""
|
930 |
|
931 |
-
#: classes/class-schedule.php:
|
932 |
#. translators: min=minute
|
933 |
msgid "%s min"
|
934 |
msgid_plural "%s mins"
|
935 |
msgstr[0] ""
|
936 |
msgstr[1] ""
|
937 |
|
938 |
-
#: classes/class-schedule.php:
|
939 |
msgid "%s hour"
|
940 |
msgid_plural "%s hours"
|
941 |
msgstr[0] ""
|
942 |
msgstr[1] ""
|
943 |
|
944 |
-
#: classes/class-schedule.php:
|
945 |
msgid "Argument 1 for %s must be a non-empty string"
|
946 |
msgstr ""
|
947 |
|
948 |
-
#: classes/class-schedule.php:
|
949 |
msgid "%s doesn't exist"
|
950 |
msgstr ""
|
951 |
|
952 |
-
#: classes/class-schedule.php:
|
953 |
msgid "That backup wasn't created by this schedule"
|
954 |
msgstr ""
|
955 |
|
@@ -1131,7 +1136,7 @@ msgid "Complete Twice Daily"
|
|
1131 |
msgstr ""
|
1132 |
|
1133 |
#: functions/interface.php:357
|
1134 |
-
msgid "File
|
1135 |
msgstr ""
|
1136 |
|
1137 |
#: functions/interface.php:358
|
2 |
# This file is distributed under the GPL-2+.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: BackUpWordPress 3.3.2\n"
|
6 |
"Report-Msgid-Bugs-To: backupwordpress@hmn.md\n"
|
7 |
+
"POT-Creation-Date: 2015-11-13 13:55:19+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
80 |
"for manual backups. See the %3$s for more details."
|
81 |
msgstr ""
|
82 |
|
83 |
+
#: admin/backups-table.php:8 admin/schedule-form-excludes.php:102
|
84 |
msgid "Size"
|
85 |
msgstr ""
|
86 |
|
87 |
+
#: admin/backups-table.php:9 admin/schedule-form-excludes.php:104
|
88 |
msgid "Type"
|
89 |
msgstr ""
|
90 |
|
122 |
|
123 |
#: admin/constants.php:17
|
124 |
msgid ""
|
125 |
+
"The path to the folder you would like to store your backup files in, "
|
126 |
+
"defaults to %s."
|
127 |
msgstr ""
|
128 |
|
129 |
#: admin/constants.php:17 admin/constants.php:33 admin/constants.php:49
|
259 |
#: admin/faq.php:24
|
260 |
msgid ""
|
261 |
"Most servers have a filesize limit on email attachments, it's generally "
|
262 |
+
"about 10mb. If your backup file is over that limit, it won't be sent "
|
263 |
+
"attached to the email. Instead, you should receive an email with a link to "
|
264 |
+
"download the backup. If you aren't even receiving that, then you likely "
|
265 |
+
"have a mail issue on your server that you'll need to contact your host "
|
266 |
+
"about."
|
267 |
msgstr ""
|
268 |
|
269 |
#: admin/faq.php:26
|
281 |
#: admin/faq.php:32
|
282 |
msgid ""
|
283 |
"Unless your site is very large (many gigabytes) it should only take a few "
|
284 |
+
"minutes to perform a backup. If your back up has been running for longer "
|
285 |
+
"than an hour, it's safe to assume that something has gone wrong. Try "
|
286 |
+
"de-activating and re-activating the plugin. If it keeps happening, contact "
|
287 |
"support."
|
288 |
msgstr ""
|
289 |
|
295 |
msgid ""
|
296 |
"The issue is that your <code>wp-cron.php</code> is not returning a "
|
297 |
"<code>200</code> response when hit with a HTTP request originating from "
|
298 |
+
"your own server, it could be several things. In most cases, it's an issue "
|
299 |
"with the server / site."
|
300 |
msgstr ""
|
301 |
|
314 |
msgstr ""
|
315 |
|
316 |
#: admin/faq.php:44
|
317 |
+
msgid "If you click manual backup, does it work?"
|
318 |
msgstr ""
|
319 |
|
320 |
#: admin/faq.php:46
|
321 |
msgid ""
|
322 |
"Try adding <code>define( 'ALTERNATE_WP_CRON', true );</code> to your "
|
323 |
+
"<code>wp-config.php</code>. Do automatic backups work?"
|
324 |
msgstr ""
|
325 |
|
326 |
#: admin/faq.php:48
|
327 |
msgid ""
|
328 |
"Is your site private (i.e. is it behind some kind of authentication, "
|
329 |
+
"maintenance plugin, .htaccess)? If so, wp-cron won't work until you remove "
|
330 |
"it. If you are and you temporarily remove the authentication, do backups "
|
331 |
"start working?"
|
332 |
msgstr ""
|
334 |
#: admin/faq.php:50
|
335 |
msgid ""
|
336 |
"Report the results to our support team for further help. To do this, either "
|
337 |
+
"enable support from your Admin Dashboard (recommended), or email "
|
338 |
"backupwordpress@hmn.md"
|
339 |
msgstr ""
|
340 |
|
358 |
#: admin/faq.php:58
|
359 |
msgid ""
|
360 |
"If your backups are failing, it's commonly caused by a lack of available "
|
361 |
+
"resources on your server. To establish this is the case, exclude the "
|
362 |
+
"complete (or parts of the) uploads folder and run a backup. If that "
|
363 |
+
"succeeds, you know it's probably a server issue. If it does not succeed, "
|
364 |
+
"report the results to our support team for further help. You can contact "
|
365 |
+
"support by enabling support from your Admin Dashboard (recommended), or "
|
366 |
+
"emailing backupwordpress@hmn.md"
|
367 |
msgstr ""
|
368 |
|
369 |
#: admin/menu.php:13 admin/menu.php:17
|
418 |
"Systems\">VCS</abbr> folders and other backup plugin folders."
|
419 |
msgstr ""
|
420 |
|
421 |
+
#: admin/schedule-form-excludes.php:43
|
422 |
msgid "Default rule"
|
423 |
msgstr ""
|
424 |
|
425 |
+
#: admin/schedule-form-excludes.php:47
|
426 |
msgid "Defined in wp-config.php"
|
427 |
msgstr ""
|
428 |
|
429 |
+
#: admin/schedule-form-excludes.php:54
|
430 |
msgid "Stop excluding"
|
431 |
msgstr ""
|
432 |
|
433 |
+
#: admin/schedule-form-excludes.php:70
|
434 |
msgid "Your Site"
|
435 |
msgstr ""
|
436 |
|
437 |
+
#: admin/schedule-form-excludes.php:72
|
438 |
msgid ""
|
439 |
"Here's a directory listing of all files on your site, you can browse "
|
440 |
"through and exclude files or folders that you don't want included in your "
|
441 |
"backup."
|
442 |
msgstr ""
|
443 |
|
444 |
+
#: admin/schedule-form-excludes.php:101
|
445 |
msgid "Name"
|
446 |
msgstr ""
|
447 |
|
448 |
+
#: admin/schedule-form-excludes.php:103
|
449 |
msgid "Permissions"
|
450 |
msgstr ""
|
451 |
|
452 |
+
#: admin/schedule-form-excludes.php:105
|
453 |
msgid "Status"
|
454 |
msgstr ""
|
455 |
|
456 |
+
#: admin/schedule-form-excludes.php:165 admin/schedule-form-excludes.php:283
|
457 |
msgid "Refresh"
|
458 |
msgstr ""
|
459 |
|
460 |
+
#: admin/schedule-form-excludes.php:182 admin/schedule-form-excludes.php:307
|
461 |
msgid "Symlink"
|
462 |
msgstr ""
|
463 |
|
464 |
+
#: admin/schedule-form-excludes.php:186 admin/schedule-form-excludes.php:311
|
465 |
msgid "Folder"
|
466 |
msgstr ""
|
467 |
|
468 |
+
#: admin/schedule-form-excludes.php:281
|
469 |
msgid "Recalculate the size of this directory"
|
470 |
msgstr ""
|
471 |
|
472 |
+
#: admin/schedule-form-excludes.php:315
|
473 |
msgid "File"
|
474 |
msgstr ""
|
475 |
|
476 |
+
#: admin/schedule-form-excludes.php:326
|
477 |
msgid "Unreadable files won't be backed up."
|
478 |
msgstr ""
|
479 |
|
480 |
+
#: admin/schedule-form-excludes.php:326
|
481 |
msgid "Unreadable"
|
482 |
msgstr ""
|
483 |
|
484 |
+
#: admin/schedule-form-excludes.php:330
|
485 |
msgid "Excluded"
|
486 |
msgstr ""
|
487 |
|
488 |
+
#: admin/schedule-form-excludes.php:346
|
489 |
msgid "Exclude →"
|
490 |
msgstr ""
|
491 |
|
492 |
+
#: admin/schedule-form-excludes.php:359
|
493 |
msgid "This folder is empty"
|
494 |
msgstr ""
|
495 |
|
496 |
+
#: admin/schedule-form-excludes.php:371 admin/schedule-form.php:195
|
497 |
#: admin/schedule-settings.php:88
|
498 |
msgid "Done"
|
499 |
msgstr ""
|
696 |
msgid "BackUpWordPress Error"
|
697 |
msgstr ""
|
698 |
|
699 |
+
#: classes/class-backup.php:341
|
700 |
msgid "archive filename must be a non-empty string"
|
701 |
msgstr ""
|
702 |
|
703 |
+
#: classes/class-backup.php:345
|
704 |
msgid "invalid file extension for archive filename <code>%s</code>"
|
705 |
msgstr ""
|
706 |
|
707 |
+
#: classes/class-backup.php:386
|
708 |
msgid "database dump filename must be a non-empty string"
|
709 |
msgstr ""
|
710 |
|
711 |
+
#: classes/class-backup.php:390
|
712 |
msgid "invalid file extension for database dump filename <code>%s</code>"
|
713 |
msgstr ""
|
714 |
|
715 |
+
#: classes/class-backup.php:424
|
716 |
msgid "Invalid root path <code>%s</code> must be a valid directory path"
|
717 |
msgstr ""
|
718 |
|
719 |
+
#: classes/class-backup.php:450
|
720 |
msgid ""
|
721 |
"Invalid existing archive filepath <code>%s</code> must be a non-empty "
|
722 |
"(string)"
|
723 |
msgstr ""
|
724 |
|
725 |
+
#: classes/class-backup.php:505
|
726 |
msgid ""
|
727 |
"Invalid backup type <code>%s</code> must be one of (string) file, database "
|
728 |
"or complete"
|
729 |
msgstr ""
|
730 |
|
731 |
+
#: classes/class-backup.php:935
|
732 |
+
msgid "mysqldump fallback error %s"
|
733 |
+
msgstr ""
|
734 |
+
|
735 |
+
#: classes/class-backup.php:957
|
736 |
msgid "Zip command is not available."
|
737 |
msgstr ""
|
738 |
|
739 |
+
#: classes/class-backup.php:964
|
740 |
msgid "ZipArchive method is not available."
|
741 |
msgstr ""
|
742 |
|
743 |
+
#: classes/class-backup.php:968 classes/class-backup.php:980
|
744 |
msgid "No valid archive method found."
|
745 |
msgstr ""
|
746 |
|
747 |
+
#: classes/class-backup.php:1659
|
748 |
msgid "Could not connect to mysql"
|
749 |
msgstr ""
|
750 |
|
806 |
msgstr ""
|
807 |
|
808 |
#: classes/class-email-service.php:181
|
809 |
+
msgid "Here are the errors that we've encountered:"
|
810 |
msgstr ""
|
811 |
|
812 |
#: classes/class-email-service.php:181
|
844 |
msgstr ""
|
845 |
|
846 |
#: classes/class-email-service.php:203
|
847 |
+
msgid "Unfortunately, the backup file was too large to attach to this email."
|
848 |
msgstr ""
|
849 |
|
850 |
#: classes/class-path.php:249
|
893 |
msgid "Argument 1 for %s must be a valid integer"
|
894 |
msgstr ""
|
895 |
|
896 |
+
#: classes/class-schedule.php:607
|
897 |
msgid "Argument 1 for %s must be a valid future timestamp"
|
898 |
msgstr ""
|
899 |
|
900 |
+
#: classes/class-schedule.php:644
|
901 |
+
msgid "Argument 1 for %s must be a valid cron recurrence or \"manually\""
|
902 |
msgstr ""
|
903 |
|
904 |
+
#: classes/class-schedule.php:763 functions/interface.php:293
|
905 |
msgid "Starting Backup"
|
906 |
msgstr ""
|
907 |
|
908 |
+
#: classes/class-schedule.php:850
|
909 |
msgid "Error writing to file. (%s)"
|
910 |
msgstr ""
|
911 |
|
912 |
+
#: classes/class-schedule.php:901
|
913 |
msgid "Dumping Database %s"
|
914 |
msgstr ""
|
915 |
|
916 |
+
#: classes/class-schedule.php:906
|
917 |
msgid "Verifying Database Dump %s"
|
918 |
msgstr ""
|
919 |
|
920 |
+
#: classes/class-schedule.php:911
|
921 |
msgid "Creating zip archive %s"
|
922 |
msgstr ""
|
923 |
|
924 |
+
#: classes/class-schedule.php:916
|
925 |
msgid "Verifying Zip Archive %s"
|
926 |
msgstr ""
|
927 |
|
928 |
+
#: classes/class-schedule.php:921
|
929 |
msgid "Finishing Backup"
|
930 |
msgstr ""
|
931 |
|
932 |
+
#: classes/class-schedule.php:972
|
933 |
+
msgid "An unexpected error occurred"
|
934 |
msgstr ""
|
935 |
|
936 |
+
#: classes/class-schedule.php:1035
|
937 |
#. translators: min=minute
|
938 |
msgid "%s min"
|
939 |
msgid_plural "%s mins"
|
940 |
msgstr[0] ""
|
941 |
msgstr[1] ""
|
942 |
|
943 |
+
#: classes/class-schedule.php:1045
|
944 |
msgid "%s hour"
|
945 |
msgid_plural "%s hours"
|
946 |
msgstr[0] ""
|
947 |
msgstr[1] ""
|
948 |
|
949 |
+
#: classes/class-schedule.php:1107
|
950 |
msgid "Argument 1 for %s must be a non-empty string"
|
951 |
msgstr ""
|
952 |
|
953 |
+
#: classes/class-schedule.php:1112
|
954 |
msgid "%s doesn't exist"
|
955 |
msgstr ""
|
956 |
|
957 |
+
#: classes/class-schedule.php:1117
|
958 |
msgid "That backup wasn't created by this schedule"
|
959 |
msgstr ""
|
960 |
|
1136 |
msgstr ""
|
1137 |
|
1138 |
#: functions/interface.php:357
|
1139 |
+
msgid "File Twice Daily"
|
1140 |
msgstr ""
|
1141 |
|
1142 |
#: functions/interface.php:358
|
phpunit.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="tests/bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<testsuites>
|
10 |
+
<testsuite name="backup">
|
11 |
+
<directory prefix="test" suffix=".php">tests/backup</directory>
|
12 |
+
</testsuite>
|
13 |
+
<testsuite name="schedule">
|
14 |
+
<directory prefix="test" suffix=".php">tests/schedule</directory>
|
15 |
+
</testsuite>
|
16 |
+
<testsuite name="other">
|
17 |
+
<directory prefix="test" suffix=".php">tests/other</directory>
|
18 |
+
</testsuite>
|
19 |
+
</testsuites>
|
20 |
+
<groups>
|
21 |
+
<exclude>
|
22 |
+
<group>full-backup</group>
|
23 |
+
</exclude>
|
24 |
+
</groups>
|
25 |
+
</phpunit>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: humanmade, willmot, pauldewouters, joehoyle, mattheu, tcrsavage, c
|
|
3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 4.4
|
6 |
-
Stable tag: 3.3.
|
7 |
|
8 |
Simple automated backups of your WordPress-powered website.
|
9 |
|
@@ -66,7 +66,7 @@ No.
|
|
66 |
|
67 |
**I'm not receiving my backups by email**
|
68 |
|
69 |
-
Most servers have a filesize limit on email attachments, it's generally about 10mb. If your backup file is over that limit it won't be sent attached to the email,
|
70 |
|
71 |
**How many backups are stored by default?**
|
72 |
|
@@ -74,11 +74,11 @@ BackUpWordPress stores the last 10 backups by default.
|
|
74 |
|
75 |
**How long should a backup take?**
|
76 |
|
77 |
-
Unless your site is very large (many gigabytes) it should only take a few minutes to perform a
|
78 |
|
79 |
**What do I do if I get the wp-cron error message?**
|
80 |
|
81 |
-
The issue is that your `wp-cron.php` is not returning a `200` response when hit with a HTTP request originating from your own server, it could be several things
|
82 |
|
83 |
There are some things you can test to confirm this is the issue.
|
84 |
|
@@ -86,13 +86,13 @@ There are some things you can test to confirm this is the issue.
|
|
86 |
|
87 |
* Are you hosted on Heart Internet? (wp-cron may not be supported by Heart Internet, see below for work-around.)
|
88 |
|
89 |
-
* If you click manual backup does it work?
|
90 |
|
91 |
-
* Try adding `define( 'ALTERNATE_WP_CRON', true );` to your `wp-config.php
|
92 |
|
93 |
-
* Is your site private (i.e. is it behind some kind of authentication, maintenance plugin, .htaccess)? If so wp-cron won't work until you remove it. If you are and you temporarily remove the authentication, do backups start working?
|
94 |
|
95 |
-
Report the results to our support team for further help. To do this, either enable
|
96 |
|
97 |
**How to get BackUpWordPress working in Heart Internet**
|
98 |
|
@@ -100,7 +100,7 @@ The script to be entered into the Heart Internet cPanel is: `/usr/bin/php5 /home
|
|
100 |
|
101 |
**My backups seem to be failing?**
|
102 |
|
103 |
-
If your backups are failing, it's commonly caused by a lack of available resources on your server.
|
104 |
|
105 |
**Further Support & Feedback**
|
106 |
|
@@ -118,10 +118,6 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
118 |
|
119 |
== Upgrade Notice ==
|
120 |
|
121 |
-
= 3.3.2 =
|
122 |
-
|
123 |
-
* Updates and improvements translations
|
124 |
-
|
125 |
= 3.3.1 =
|
126 |
|
127 |
* Fixes a bug that would prevent downloading backups since 3.3.0 - please update.
|
@@ -137,7 +133,7 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
137 |
= 3.1.3 =
|
138 |
|
139 |
* Fixes backwards compatibility for add-ons and avoids a Fatal Error. Please upgrade straight to this version before upgrading your add-ons.
|
140 |
-
|
141 |
= 3.0.4 =
|
142 |
|
143 |
* Fixes a few minor bugs. Immediate update is recommended.
|
@@ -152,6 +148,18 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
### 3.3.1 / 2015-10-12
|
156 |
|
157 |
* Fix false positive error message.
|
3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 4.4
|
6 |
+
Stable tag: 3.3.3
|
7 |
|
8 |
Simple automated backups of your WordPress-powered website.
|
9 |
|
66 |
|
67 |
**I'm not receiving my backups by email**
|
68 |
|
69 |
+
Most servers have a filesize limit on email attachments, it's generally about 10mb. If your backup file is over that limit, it won't be sent attached to the email. Instead, you should receive an email with a link to download the backup. If you aren't even receiving that, then you likely have a mail issue on your server that you'll need to contact your host about.
|
70 |
|
71 |
**How many backups are stored by default?**
|
72 |
|
74 |
|
75 |
**How long should a backup take?**
|
76 |
|
77 |
+
Unless your site is very large (many gigabytes) it should only take a few minutes to perform a backup. If your back up has been running for longer than an hour, it's safe to assume that something has gone wrong. Try de-activating and re-activating the plugin. If it keeps happening, contact support.
|
78 |
|
79 |
**What do I do if I get the wp-cron error message?**
|
80 |
|
81 |
+
The issue is that your `wp-cron.php` is not returning a `200` response when hit with a HTTP request originating from your own server, it could be several things. In most cases, it's an issue with the server / site.
|
82 |
|
83 |
There are some things you can test to confirm this is the issue.
|
84 |
|
86 |
|
87 |
* Are you hosted on Heart Internet? (wp-cron may not be supported by Heart Internet, see below for work-around.)
|
88 |
|
89 |
+
* If you click manual backup, does it work?
|
90 |
|
91 |
+
* Try adding `define( 'ALTERNATE_WP_CRON', true );` to your `wp-config.php`. Do automatic backups work?
|
92 |
|
93 |
+
* Is your site private (i.e. is it behind some kind of authentication, maintenance plugin, .htaccess)? If so, wp-cron won't work until you remove it. If you are and you temporarily remove the authentication, do backups start working?
|
94 |
|
95 |
+
Report the results to our support team for further help. To do this, either enable support from your Admin Dashboard (recommended), or email backupwordpress@hmn.md
|
96 |
|
97 |
**How to get BackUpWordPress working in Heart Internet**
|
98 |
|
100 |
|
101 |
**My backups seem to be failing?**
|
102 |
|
103 |
+
If your backups are failing, it's commonly caused by a lack of available resources on your server. To establish this is the case, exclude the complete (or parts of the) uploads folder and run a backup. If that succeeds, you know it's probably a server issue. If it does not succeed, report the results to our support team for further help. You can contact support by enabling support from your Admin Dashboard (recommended), or emailing backupwordpress@hmn.md
|
104 |
|
105 |
**Further Support & Feedback**
|
106 |
|
118 |
|
119 |
== Upgrade Notice ==
|
120 |
|
|
|
|
|
|
|
|
|
121 |
= 3.3.1 =
|
122 |
|
123 |
* Fixes a bug that would prevent downloading backups since 3.3.0 - please update.
|
133 |
= 3.1.3 =
|
134 |
|
135 |
* Fixes backwards compatibility for add-ons and avoids a Fatal Error. Please upgrade straight to this version before upgrading your add-ons.
|
136 |
+
|
137 |
= 3.0.4 =
|
138 |
|
139 |
* Fixes a few minor bugs. Immediate update is recommended.
|
148 |
|
149 |
== Changelog ==
|
150 |
|
151 |
+
### 3.3.3 / 2015-11-13
|
152 |
+
|
153 |
+
* Fix broken Intercom support window
|
154 |
+
* Fixes Typos in i18n strings
|
155 |
+
* Backups finish faster
|
156 |
+
* Fix an issue that caused the site size to report as twice as large as it should
|
157 |
+
* Adds PHP mysqldump fallback lib
|
158 |
+
|
159 |
+
### 3.3.2 / 2015-10-15
|
160 |
+
|
161 |
+
* Mis improvements
|
162 |
+
|
163 |
### 3.3.1 / 2015-10-12
|
164 |
|
165 |
* Fix false positive error message.
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
|
|
7 |
|
8 |
return array(
|
9 |
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
|
|
|
10 |
);
|
7 |
|
8 |
return array(
|
9 |
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
|
10 |
+
'Ifsnop\\' => array($vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop'),
|
11 |
);
|
vendor/composer/installed.json
CHANGED
@@ -1,26 +1,77 @@
|
|
1 |
[
|
2 |
{
|
3 |
-
"name": "
|
4 |
-
"version": "v2.
|
5 |
-
"version_normalized": "2.
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
-
"url": "https://github.com/
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
18 |
-
"php": ">=5.3.
|
19 |
},
|
20 |
"require-dev": {
|
21 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
},
|
23 |
-
"time": "2015-
|
24 |
"type": "library",
|
25 |
"extra": {
|
26 |
"branch-alias": {
|
1 |
[
|
2 |
{
|
3 |
+
"name": "ifsnop/mysqldump-php",
|
4 |
+
"version": "v2.1",
|
5 |
+
"version_normalized": "2.1.0.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
+
"url": "https://github.com/ifsnop/mysqldump-php.git",
|
9 |
+
"reference": "701024dd160f15796bed8130c3bdeb26c634785a"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/ifsnop/mysqldump-php/zipball/701024dd160f15796bed8130c3bdeb26c634785a",
|
14 |
+
"reference": "701024dd160f15796bed8130c3bdeb26c634785a",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
18 |
+
"php": ">=5.3.0"
|
19 |
},
|
20 |
"require-dev": {
|
21 |
+
"phpunit/phpunit": "3.7.*",
|
22 |
+
"squizlabs/php_codesniffer": "1.*"
|
23 |
+
},
|
24 |
+
"time": "2015-10-19 15:58:11",
|
25 |
+
"type": "library",
|
26 |
+
"installation-source": "dist",
|
27 |
+
"autoload": {
|
28 |
+
"psr-4": {
|
29 |
+
"Ifsnop\\": "src/Ifsnop/"
|
30 |
+
}
|
31 |
+
},
|
32 |
+
"notification-url": "https://packagist.org/downloads/",
|
33 |
+
"license": [
|
34 |
+
"MIT"
|
35 |
+
],
|
36 |
+
"authors": [
|
37 |
+
{
|
38 |
+
"name": "Diego Torres",
|
39 |
+
"homepage": "https://github.com/ifsnop",
|
40 |
+
"role": "Developer"
|
41 |
+
}
|
42 |
+
],
|
43 |
+
"description": "This is a php version of linux's mysqldump in terminal \"$ mysqldump -u username -p...\"",
|
44 |
+
"homepage": "https://github.com/ifsnop/mysqldump-php",
|
45 |
+
"keywords": [
|
46 |
+
"backup",
|
47 |
+
"database",
|
48 |
+
"dump",
|
49 |
+
"export",
|
50 |
+
"mysql",
|
51 |
+
"mysqldump",
|
52 |
+
"pdo",
|
53 |
+
"sqlite"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"name": "symfony/finder",
|
58 |
+
"version": "v2.7.6",
|
59 |
+
"version_normalized": "2.7.6.0",
|
60 |
+
"source": {
|
61 |
+
"type": "git",
|
62 |
+
"url": "https://github.com/symfony/finder.git",
|
63 |
+
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d"
|
64 |
+
},
|
65 |
+
"dist": {
|
66 |
+
"type": "zip",
|
67 |
+
"url": "https://api.github.com/repos/symfony/finder/zipball/2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
|
68 |
+
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
|
69 |
+
"shasum": ""
|
70 |
+
},
|
71 |
+
"require": {
|
72 |
+
"php": ">=5.3.9"
|
73 |
},
|
74 |
+
"time": "2015-10-11 09:39:48",
|
75 |
"type": "library",
|
76 |
"extra": {
|
77 |
"branch-alias": {
|
vendor/ifsnop/mysqldump-php/composer.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "ifsnop/mysqldump-php",
|
3 |
+
"description": "This is a php version of linux's mysqldump in terminal \"$ mysqldump -u username -p...\"",
|
4 |
+
"type": "library",
|
5 |
+
"keywords": ["backup", "mysqldump", "export", "dump", "mysql", "sqlite", "pdo", "database"],
|
6 |
+
"homepage": "https://github.com/ifsnop/mysqldump-php",
|
7 |
+
"license": "MIT",
|
8 |
+
"minimum-stability": "stable",
|
9 |
+
"authors": [
|
10 |
+
{
|
11 |
+
"name" : "Diego Torres",
|
12 |
+
"homepage": "https://github.com/ifsnop",
|
13 |
+
"role": "Developer"
|
14 |
+
}
|
15 |
+
],
|
16 |
+
"require": {
|
17 |
+
"php": ">=5.3.0"
|
18 |
+
},
|
19 |
+
"require-dev": {
|
20 |
+
"squizlabs/php_codesniffer": "1.*",
|
21 |
+
"phpunit/phpunit": "3.7.*"
|
22 |
+
},
|
23 |
+
"autoload": {
|
24 |
+
"psr-4": {"Ifsnop\\": "src/Ifsnop/"}
|
25 |
+
}
|
26 |
+
}
|
vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php
ADDED
@@ -0,0 +1,1717 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mysqldump File Doc Comment
|
4 |
+
*
|
5 |
+
* PHP version 5
|
6 |
+
*
|
7 |
+
* @category Library
|
8 |
+
* @package Ifsnop\Mysqldump
|
9 |
+
* @author Michael J. Calkins <clouddueling@github.com>
|
10 |
+
* @author Diego Torres <ifsnop@github.com>
|
11 |
+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
12 |
+
* @link https://github.com/ifsnop/mysqldump-php
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
|
16 |
+
namespace Ifsnop\Mysqldump;
|
17 |
+
|
18 |
+
use Exception;
|
19 |
+
use PDO;
|
20 |
+
use PDOException;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Mysqldump Class Doc Comment
|
24 |
+
*
|
25 |
+
* @category Library
|
26 |
+
* @package Ifsnop\Mysqldump
|
27 |
+
* @author Michael J. Calkins <clouddueling@github.com>
|
28 |
+
* @author Diego Torres <ifsnop@github.com>
|
29 |
+
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
30 |
+
* @link https://github.com/ifsnop/mysqldump-php
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
class Mysqldump
|
34 |
+
{
|
35 |
+
|
36 |
+
// Same as mysqldump
|
37 |
+
const MAXLINESIZE = 1000000;
|
38 |
+
|
39 |
+
// Available compression methods as constants
|
40 |
+
const GZIP = 'Gzip';
|
41 |
+
const BZIP2 = 'Bzip2';
|
42 |
+
const NONE = 'None';
|
43 |
+
|
44 |
+
// Available connection strings
|
45 |
+
const UTF8 = 'utf8';
|
46 |
+
const UTF8MB4 = 'utf8mb4';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Database username
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
public $user;
|
53 |
+
/**
|
54 |
+
* Database password
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
public $pass;
|
58 |
+
/**
|
59 |
+
* Connection string for PDO
|
60 |
+
* @var string
|
61 |
+
*/
|
62 |
+
public $dsn;
|
63 |
+
/**
|
64 |
+
* Destination filename, defaults to stdout
|
65 |
+
* @var string
|
66 |
+
*/
|
67 |
+
public $fileName = 'php://output';
|
68 |
+
|
69 |
+
// Internal stuff
|
70 |
+
private $tables = array();
|
71 |
+
private $views = array();
|
72 |
+
private $triggers = array();
|
73 |
+
private $procedures = array();
|
74 |
+
private $dbHandler;
|
75 |
+
private $dbType;
|
76 |
+
private $compressManager;
|
77 |
+
private $typeAdapter;
|
78 |
+
private $dumpSettings = array();
|
79 |
+
private $pdoSettings = array();
|
80 |
+
private $version;
|
81 |
+
private $tableColumnTypes = array();
|
82 |
+
/**
|
83 |
+
* database name, parsed from dsn
|
84 |
+
* @var string
|
85 |
+
*/
|
86 |
+
private $dbName;
|
87 |
+
/**
|
88 |
+
* host name, parsed from dsn
|
89 |
+
* @var string
|
90 |
+
*/
|
91 |
+
private $host;
|
92 |
+
/**
|
93 |
+
* dsn string parsed as an array
|
94 |
+
* @var array
|
95 |
+
*/
|
96 |
+
private $dsnArray = array();
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Constructor of Mysqldump. Note that in the case of an SQLite database
|
100 |
+
* connection, the filename must be in the $db parameter.
|
101 |
+
*
|
102 |
+
* @param string $dsn PDO DSN connection string
|
103 |
+
* @param string $user SQL account username
|
104 |
+
* @param string $pass SQL account password
|
105 |
+
* @param array $dumpSettings SQL database settings
|
106 |
+
* @param array $pdoSettings PDO configured attributes
|
107 |
+
*/
|
108 |
+
public function __construct(
|
109 |
+
$dsn = '',
|
110 |
+
$user = '',
|
111 |
+
$pass = '',
|
112 |
+
$dumpSettings = array(),
|
113 |
+
$pdoSettings = array()
|
114 |
+
) {
|
115 |
+
$dumpSettingsDefault = array(
|
116 |
+
'include-tables' => array(),
|
117 |
+
'exclude-tables' => array(),
|
118 |
+
'compress' => Mysqldump::NONE,
|
119 |
+
'no-data' => false,
|
120 |
+
'add-drop-table' => false,
|
121 |
+
'single-transaction' => true,
|
122 |
+
'lock-tables' => true,
|
123 |
+
'add-locks' => true,
|
124 |
+
'extended-insert' => true,
|
125 |
+
'disable-keys' => true,
|
126 |
+
'where' => '',
|
127 |
+
'no-create-info' => false,
|
128 |
+
'skip-triggers' => false,
|
129 |
+
'add-drop-trigger' => true,
|
130 |
+
'routines' => false,
|
131 |
+
'hex-blob' => true, /* faster than escaped content */
|
132 |
+
'databases' => false,
|
133 |
+
'add-drop-database' => false,
|
134 |
+
'skip-tz-utc' => false,
|
135 |
+
'no-autocommit' => true,
|
136 |
+
'default-character-set' => Mysqldump::UTF8,
|
137 |
+
'skip-comments' => false,
|
138 |
+
'skip-dump-date' => false,
|
139 |
+
'init_commands' => array(),
|
140 |
+
/* deprecated */
|
141 |
+
'disable-foreign-keys-check' => true
|
142 |
+
);
|
143 |
+
|
144 |
+
$pdoSettingsDefault = array(
|
145 |
+
PDO::ATTR_PERSISTENT => true,
|
146 |
+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
147 |
+
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false
|
148 |
+
);
|
149 |
+
|
150 |
+
$this->user = $user;
|
151 |
+
$this->pass = $pass;
|
152 |
+
$this->parseDsn($dsn);
|
153 |
+
$this->pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
|
154 |
+
$this->dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
|
155 |
+
|
156 |
+
$this->dumpSettings['init_commands'][] = "SET NAMES " . $this->dumpSettings['default-character-set'];
|
157 |
+
|
158 |
+
if (false === $this->dumpSettings['skip-tz-utc']) {
|
159 |
+
$this->dumpSettings['init_commands'][] = "SET TIME_ZONE='+00:00'";
|
160 |
+
}
|
161 |
+
|
162 |
+
$diff = array_diff(array_keys($this->dumpSettings), array_keys($dumpSettingsDefault));
|
163 |
+
if (count($diff)>0) {
|
164 |
+
throw new Exception("Unexpected value in dumpSettings: (" . implode(",", $diff) . ")");
|
165 |
+
}
|
166 |
+
|
167 |
+
// Create a new compressManager to manage compressed output
|
168 |
+
$this->compressManager = CompressManagerFactory::create($this->dumpSettings['compress']);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Custom array_replace_recursive to be used if PHP < 5.3
|
173 |
+
* Replaces elements from passed arrays into the first array recursively
|
174 |
+
*
|
175 |
+
* @param array $array1 The array in which elements are replaced
|
176 |
+
* @param array $array2 The array from which elements will be extracted
|
177 |
+
*
|
178 |
+
* @return array Returns an array, or NULL if an error occurs.
|
179 |
+
*/
|
180 |
+
public static function array_replace_recursive($array1, $array2)
|
181 |
+
{
|
182 |
+
if (function_exists('array_replace_recursive')) {
|
183 |
+
return array_replace_recursive($array1, $array2);
|
184 |
+
}
|
185 |
+
|
186 |
+
foreach ($array2 as $key => $value) {
|
187 |
+
if (is_array($value)) {
|
188 |
+
$array1[$key] = self::array_replace_recursive($array1[$key], $value);
|
189 |
+
} else {
|
190 |
+
$array1[$key] = $value;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
return $array1;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Parse DSN string and extract dbname value
|
198 |
+
* Several examples of a DSN string
|
199 |
+
* mysql:host=localhost;dbname=testdb
|
200 |
+
* mysql:host=localhost;port=3307;dbname=testdb
|
201 |
+
* mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
|
202 |
+
*
|
203 |
+
* @param string $dsn dsn string to parse
|
204 |
+
*/
|
205 |
+
private function parseDsn($dsn)
|
206 |
+
{
|
207 |
+
if (empty($dsn) || (false === ($pos = strpos($dsn, ":")))) {
|
208 |
+
throw new Exception("Empty DSN string");
|
209 |
+
}
|
210 |
+
|
211 |
+
$this->dsn = $dsn;
|
212 |
+
$this->dbType = strtolower(substr($dsn, 0, $pos));
|
213 |
+
|
214 |
+
if (empty($this->dbType)) {
|
215 |
+
throw new Exception("Missing database type from DSN string");
|
216 |
+
}
|
217 |
+
|
218 |
+
$dsn = substr($dsn, $pos + 1);
|
219 |
+
|
220 |
+
foreach(explode(";", $dsn) as $kvp) {
|
221 |
+
$kvpArr = explode("=", $kvp);
|
222 |
+
$this->dsnArray[strtolower($kvpArr[0])] = $kvpArr[1];
|
223 |
+
}
|
224 |
+
|
225 |
+
if (empty($this->dsnArray['host']) &&
|
226 |
+
empty($this->dsnArray['unix_socket'])) {
|
227 |
+
throw new Exception("Missing host from DSN string");
|
228 |
+
}
|
229 |
+
$this->host = (!empty($this->dsnArray['host'])) ?
|
230 |
+
$this->dsnArray['host'] :
|
231 |
+
$this->dsnArray['unix_socket'];
|
232 |
+
|
233 |
+
if (empty($this->dsnArray['dbname'])) {
|
234 |
+
throw new Exception("Missing database name from DSN string");
|
235 |
+
}
|
236 |
+
|
237 |
+
$this->dbName = $this->dsnArray['dbname'];
|
238 |
+
|
239 |
+
return true;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Connect with PDO
|
244 |
+
*
|
245 |
+
* @return null
|
246 |
+
*/
|
247 |
+
private function connect()
|
248 |
+
{
|
249 |
+
// Connecting with PDO
|
250 |
+
try {
|
251 |
+
switch ($this->dbType) {
|
252 |
+
case 'sqlite':
|
253 |
+
$this->dbHandler = @new PDO("sqlite:" . $this->dbName, null, null, $this->pdoSettings);
|
254 |
+
break;
|
255 |
+
case 'mysql':
|
256 |
+
case 'pgsql':
|
257 |
+
case 'dblib':
|
258 |
+
$this->dbHandler = @new PDO(
|
259 |
+
$this->dsn,
|
260 |
+
$this->user,
|
261 |
+
$this->pass,
|
262 |
+
$this->pdoSettings
|
263 |
+
);
|
264 |
+
// Execute init commands once connected
|
265 |
+
foreach($this->dumpSettings['init_commands'] as $stmt) {
|
266 |
+
$this->dbHandler->exec($stmt);
|
267 |
+
}
|
268 |
+
// Store server version
|
269 |
+
$this->version = $this->dbHandler->getAttribute(PDO::ATTR_SERVER_VERSION);
|
270 |
+
break;
|
271 |
+
default:
|
272 |
+
throw new Exception("Unsupported database type (" . $this->dbType . ")");
|
273 |
+
}
|
274 |
+
} catch (PDOException $e) {
|
275 |
+
throw new Exception(
|
276 |
+
"Connection to " . $this->dbType . " failed with message: " .
|
277 |
+
$e->getMessage()
|
278 |
+
);
|
279 |
+
}
|
280 |
+
|
281 |
+
$this->dbHandler->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
|
282 |
+
$this->typeAdapter = TypeAdapterFactory::create($this->dbType, $this->dbHandler);
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Main call
|
287 |
+
*
|
288 |
+
* @param string $filename Name of file to write sql dump to
|
289 |
+
* @return null
|
290 |
+
*/
|
291 |
+
public function start($filename = '')
|
292 |
+
{
|
293 |
+
// Output file can be redefined here
|
294 |
+
if (!empty($filename)) {
|
295 |
+
$this->fileName = $filename;
|
296 |
+
}
|
297 |
+
|
298 |
+
// Connect to database
|
299 |
+
$this->connect();
|
300 |
+
|
301 |
+
// Create output file
|
302 |
+
$this->compressManager->open($this->fileName);
|
303 |
+
|
304 |
+
// Write some basic info to output file
|
305 |
+
$this->compressManager->write($this->getDumpFileHeader());
|
306 |
+
|
307 |
+
// Store server settings and use sanner defaults to dump
|
308 |
+
$this->compressManager->write(
|
309 |
+
$this->typeAdapter->backup_parameters($this->dumpSettings)
|
310 |
+
);
|
311 |
+
|
312 |
+
if ($this->dumpSettings['databases']) {
|
313 |
+
$this->compressManager->write(
|
314 |
+
$this->typeAdapter->getDatabaseHeader($this->dbName)
|
315 |
+
);
|
316 |
+
if ($this->dumpSettings['add-drop-database']) {
|
317 |
+
$this->compressManager->write(
|
318 |
+
$this->typeAdapter->add_drop_database($this->dbName)
|
319 |
+
);
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
// Get table, view and trigger structures from database
|
324 |
+
$this->getDatabaseStructure();
|
325 |
+
|
326 |
+
if ($this->dumpSettings['databases']) {
|
327 |
+
$this->compressManager->write(
|
328 |
+
$this->typeAdapter->databases($this->dbName)
|
329 |
+
);
|
330 |
+
}
|
331 |
+
|
332 |
+
// If there still are some tables/views in include-tables array,
|
333 |
+
// that means that some tables or views weren't found.
|
334 |
+
// Give proper error and exit.
|
335 |
+
if (0 < count($this->dumpSettings['include-tables'])) {
|
336 |
+
$name = implode(",", $this->dumpSettings['include-tables']);
|
337 |
+
throw new Exception("Table or View (" . $name . ") not found in database");
|
338 |
+
}
|
339 |
+
|
340 |
+
$this->exportTables();
|
341 |
+
$this->exportViews();
|
342 |
+
$this->exportTriggers();
|
343 |
+
$this->exportProcedures();
|
344 |
+
|
345 |
+
// Restore saved parameters
|
346 |
+
$this->compressManager->write(
|
347 |
+
$this->typeAdapter->restore_parameters($this->dumpSettings)
|
348 |
+
);
|
349 |
+
// Write some stats to output file
|
350 |
+
$this->compressManager->write($this->getDumpFileFooter());
|
351 |
+
// Close output file
|
352 |
+
$this->compressManager->close();
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Returns header for dump file
|
357 |
+
*
|
358 |
+
* @return string
|
359 |
+
*/
|
360 |
+
private function getDumpFileHeader()
|
361 |
+
{
|
362 |
+
$header = '';
|
363 |
+
if (!$this->dumpSettings['skip-comments']) {
|
364 |
+
// Some info about software, source and time
|
365 |
+
$header = "-- mysqldump-php https://github.com/ifsnop/mysqldump-php" . PHP_EOL .
|
366 |
+
"--" . PHP_EOL .
|
367 |
+
"-- Host: {$this->host}\tDatabase: {$this->dbName}" . PHP_EOL .
|
368 |
+
"-- ------------------------------------------------------" . PHP_EOL;
|
369 |
+
|
370 |
+
if (!empty($this->version)) {
|
371 |
+
$header .= "-- Server version \t" . $this->version . PHP_EOL;
|
372 |
+
}
|
373 |
+
|
374 |
+
$header .= "-- Date: " . date('r') . PHP_EOL . PHP_EOL;
|
375 |
+
}
|
376 |
+
return $header;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Returns footer for dump file
|
381 |
+
*
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
private function getDumpFileFooter()
|
385 |
+
{
|
386 |
+
$footer = '';
|
387 |
+
if (!$this->dumpSettings['skip-comments']) {
|
388 |
+
$footer .= '-- Dump completed';
|
389 |
+
if (!$this->dumpSettings['skip-dump-date']) {
|
390 |
+
$footer .= ' on: ' . date('r');
|
391 |
+
}
|
392 |
+
$footer .= PHP_EOL;
|
393 |
+
}
|
394 |
+
|
395 |
+
return $footer;
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Reads table and views names from database.
|
400 |
+
* Fills $this->tables array so they will be dumped later.
|
401 |
+
*
|
402 |
+
* @return null
|
403 |
+
*/
|
404 |
+
private function getDatabaseStructure()
|
405 |
+
{
|
406 |
+
// Listing all tables from database
|
407 |
+
if (empty($this->dumpSettings['include-tables'])) {
|
408 |
+
// include all tables for now, blacklisting happens later
|
409 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_tables($this->dbName)) as $row) {
|
410 |
+
array_push($this->tables, current($row));
|
411 |
+
}
|
412 |
+
} else {
|
413 |
+
// include only the tables mentioned in include-tables
|
414 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_tables($this->dbName)) as $row) {
|
415 |
+
if (in_array(current($row), $this->dumpSettings['include-tables'], true)) {
|
416 |
+
array_push($this->tables, current($row));
|
417 |
+
$elem = array_search(
|
418 |
+
current($row),
|
419 |
+
$this->dumpSettings['include-tables']
|
420 |
+
);
|
421 |
+
unset($this->dumpSettings['include-tables'][$elem]);
|
422 |
+
}
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
// Listing all views from database
|
427 |
+
if (empty($this->dumpSettings['include-tables'])) {
|
428 |
+
// include all views for now, blacklisting happens later
|
429 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_views($this->dbName)) as $row) {
|
430 |
+
array_push($this->views, current($row));
|
431 |
+
}
|
432 |
+
} else {
|
433 |
+
// include only the tables mentioned in include-tables
|
434 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_views($this->dbName)) as $row) {
|
435 |
+
if (in_array(current($row), $this->dumpSettings['include-tables'], true)) {
|
436 |
+
array_push($this->views, current($row));
|
437 |
+
$elem = array_search(
|
438 |
+
current($row),
|
439 |
+
$this->dumpSettings['include-tables']
|
440 |
+
);
|
441 |
+
unset($this->dumpSettings['include-tables'][$elem]);
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
// Listing all triggers from database
|
447 |
+
if (false === $this->dumpSettings['skip-triggers']) {
|
448 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_triggers($this->dbName)) as $row) {
|
449 |
+
array_push($this->triggers, $row['Trigger']);
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
// Listing all procedures from database
|
454 |
+
if ($this->dumpSettings['routines']) {
|
455 |
+
foreach ($this->dbHandler->query($this->typeAdapter->show_procedures($this->dbName)) as $row) {
|
456 |
+
array_push($this->procedures, $row['procedure_name']);
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Exports all the tables selected from database
|
463 |
+
*
|
464 |
+
* @return null
|
465 |
+
*/
|
466 |
+
private function exportTables()
|
467 |
+
{
|
468 |
+
// Exporting tables one by one
|
469 |
+
foreach ($this->tables as $table) {
|
470 |
+
if (in_array($table, $this->dumpSettings['exclude-tables'], true)) {
|
471 |
+
continue;
|
472 |
+
}
|
473 |
+
$this->getTableStructure($table);
|
474 |
+
if (false === $this->dumpSettings['no-data']) {
|
475 |
+
$this->listValues($table);
|
476 |
+
}
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Exports all the views found in database
|
482 |
+
*
|
483 |
+
* @return null
|
484 |
+
*/
|
485 |
+
private function exportViews()
|
486 |
+
{
|
487 |
+
if (false === $this->dumpSettings['no-create-info']) {
|
488 |
+
// Exporting views one by one
|
489 |
+
foreach ($this->views as $view) {
|
490 |
+
if (in_array($view, $this->dumpSettings['exclude-tables'], true)) {
|
491 |
+
continue;
|
492 |
+
}
|
493 |
+
$this->tableColumnTypes[$view] = $this->getTableColumnTypes($view);
|
494 |
+
$this->getViewStructureTable($view);
|
495 |
+
}
|
496 |
+
foreach ($this->views as $view) {
|
497 |
+
if (in_array($view, $this->dumpSettings['exclude-tables'], true)) {
|
498 |
+
continue;
|
499 |
+
}
|
500 |
+
$this->getViewStructureView($view);
|
501 |
+
}
|
502 |
+
}
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Exports all the triggers found in database
|
507 |
+
*
|
508 |
+
* @return null
|
509 |
+
*/
|
510 |
+
private function exportTriggers()
|
511 |
+
{
|
512 |
+
// Exporting triggers one by one
|
513 |
+
foreach ($this->triggers as $trigger) {
|
514 |
+
$this->getTriggerStructure($trigger);
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Exports all the procedures found in database
|
520 |
+
*
|
521 |
+
* @return null
|
522 |
+
*/
|
523 |
+
private function exportProcedures()
|
524 |
+
{
|
525 |
+
// Exporting triggers one by one
|
526 |
+
foreach ($this->procedures as $procedure) {
|
527 |
+
$this->getProcedureStructure($procedure);
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Table structure extractor
|
533 |
+
*
|
534 |
+
* @todo move specific mysql code to typeAdapter
|
535 |
+
* @param string $tableName Name of table to export
|
536 |
+
* @return null
|
537 |
+
*/
|
538 |
+
private function getTableStructure($tableName)
|
539 |
+
{
|
540 |
+
if (!$this->dumpSettings['no-create-info']) {
|
541 |
+
$ret = '';
|
542 |
+
if (!$this->dumpSettings['skip-comments']) {
|
543 |
+
$ret = "--" . PHP_EOL .
|
544 |
+
"-- Table structure for table `$tableName`" . PHP_EOL .
|
545 |
+
"--" . PHP_EOL . PHP_EOL;
|
546 |
+
}
|
547 |
+
$stmt = $this->typeAdapter->show_create_table($tableName);
|
548 |
+
foreach ($this->dbHandler->query($stmt) as $r) {
|
549 |
+
$this->compressManager->write($ret);
|
550 |
+
if ($this->dumpSettings['add-drop-table']) {
|
551 |
+
$this->compressManager->write(
|
552 |
+
$this->typeAdapter->drop_table($tableName)
|
553 |
+
);
|
554 |
+
}
|
555 |
+
$this->compressManager->write(
|
556 |
+
$this->typeAdapter->create_table($r, $this->dumpSettings)
|
557 |
+
);
|
558 |
+
break;
|
559 |
+
}
|
560 |
+
}
|
561 |
+
$this->tableColumnTypes[$tableName] = $this->getTableColumnTypes($tableName);
|
562 |
+
return;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Store column types to create data dumps and for Stand-In tables
|
567 |
+
*
|
568 |
+
* @param string $tableName Name of table to export
|
569 |
+
* @return array type column types detailed
|
570 |
+
*/
|
571 |
+
|
572 |
+
private function getTableColumnTypes($tableName) {
|
573 |
+
$columnTypes = array();
|
574 |
+
$columns = $this->dbHandler->query(
|
575 |
+
$this->typeAdapter->show_columns($tableName)
|
576 |
+
);
|
577 |
+
$columns->setFetchMode(PDO::FETCH_ASSOC);
|
578 |
+
|
579 |
+
foreach($columns as $key => $col) {
|
580 |
+
$types = $this->typeAdapter->parseColumnType($col);
|
581 |
+
$columnTypes[$col['Field']] = array(
|
582 |
+
'is_numeric'=> $types['is_numeric'],
|
583 |
+
'is_blob' => $types['is_blob'],
|
584 |
+
'type' => $types['type'],
|
585 |
+
'type_sql' => $col['Type']
|
586 |
+
);
|
587 |
+
}
|
588 |
+
|
589 |
+
return $columnTypes;
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
+
* View structure extractor, create table (avoids cyclic references)
|
594 |
+
*
|
595 |
+
* @todo move mysql specific code to typeAdapter
|
596 |
+
* @param string $viewName Name of view to export
|
597 |
+
* @return null
|
598 |
+
*/
|
599 |
+
private function getViewStructureTable($viewName)
|
600 |
+
{
|
601 |
+
if (!$this->dumpSettings['skip-comments']) {
|
602 |
+
$ret = "--" . PHP_EOL .
|
603 |
+
"-- Stand-In structure for view `${viewName}`" . PHP_EOL .
|
604 |
+
"--" . PHP_EOL . PHP_EOL;
|
605 |
+
$this->compressManager->write($ret);
|
606 |
+
}
|
607 |
+
$stmt = $this->typeAdapter->show_create_view($viewName);
|
608 |
+
|
609 |
+
// create views as tables, to resolve dependencies
|
610 |
+
foreach ($this->dbHandler->query($stmt) as $r) {
|
611 |
+
if ($this->dumpSettings['add-drop-table']) {
|
612 |
+
$this->compressManager->write(
|
613 |
+
$this->typeAdapter->drop_view($viewName)
|
614 |
+
);
|
615 |
+
}
|
616 |
+
|
617 |
+
$this->compressManager->write(
|
618 |
+
$this->createStandInTable($viewName)
|
619 |
+
);
|
620 |
+
break;
|
621 |
+
}
|
622 |
+
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Write a create table statement for the table Stand-In, show create
|
626 |
+
* table would return a create algorithm when used on a view
|
627 |
+
*
|
628 |
+
* @param string $viewName Name of view to export
|
629 |
+
* @return string create statement
|
630 |
+
*/
|
631 |
+
function createStandInTable($viewName) {
|
632 |
+
$ret = array();
|
633 |
+
foreach($this->tableColumnTypes[$viewName] as $k => $v) {
|
634 |
+
$ret[] = "`${k}` ${v['type_sql']}";
|
635 |
+
}
|
636 |
+
$ret = implode(PHP_EOL . ",", $ret);
|
637 |
+
|
638 |
+
$ret = "CREATE TABLE IF NOT EXISTS `$viewName` (" .
|
639 |
+
PHP_EOL . $ret . PHP_EOL . ");" . PHP_EOL;
|
640 |
+
|
641 |
+
return $ret;
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* View structure extractor, create view
|
646 |
+
*
|
647 |
+
* @todo move mysql specific code to typeAdapter
|
648 |
+
* @param string $viewName Name of view to export
|
649 |
+
* @return null
|
650 |
+
*/
|
651 |
+
private function getViewStructureView($viewName)
|
652 |
+
{
|
653 |
+
if (!$this->dumpSettings['skip-comments']) {
|
654 |
+
$ret = "--" . PHP_EOL .
|
655 |
+
"-- View structure for view `${viewName}`" . PHP_EOL .
|
656 |
+
"--" . PHP_EOL . PHP_EOL;
|
657 |
+
$this->compressManager->write($ret);
|
658 |
+
}
|
659 |
+
$stmt = $this->typeAdapter->show_create_view($viewName);
|
660 |
+
|
661 |
+
// create views, to resolve dependencies
|
662 |
+
// replacing tables with views
|
663 |
+
foreach ($this->dbHandler->query($stmt) as $r) {
|
664 |
+
// because we must replace table with view, we should delete it
|
665 |
+
$this->compressManager->write(
|
666 |
+
$this->typeAdapter->drop_view($viewName)
|
667 |
+
);
|
668 |
+
$this->compressManager->write(
|
669 |
+
$this->typeAdapter->create_view($r)
|
670 |
+
);
|
671 |
+
break;
|
672 |
+
}
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Trigger structure extractor
|
677 |
+
*
|
678 |
+
* @param string $triggerName Name of trigger to export
|
679 |
+
* @return null
|
680 |
+
*/
|
681 |
+
private function getTriggerStructure($triggerName)
|
682 |
+
{
|
683 |
+
$stmt = $this->typeAdapter->show_create_trigger($triggerName);
|
684 |
+
foreach ($this->dbHandler->query($stmt) as $r) {
|
685 |
+
if ($this->dumpSettings['add-drop-trigger']) {
|
686 |
+
$this->compressManager->write(
|
687 |
+
$this->typeAdapter->add_drop_trigger($triggerName)
|
688 |
+
);
|
689 |
+
}
|
690 |
+
$this->compressManager->write(
|
691 |
+
$this->typeAdapter->create_trigger($r)
|
692 |
+
);
|
693 |
+
return;
|
694 |
+
}
|
695 |
+
}
|
696 |
+
|
697 |
+
/**
|
698 |
+
* Procedure structure extractor
|
699 |
+
*
|
700 |
+
* @param string $procedureName Name of procedure to export
|
701 |
+
* @return null
|
702 |
+
*/
|
703 |
+
private function getProcedureStructure($procedureName)
|
704 |
+
{
|
705 |
+
if (!$this->dumpSettings['skip-comments']) {
|
706 |
+
$ret = "--" . PHP_EOL .
|
707 |
+
"-- Dumping routines for database '" . $this->dbName . "'" . PHP_EOL .
|
708 |
+
"--" . PHP_EOL . PHP_EOL;
|
709 |
+
$this->compressManager->write($ret);
|
710 |
+
}
|
711 |
+
$stmt = $this->typeAdapter->show_create_procedure($procedureName);
|
712 |
+
foreach ($this->dbHandler->query($stmt) as $r) {
|
713 |
+
$this->compressManager->write(
|
714 |
+
$this->typeAdapter->create_procedure($r, $this->dumpSettings)
|
715 |
+
);
|
716 |
+
return;
|
717 |
+
}
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Escape values with quotes when needed
|
722 |
+
*
|
723 |
+
* @param string $tableName Name of table which contains rows
|
724 |
+
* @param array $row Associative array of column names and values to be quoted
|
725 |
+
*
|
726 |
+
* @return string
|
727 |
+
*/
|
728 |
+
private function escape($tableName, $row)
|
729 |
+
{
|
730 |
+
$ret = array();
|
731 |
+
$columnTypes = $this->tableColumnTypes[$tableName];
|
732 |
+
foreach ($row as $colName => $colValue) {
|
733 |
+
if (is_null($colValue)) {
|
734 |
+
$ret[] = "NULL";
|
735 |
+
} elseif ($this->dumpSettings['hex-blob'] && $columnTypes[$colName]['is_blob']) {
|
736 |
+
if ($columnTypes[$colName]['type'] == 'bit' || !empty($colValue)) {
|
737 |
+
$ret[] = "0x${colValue}";
|
738 |
+
} else {
|
739 |
+
$ret[] = "''";
|
740 |
+
}
|
741 |
+
} elseif ($columnTypes[$colName]['is_numeric']) {
|
742 |
+
$ret[] = $colValue;
|
743 |
+
} else {
|
744 |
+
$ret[] = $this->dbHandler->quote($colValue);
|
745 |
+
}
|
746 |
+
}
|
747 |
+
return $ret;
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* Table rows extractor
|
752 |
+
*
|
753 |
+
* @param string $tableName Name of table to export
|
754 |
+
*
|
755 |
+
* @return null
|
756 |
+
*/
|
757 |
+
private function listValues($tableName)
|
758 |
+
{
|
759 |
+
$this->prepareListValues($tableName);
|
760 |
+
|
761 |
+
$onlyOnce = true;
|
762 |
+
$lineSize = 0;
|
763 |
+
|
764 |
+
$colStmt = $this->getColumnStmt($tableName);
|
765 |
+
$stmt = "SELECT $colStmt FROM `$tableName`";
|
766 |
+
|
767 |
+
if ($this->dumpSettings['where']) {
|
768 |
+
$stmt .= " WHERE {$this->dumpSettings['where']}";
|
769 |
+
}
|
770 |
+
$resultSet = $this->dbHandler->query($stmt);
|
771 |
+
$resultSet->setFetchMode(PDO::FETCH_ASSOC);
|
772 |
+
|
773 |
+
foreach ($resultSet as $row) {
|
774 |
+
$vals = $this->escape($tableName, $row);
|
775 |
+
if ($onlyOnce || !$this->dumpSettings['extended-insert']) {
|
776 |
+
$lineSize += $this->compressManager->write(
|
777 |
+
"INSERT INTO `$tableName` VALUES (" . implode(",", $vals) . ")"
|
778 |
+
);
|
779 |
+
$onlyOnce = false;
|
780 |
+
} else {
|
781 |
+
$lineSize += $this->compressManager->write(",(" . implode(",", $vals) . ")");
|
782 |
+
}
|
783 |
+
if (($lineSize > self::MAXLINESIZE) ||
|
784 |
+
!$this->dumpSettings['extended-insert']) {
|
785 |
+
$onlyOnce = true;
|
786 |
+
$lineSize = $this->compressManager->write(";" . PHP_EOL);
|
787 |
+
}
|
788 |
+
}
|
789 |
+
$resultSet->closeCursor();
|
790 |
+
|
791 |
+
if (!$onlyOnce) {
|
792 |
+
$this->compressManager->write(";" . PHP_EOL);
|
793 |
+
}
|
794 |
+
|
795 |
+
$this->endListValues($tableName);
|
796 |
+
}
|
797 |
+
|
798 |
+
/**
|
799 |
+
* Table rows extractor, append information prior to dump
|
800 |
+
*
|
801 |
+
* @param string $tableName Name of table to export
|
802 |
+
*
|
803 |
+
* @return null
|
804 |
+
*/
|
805 |
+
function prepareListValues($tableName)
|
806 |
+
{
|
807 |
+
if (!$this->dumpSettings['skip-comments']) {
|
808 |
+
$this->compressManager->write(
|
809 |
+
"--" . PHP_EOL .
|
810 |
+
"-- Dumping data for table `$tableName`" . PHP_EOL .
|
811 |
+
"--" . PHP_EOL . PHP_EOL
|
812 |
+
);
|
813 |
+
}
|
814 |
+
|
815 |
+
if ($this->dumpSettings['single-transaction']) {
|
816 |
+
$this->dbHandler->exec($this->typeAdapter->setup_transaction());
|
817 |
+
$this->dbHandler->exec($this->typeAdapter->start_transaction());
|
818 |
+
}
|
819 |
+
|
820 |
+
if ($this->dumpSettings['lock-tables']) {
|
821 |
+
$this->typeAdapter->lock_table($tableName);
|
822 |
+
}
|
823 |
+
|
824 |
+
if ($this->dumpSettings['add-locks']) {
|
825 |
+
$this->compressManager->write(
|
826 |
+
$this->typeAdapter->start_add_lock_table($tableName)
|
827 |
+
);
|
828 |
+
}
|
829 |
+
|
830 |
+
if ($this->dumpSettings['disable-keys']) {
|
831 |
+
$this->compressManager->write(
|
832 |
+
$this->typeAdapter->start_add_disable_keys($tableName)
|
833 |
+
);
|
834 |
+
}
|
835 |
+
|
836 |
+
// Disable autocommit for faster reload
|
837 |
+
if ($this->dumpSettings['no-autocommit']) {
|
838 |
+
$this->compressManager->write(
|
839 |
+
$this->typeAdapter->start_disable_autocommit()
|
840 |
+
);
|
841 |
+
}
|
842 |
+
|
843 |
+
return;
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Table rows extractor, close locks and commits after dump
|
848 |
+
*
|
849 |
+
* @param string $tableName Name of table to export
|
850 |
+
*
|
851 |
+
* @return null
|
852 |
+
*/
|
853 |
+
function endListValues($tableName)
|
854 |
+
{
|
855 |
+
if ($this->dumpSettings['disable-keys']) {
|
856 |
+
$this->compressManager->write(
|
857 |
+
$this->typeAdapter->end_add_disable_keys($tableName)
|
858 |
+
);
|
859 |
+
}
|
860 |
+
|
861 |
+
if ($this->dumpSettings['add-locks']) {
|
862 |
+
$this->compressManager->write(
|
863 |
+
$this->typeAdapter->end_add_lock_table($tableName)
|
864 |
+
);
|
865 |
+
}
|
866 |
+
|
867 |
+
if ($this->dumpSettings['single-transaction']) {
|
868 |
+
$this->dbHandler->exec($this->typeAdapter->commit_transaction());
|
869 |
+
}
|
870 |
+
|
871 |
+
if ($this->dumpSettings['lock-tables']) {
|
872 |
+
$this->typeAdapter->unlock_table($tableName);
|
873 |
+
}
|
874 |
+
|
875 |
+
// Commit to enable autocommit
|
876 |
+
if ($this->dumpSettings['no-autocommit']) {
|
877 |
+
$this->compressManager->write(
|
878 |
+
$this->typeAdapter->end_disable_autocommit()
|
879 |
+
);
|
880 |
+
}
|
881 |
+
|
882 |
+
$this->compressManager->write(PHP_EOL);
|
883 |
+
|
884 |
+
return;
|
885 |
+
}
|
886 |
+
|
887 |
+
/**
|
888 |
+
* Build SQL List of all columns on current table
|
889 |
+
*
|
890 |
+
* @param string $tableName Name of table to get columns
|
891 |
+
*
|
892 |
+
* @return string SQL sentence with columns
|
893 |
+
*/
|
894 |
+
function getColumnStmt($tableName)
|
895 |
+
{
|
896 |
+
$colStmt = array();
|
897 |
+
foreach($this->tableColumnTypes[$tableName] as $colName => $colType) {
|
898 |
+
if ($colType['type'] == 'bit' && $this->dumpSettings['hex-blob']) {
|
899 |
+
$colStmt[] = "LPAD(HEX(`${colName}`),2,'0') AS `${colName}`";
|
900 |
+
} else if ($colType['is_blob'] && $this->dumpSettings['hex-blob']) {
|
901 |
+
$colStmt[] = "HEX(`${colName}`) AS `${colName}`";
|
902 |
+
} else {
|
903 |
+
$colStmt[] = "`${colName}`";
|
904 |
+
}
|
905 |
+
}
|
906 |
+
$colStmt = implode($colStmt, ",");
|
907 |
+
|
908 |
+
return $colStmt;
|
909 |
+
}
|
910 |
+
}
|
911 |
+
|
912 |
+
/**
|
913 |
+
* Enum with all available compression methods
|
914 |
+
*
|
915 |
+
*/
|
916 |
+
abstract class CompressMethod
|
917 |
+
{
|
918 |
+
public static $enums = array(
|
919 |
+
"None",
|
920 |
+
"Gzip",
|
921 |
+
"Bzip2"
|
922 |
+
);
|
923 |
+
|
924 |
+
/**
|
925 |
+
* @param string $c
|
926 |
+
* @return boolean
|
927 |
+
*/
|
928 |
+
public static function isValid($c)
|
929 |
+
{
|
930 |
+
return in_array($c, self::$enums);
|
931 |
+
}
|
932 |
+
}
|
933 |
+
|
934 |
+
abstract class CompressManagerFactory
|
935 |
+
{
|
936 |
+
/**
|
937 |
+
* @param string $c
|
938 |
+
* @return CompressBzip2|CompressGzip|CompressNone
|
939 |
+
*/
|
940 |
+
public static function create($c)
|
941 |
+
{
|
942 |
+
$c = ucfirst(strtolower($c));
|
943 |
+
if (! CompressMethod::isValid($c)) {
|
944 |
+
throw new Exception("Compression method ($c) is not defined yet");
|
945 |
+
}
|
946 |
+
|
947 |
+
$method = __NAMESPACE__ . "\\" . "Compress" . $c;
|
948 |
+
|
949 |
+
return new $method;
|
950 |
+
}
|
951 |
+
}
|
952 |
+
|
953 |
+
class CompressBzip2 extends CompressManagerFactory
|
954 |
+
{
|
955 |
+
private $fileHandler = null;
|
956 |
+
|
957 |
+
public function __construct()
|
958 |
+
{
|
959 |
+
if (! function_exists("bzopen")) {
|
960 |
+
throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly");
|
961 |
+
}
|
962 |
+
}
|
963 |
+
|
964 |
+
/**
|
965 |
+
* @param string $filename
|
966 |
+
*/
|
967 |
+
public function open($filename)
|
968 |
+
{
|
969 |
+
$this->fileHandler = bzopen($filename, "w");
|
970 |
+
if (false === $this->fileHandler) {
|
971 |
+
throw new Exception("Output file is not writable");
|
972 |
+
}
|
973 |
+
|
974 |
+
return true;
|
975 |
+
}
|
976 |
+
|
977 |
+
public function write($str)
|
978 |
+
{
|
979 |
+
if (false === ($bytesWritten = bzwrite($this->fileHandler, $str))) {
|
980 |
+
throw new Exception("Writting to file failed! Probably, there is no more free space left?");
|
981 |
+
}
|
982 |
+
return $bytesWritten;
|
983 |
+
}
|
984 |
+
|
985 |
+
public function close()
|
986 |
+
{
|
987 |
+
return bzclose($this->fileHandler);
|
988 |
+
}
|
989 |
+
}
|
990 |
+
|
991 |
+
class CompressGzip extends CompressManagerFactory
|
992 |
+
{
|
993 |
+
private $fileHandler = null;
|
994 |
+
|
995 |
+
public function __construct()
|
996 |
+
{
|
997 |
+
if (! function_exists("gzopen")) {
|
998 |
+
throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly");
|
999 |
+
}
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* @param string $filename
|
1004 |
+
*/
|
1005 |
+
public function open($filename)
|
1006 |
+
{
|
1007 |
+
$this->fileHandler = gzopen($filename, "wb");
|
1008 |
+
if (false === $this->fileHandler) {
|
1009 |
+
throw new Exception("Output file is not writable");
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
return true;
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
public function write($str)
|
1016 |
+
{
|
1017 |
+
if (false === ($bytesWritten = gzwrite($this->fileHandler, $str))) {
|
1018 |
+
throw new Exception("Writting to file failed! Probably, there is no more free space left?");
|
1019 |
+
}
|
1020 |
+
return $bytesWritten;
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
public function close()
|
1024 |
+
{
|
1025 |
+
return gzclose($this->fileHandler);
|
1026 |
+
}
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
class CompressNone extends CompressManagerFactory
|
1030 |
+
{
|
1031 |
+
private $fileHandler = null;
|
1032 |
+
|
1033 |
+
/**
|
1034 |
+
* @param string $filename
|
1035 |
+
*/
|
1036 |
+
public function open($filename)
|
1037 |
+
{
|
1038 |
+
$this->fileHandler = fopen($filename, "wb");
|
1039 |
+
if (false === $this->fileHandler) {
|
1040 |
+
throw new Exception("Output file is not writable");
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
return true;
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
public function write($str)
|
1047 |
+
{
|
1048 |
+
if (false === ($bytesWritten = fwrite($this->fileHandler, $str))) {
|
1049 |
+
throw new Exception("Writting to file failed! Probably, there is no more free space left?");
|
1050 |
+
}
|
1051 |
+
return $bytesWritten;
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
public function close()
|
1055 |
+
{
|
1056 |
+
return fclose($this->fileHandler);
|
1057 |
+
}
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
/**
|
1061 |
+
* Enum with all available TypeAdapter implementations
|
1062 |
+
*
|
1063 |
+
*/
|
1064 |
+
abstract class TypeAdapter
|
1065 |
+
{
|
1066 |
+
public static $enums = array(
|
1067 |
+
"Sqlite",
|
1068 |
+
"Mysql"
|
1069 |
+
);
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
* @param string $c
|
1073 |
+
* @return boolean
|
1074 |
+
*/
|
1075 |
+
public static function isValid($c)
|
1076 |
+
{
|
1077 |
+
return in_array($c, self::$enums);
|
1078 |
+
}
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* TypeAdapter Factory
|
1083 |
+
*
|
1084 |
+
*/
|
1085 |
+
abstract class TypeAdapterFactory
|
1086 |
+
{
|
1087 |
+
/**
|
1088 |
+
* @param string $c Type of database factory to create (Mysql, Sqlite,...)
|
1089 |
+
* @param PDO $dbHandler
|
1090 |
+
*/
|
1091 |
+
public static function create($c, $dbHandler = null)
|
1092 |
+
{
|
1093 |
+
$c = ucfirst(strtolower($c));
|
1094 |
+
if (! TypeAdapter::isValid($c)) {
|
1095 |
+
throw new Exception("Database type support for ($c) not yet available");
|
1096 |
+
}
|
1097 |
+
$method = __NAMESPACE__ . "\\" . "TypeAdapter" . $c;
|
1098 |
+
return new $method($dbHandler);
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
/**
|
1102 |
+
* function databases Add sql to create and use database
|
1103 |
+
* @todo make it do something with sqlite
|
1104 |
+
*/
|
1105 |
+
public function databases()
|
1106 |
+
{
|
1107 |
+
return "";
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
public function show_create_table($tableName)
|
1111 |
+
{
|
1112 |
+
return "SELECT tbl_name as 'Table', sql as 'Create Table' " .
|
1113 |
+
"FROM sqlite_master " .
|
1114 |
+
"WHERE type='table' AND tbl_name='$tableName'";
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
/**
|
1118 |
+
* function create_table Get table creation code from database
|
1119 |
+
* @todo make it do something with sqlite
|
1120 |
+
*/
|
1121 |
+
public function create_table($row, $dumpSettings)
|
1122 |
+
{
|
1123 |
+
return "";
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
public function show_create_view($viewName)
|
1127 |
+
{
|
1128 |
+
return "SELECT tbl_name as 'View', sql as 'Create View' " .
|
1129 |
+
"FROM sqlite_master " .
|
1130 |
+
"WHERE type='view' AND tbl_name='$viewName'";
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
/**
|
1134 |
+
* function create_view Get view creation code from database
|
1135 |
+
* @todo make it do something with sqlite
|
1136 |
+
*/
|
1137 |
+
public function create_view($row)
|
1138 |
+
{
|
1139 |
+
return "";
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
/**
|
1143 |
+
* function show_create_trigger Get trigger creation code from database
|
1144 |
+
* @todo make it do something with sqlite
|
1145 |
+
*/
|
1146 |
+
public function show_create_trigger($triggerName)
|
1147 |
+
{
|
1148 |
+
return "";
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
/**
|
1152 |
+
* function create_trigger Modify trigger code, add delimiters, etc
|
1153 |
+
* @todo make it do something with sqlite
|
1154 |
+
*/
|
1155 |
+
public function create_trigger($triggerName)
|
1156 |
+
{
|
1157 |
+
return "";
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
/**
|
1161 |
+
* function create_procedure Modify procedure code, add delimiters, etc
|
1162 |
+
* @todo make it do something with sqlite
|
1163 |
+
*/
|
1164 |
+
public function create_procedure($procedureName, $dumpSettings)
|
1165 |
+
{
|
1166 |
+
return "";
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
public function show_tables()
|
1170 |
+
{
|
1171 |
+
return "SELECT tbl_name FROM sqlite_master WHERE type='table'";
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
public function show_views()
|
1175 |
+
{
|
1176 |
+
return "SELECT tbl_name FROM sqlite_master WHERE type='view'";
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
public function show_triggers()
|
1180 |
+
{
|
1181 |
+
return "SELECT name FROM sqlite_master WHERE type='trigger'";
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
public function show_columns()
|
1185 |
+
{
|
1186 |
+
if (func_num_args() != 1) {
|
1187 |
+
return "";
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
$args = func_get_args();
|
1191 |
+
|
1192 |
+
return "pragma table_info(${args[0]})";
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
public function show_procedures()
|
1196 |
+
{
|
1197 |
+
return "";
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
public function setup_transaction()
|
1201 |
+
{
|
1202 |
+
return "";
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
public function start_transaction()
|
1206 |
+
{
|
1207 |
+
return "BEGIN EXCLUSIVE";
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
public function commit_transaction()
|
1211 |
+
{
|
1212 |
+
return "COMMIT";
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
public function lock_table()
|
1216 |
+
{
|
1217 |
+
return "";
|
1218 |
+
}
|
1219 |
+
|
1220 |
+
public function unlock_table()
|
1221 |
+
{
|
1222 |
+
return "";
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
public function start_add_lock_table()
|
1226 |
+
{
|
1227 |
+
return PHP_EOL;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
public function end_add_lock_table()
|
1231 |
+
{
|
1232 |
+
return PHP_EOL;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
public function start_add_disable_keys()
|
1236 |
+
{
|
1237 |
+
return PHP_EOL;
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
public function end_add_disable_keys()
|
1241 |
+
{
|
1242 |
+
return PHP_EOL;
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
public function start_disable_foreign_keys_check()
|
1246 |
+
{
|
1247 |
+
return PHP_EOL;
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
public function end_disable_foreign_keys_check()
|
1251 |
+
{
|
1252 |
+
return PHP_EOL;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
public function add_drop_database()
|
1256 |
+
{
|
1257 |
+
return PHP_EOL;
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
public function add_drop_trigger()
|
1261 |
+
{
|
1262 |
+
return PHP_EOL;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
public function drop_table()
|
1266 |
+
{
|
1267 |
+
return PHP_EOL;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
public function drop_view()
|
1271 |
+
{
|
1272 |
+
return PHP_EOL;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
/**
|
1276 |
+
* Decode column metadata and fill info structure.
|
1277 |
+
* type, is_numeric and is_blob will always be available.
|
1278 |
+
*
|
1279 |
+
* @param array $colType Array returned from "SHOW COLUMNS FROM tableName"
|
1280 |
+
* @return array
|
1281 |
+
*/
|
1282 |
+
public function parseColumnType($colType)
|
1283 |
+
{
|
1284 |
+
return array();
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
public function backup_parameters()
|
1288 |
+
{
|
1289 |
+
return PHP_EOL;
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
public function restore_parameters()
|
1293 |
+
{
|
1294 |
+
return PHP_EOL;
|
1295 |
+
}
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
class TypeAdapterPgsql extends TypeAdapterFactory
|
1299 |
+
{
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
class TypeAdapterDblib extends TypeAdapterFactory
|
1303 |
+
{
|
1304 |
+
}
|
1305 |
+
|
1306 |
+
class TypeAdapterSqlite extends TypeAdapterFactory
|
1307 |
+
{
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
class TypeAdapterMysql extends TypeAdapterFactory
|
1311 |
+
{
|
1312 |
+
|
1313 |
+
private $dbHandler = null;
|
1314 |
+
|
1315 |
+
// Numerical Mysql types
|
1316 |
+
public $mysqlTypes = array(
|
1317 |
+
'numerical' => array(
|
1318 |
+
'bit',
|
1319 |
+
'tinyint',
|
1320 |
+
'smallint',
|
1321 |
+
'mediumint',
|
1322 |
+
'int',
|
1323 |
+
'integer',
|
1324 |
+
'bigint',
|
1325 |
+
'real',
|
1326 |
+
'double',
|
1327 |
+
'float',
|
1328 |
+
'decimal',
|
1329 |
+
'numeric'
|
1330 |
+
),
|
1331 |
+
'blob' => array(
|
1332 |
+
'tinyblob',
|
1333 |
+
'blob',
|
1334 |
+
'mediumblob',
|
1335 |
+
'longblob',
|
1336 |
+
'binary',
|
1337 |
+
'varbinary',
|
1338 |
+
'bit'
|
1339 |
+
)
|
1340 |
+
);
|
1341 |
+
|
1342 |
+
public function __construct ($dbHandler)
|
1343 |
+
{
|
1344 |
+
$this->dbHandler = $dbHandler;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
public function databases()
|
1348 |
+
{
|
1349 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1350 |
+
$args = func_get_args();
|
1351 |
+
$databaseName = $args[0];
|
1352 |
+
|
1353 |
+
$resultSet = $this->dbHandler->query("SHOW VARIABLES LIKE 'character_set_database';");
|
1354 |
+
$characterSet = $resultSet->fetchColumn(1);
|
1355 |
+
$resultSet->closeCursor();
|
1356 |
+
|
1357 |
+
$resultSet = $this->dbHandler->query("SHOW VARIABLES LIKE 'collation_database';");
|
1358 |
+
$collationDb = $resultSet->fetchColumn(1);
|
1359 |
+
$resultSet->closeCursor();
|
1360 |
+
$ret = "";
|
1361 |
+
|
1362 |
+
$ret .= "CREATE DATABASE /*!32312 IF NOT EXISTS*/ `${databaseName}`".
|
1363 |
+
" /*!40100 DEFAULT CHARACTER SET ${characterSet} " .
|
1364 |
+
" COLLATE ${collationDb} */;" . PHP_EOL . PHP_EOL .
|
1365 |
+
"USE `${databaseName}`;" . PHP_EOL . PHP_EOL;
|
1366 |
+
|
1367 |
+
return $ret;
|
1368 |
+
}
|
1369 |
+
|
1370 |
+
public function show_create_table($tableName)
|
1371 |
+
{
|
1372 |
+
return "SHOW CREATE TABLE `$tableName`";
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
public function show_create_view($viewName)
|
1376 |
+
{
|
1377 |
+
return "SHOW CREATE VIEW `$viewName`";
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
public function show_create_trigger($triggerName)
|
1381 |
+
{
|
1382 |
+
return "SHOW CREATE TRIGGER `$triggerName`";
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
public function show_create_procedure($procedureName)
|
1386 |
+
{
|
1387 |
+
return "SHOW CREATE PROCEDURE `$procedureName`";
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
public function create_table($row, $dumpSettings)
|
1391 |
+
{
|
1392 |
+
if (!isset($row['Create Table'])) {
|
1393 |
+
throw new Exception("Error getting table code, unknown output");
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
$ret = "/*!40101 SET @saved_cs_client = @@character_set_client */;" . PHP_EOL .
|
1397 |
+
"/*!40101 SET character_set_client = " . $dumpSettings['default-character-set'] . " */;" . PHP_EOL .
|
1398 |
+
$row['Create Table'] . ";" . PHP_EOL .
|
1399 |
+
"/*!40101 SET character_set_client = @saved_cs_client */;" . PHP_EOL .
|
1400 |
+
PHP_EOL;
|
1401 |
+
return $ret;
|
1402 |
+
}
|
1403 |
+
|
1404 |
+
public function create_view($row)
|
1405 |
+
{
|
1406 |
+
$ret = "";
|
1407 |
+
if (!isset($row['Create View'])) {
|
1408 |
+
throw new Exception("Error getting view structure, unknown output");
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
$triggerStmt = $row['Create View'];
|
1412 |
+
|
1413 |
+
$triggerStmtReplaced1 = str_replace(
|
1414 |
+
"CREATE ALGORITHM",
|
1415 |
+
"/*!50001 CREATE ALGORITHM",
|
1416 |
+
$triggerStmt
|
1417 |
+
);
|
1418 |
+
$triggerStmtReplaced2 = str_replace(
|
1419 |
+
" DEFINER=",
|
1420 |
+
" */" . PHP_EOL . "/*!50013 DEFINER=",
|
1421 |
+
$triggerStmtReplaced1
|
1422 |
+
);
|
1423 |
+
$triggerStmtReplaced3 = str_replace(
|
1424 |
+
" VIEW ",
|
1425 |
+
" */" . PHP_EOL . "/*!50001 VIEW ",
|
1426 |
+
$triggerStmtReplaced2
|
1427 |
+
);
|
1428 |
+
if (false === $triggerStmtReplaced1 ||
|
1429 |
+
false === $triggerStmtReplaced2 ||
|
1430 |
+
false === $triggerStmtReplaced3) {
|
1431 |
+
$triggerStmtReplaced = $triggerStmt;
|
1432 |
+
} else {
|
1433 |
+
$triggerStmtReplaced = $triggerStmtReplaced3 . " */;";
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
$ret .= $triggerStmtReplaced . PHP_EOL . PHP_EOL;
|
1437 |
+
return $ret;
|
1438 |
+
}
|
1439 |
+
|
1440 |
+
public function create_trigger($row)
|
1441 |
+
{
|
1442 |
+
$ret = "";
|
1443 |
+
if (!isset($row['SQL Original Statement'])) {
|
1444 |
+
throw new Exception("Error getting trigger code, unknown output");
|
1445 |
+
}
|
1446 |
+
|
1447 |
+
$triggerStmt = $row['SQL Original Statement'];
|
1448 |
+
$triggerStmtReplaced = str_replace(
|
1449 |
+
"CREATE DEFINER",
|
1450 |
+
"/*!50003 CREATE*/ /*!50017 DEFINER",
|
1451 |
+
$triggerStmt
|
1452 |
+
);
|
1453 |
+
$triggerStmtReplaced = str_replace(
|
1454 |
+
" TRIGGER",
|
1455 |
+
"*/ /*!50003 TRIGGER",
|
1456 |
+
$triggerStmtReplaced
|
1457 |
+
);
|
1458 |
+
if ( false === $triggerStmtReplaced ) {
|
1459 |
+
$triggerStmtReplaced = $triggerStmt;
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
$ret .= "DELIMITER ;;" . PHP_EOL .
|
1463 |
+
$triggerStmtReplaced . "*/;;" . PHP_EOL .
|
1464 |
+
"DELIMITER ;" . PHP_EOL . PHP_EOL;
|
1465 |
+
return $ret;
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
public function create_procedure($row, $dumpSettings)
|
1469 |
+
{
|
1470 |
+
$ret = "";
|
1471 |
+
if (!isset($row['Create Procedure'])) {
|
1472 |
+
throw new Exception("Error getting procedure code, unknown output. " .
|
1473 |
+
"Please check 'https://bugs.mysql.com/bug.php?id=14564'");
|
1474 |
+
}
|
1475 |
+
$procedureStmt = $row['Create Procedure'];
|
1476 |
+
|
1477 |
+
$ret .= "/*!50003 DROP PROCEDURE IF EXISTS `" .
|
1478 |
+
$row['Procedure'] . "` */;" . PHP_EOL .
|
1479 |
+
"/*!40101 SET @saved_cs_client = @@character_set_client */;" . PHP_EOL .
|
1480 |
+
"/*!40101 SET character_set_client = " . $dumpSettings['default-character-set'] . " */;" . PHP_EOL .
|
1481 |
+
"DELIMITER ;;" . PHP_EOL .
|
1482 |
+
$procedureStmt . " ;;" . PHP_EOL .
|
1483 |
+
"DELIMITER ;" . PHP_EOL .
|
1484 |
+
"/*!40101 SET character_set_client = @saved_cs_client */;" . PHP_EOL . PHP_EOL;
|
1485 |
+
|
1486 |
+
return $ret;
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
public function show_tables()
|
1490 |
+
{
|
1491 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1492 |
+
$args = func_get_args();
|
1493 |
+
return "SELECT TABLE_NAME AS tbl_name " .
|
1494 |
+
"FROM INFORMATION_SCHEMA.TABLES " .
|
1495 |
+
"WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='${args[0]}'";
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
public function show_views()
|
1499 |
+
{
|
1500 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1501 |
+
$args = func_get_args();
|
1502 |
+
return "SELECT TABLE_NAME AS tbl_name " .
|
1503 |
+
"FROM INFORMATION_SCHEMA.TABLES " .
|
1504 |
+
"WHERE TABLE_TYPE='VIEW' AND TABLE_SCHEMA='${args[0]}'";
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
public function show_triggers()
|
1508 |
+
{
|
1509 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1510 |
+
$args = func_get_args();
|
1511 |
+
return "SHOW TRIGGERS FROM `${args[0]}`;";
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
public function show_columns()
|
1515 |
+
{
|
1516 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1517 |
+
$args = func_get_args();
|
1518 |
+
return "SHOW COLUMNS FROM `${args[0]}`;";
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
public function show_procedures()
|
1522 |
+
{
|
1523 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1524 |
+
$args = func_get_args();
|
1525 |
+
return "SELECT SPECIFIC_NAME AS procedure_name " .
|
1526 |
+
"FROM INFORMATION_SCHEMA.ROUTINES " .
|
1527 |
+
"WHERE ROUTINE_TYPE='PROCEDURE' AND ROUTINE_SCHEMA='${args[0]}'";
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
public function setup_transaction()
|
1531 |
+
{
|
1532 |
+
return "SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ";
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
public function start_transaction()
|
1536 |
+
{
|
1537 |
+
return "START TRANSACTION";
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
public function commit_transaction()
|
1541 |
+
{
|
1542 |
+
return "COMMIT";
|
1543 |
+
}
|
1544 |
+
|
1545 |
+
public function lock_table()
|
1546 |
+
{
|
1547 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1548 |
+
$args = func_get_args();
|
1549 |
+
return $this->dbHandler->exec("LOCK TABLES `${args[0]}` READ LOCAL");
|
1550 |
+
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
public function unlock_table()
|
1554 |
+
{
|
1555 |
+
return $this->dbHandler->exec("UNLOCK TABLES");
|
1556 |
+
}
|
1557 |
+
|
1558 |
+
public function start_add_lock_table()
|
1559 |
+
{
|
1560 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1561 |
+
$args = func_get_args();
|
1562 |
+
|
1563 |
+
return "LOCK TABLES `${args[0]}` WRITE;" . PHP_EOL;
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
public function end_add_lock_table()
|
1567 |
+
{
|
1568 |
+
return "UNLOCK TABLES;" . PHP_EOL;
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
public function start_add_disable_keys()
|
1572 |
+
{
|
1573 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1574 |
+
$args = func_get_args();
|
1575 |
+
return "/*!40000 ALTER TABLE `${args[0]}` DISABLE KEYS */;" .
|
1576 |
+
PHP_EOL;
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
public function end_add_disable_keys()
|
1580 |
+
{
|
1581 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1582 |
+
$args = func_get_args();
|
1583 |
+
return "/*!40000 ALTER TABLE `${args[0]}` ENABLE KEYS */;" .
|
1584 |
+
PHP_EOL;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
public function start_disable_autocommit()
|
1588 |
+
{
|
1589 |
+
return "SET autocommit=0;" . PHP_EOL;
|
1590 |
+
}
|
1591 |
+
|
1592 |
+
public function end_disable_autocommit()
|
1593 |
+
{
|
1594 |
+
return "COMMIT;" . PHP_EOL;
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
public function add_drop_database()
|
1598 |
+
{
|
1599 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1600 |
+
$args = func_get_args();
|
1601 |
+
|
1602 |
+
return "/*!40000 DROP DATABASE IF EXISTS `${args[0]}`*/;" .
|
1603 |
+
PHP_EOL . PHP_EOL;
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
public function add_drop_trigger()
|
1607 |
+
{
|
1608 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1609 |
+
$args = func_get_args();
|
1610 |
+
return "DROP TRIGGER IF EXISTS `${args[0]}`;" . PHP_EOL;
|
1611 |
+
}
|
1612 |
+
|
1613 |
+
public function drop_table()
|
1614 |
+
{
|
1615 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1616 |
+
$args = func_get_args();
|
1617 |
+
return "DROP TABLE IF EXISTS `${args[0]}`;" . PHP_EOL;
|
1618 |
+
}
|
1619 |
+
|
1620 |
+
public function drop_view()
|
1621 |
+
{
|
1622 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1623 |
+
$args = func_get_args();
|
1624 |
+
return "DROP TABLE IF EXISTS `${args[0]}`;" . PHP_EOL .
|
1625 |
+
"/*!50001 DROP VIEW IF EXISTS `${args[0]}`*/;" . PHP_EOL;
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
public function getDatabaseHeader()
|
1629 |
+
{
|
1630 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1631 |
+
$args = func_get_args();
|
1632 |
+
return "--" . PHP_EOL .
|
1633 |
+
"-- Current Database: `${args[0]}`" . PHP_EOL .
|
1634 |
+
"--" . PHP_EOL . PHP_EOL;
|
1635 |
+
}
|
1636 |
+
|
1637 |
+
/**
|
1638 |
+
* Decode column metadata and fill info structure.
|
1639 |
+
* type, is_numeric and is_blob will always be available.
|
1640 |
+
*
|
1641 |
+
* @param array $colType Array returned from "SHOW COLUMNS FROM tableName"
|
1642 |
+
* @return array
|
1643 |
+
*/
|
1644 |
+
public function parseColumnType($colType)
|
1645 |
+
{
|
1646 |
+
$colInfo = array();
|
1647 |
+
$colParts = explode(" ", $colType['Type']);
|
1648 |
+
|
1649 |
+
if($fparen = strpos($colParts[0], "("))
|
1650 |
+
{
|
1651 |
+
$colInfo['type'] = substr($colParts[0], 0, $fparen);
|
1652 |
+
$colInfo['length'] = str_replace(")", "", substr($colParts[0], $fparen+1));
|
1653 |
+
$colInfo['attributes'] = isset($colParts[1]) ? $colParts[1] : NULL;
|
1654 |
+
}
|
1655 |
+
else
|
1656 |
+
{
|
1657 |
+
$colInfo['type'] = $colParts[0];
|
1658 |
+
}
|
1659 |
+
$colInfo['is_numeric'] = in_array($colInfo['type'], $this->mysqlTypes['numerical']);
|
1660 |
+
$colInfo['is_blob'] = in_array($colInfo['type'], $this->mysqlTypes['blob']);
|
1661 |
+
|
1662 |
+
return $colInfo;
|
1663 |
+
}
|
1664 |
+
|
1665 |
+
public function backup_parameters()
|
1666 |
+
{
|
1667 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1668 |
+
$args = func_get_args();
|
1669 |
+
$dumpSettings = $args[0];
|
1670 |
+
$ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL .
|
1671 |
+
"/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL .
|
1672 |
+
"/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL .
|
1673 |
+
"/*!40101 SET NAMES " . $dumpSettings['default-character-set'] . " */;" . PHP_EOL;
|
1674 |
+
|
1675 |
+
if (false === $dumpSettings['skip-tz-utc']) {
|
1676 |
+
$ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL .
|
1677 |
+
"/*!40103 SET TIME_ZONE='+00:00' */;" . PHP_EOL;
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
$ret .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;" . PHP_EOL .
|
1681 |
+
"/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;" . PHP_EOL .
|
1682 |
+
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;" . PHP_EOL .
|
1683 |
+
"/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;" . PHP_EOL .PHP_EOL;
|
1684 |
+
|
1685 |
+
return $ret;
|
1686 |
+
}
|
1687 |
+
|
1688 |
+
public function restore_parameters()
|
1689 |
+
{
|
1690 |
+
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1691 |
+
$args = func_get_args();
|
1692 |
+
$dumpSettings = $args[0];
|
1693 |
+
$ret = "";
|
1694 |
+
|
1695 |
+
if (false === $dumpSettings['skip-tz-utc']) {
|
1696 |
+
$ret .= "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;" . PHP_EOL;
|
1697 |
+
}
|
1698 |
+
|
1699 |
+
$ret .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;" . PHP_EOL .
|
1700 |
+
"/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;" . PHP_EOL .
|
1701 |
+
"/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;" . PHP_EOL .
|
1702 |
+
"/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;" . PHP_EOL .
|
1703 |
+
"/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;" . PHP_EOL .
|
1704 |
+
"/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;" . PHP_EOL .
|
1705 |
+
"/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;" . PHP_EOL . PHP_EOL;
|
1706 |
+
|
1707 |
+
return $ret;
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
private function check_parameters($num_args, $expected_num_args, $method_name)
|
1711 |
+
{
|
1712 |
+
if ( $num_args != $expected_num_args ) {
|
1713 |
+
throw new Exception("Unexpected parameter passed to $method_name");
|
1714 |
+
}
|
1715 |
+
return;
|
1716 |
+
}
|
1717 |
+
}
|
vendor/symfony/finder/Adapter/PhpAdapter.php
CHANGED
@@ -31,10 +31,13 @@ class PhpAdapter extends AbstractAdapter
|
|
31 |
$flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
|
32 |
}
|
33 |
|
34 |
-
$iterator = new \
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
|
39 |
if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
|
40 |
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
|
@@ -44,10 +47,6 @@ class PhpAdapter extends AbstractAdapter
|
|
44 |
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
|
45 |
}
|
46 |
|
47 |
-
if ($this->exclude) {
|
48 |
-
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
49 |
-
}
|
50 |
-
|
51 |
if ($this->names || $this->notNames) {
|
52 |
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
|
53 |
}
|
@@ -68,15 +67,15 @@ class PhpAdapter extends AbstractAdapter
|
|
68 |
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
71 |
if ($this->sort) {
|
72 |
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
73 |
$iterator = $iteratorAggregate->getIterator();
|
74 |
}
|
75 |
|
76 |
-
if ($this->paths || $this->notPaths) {
|
77 |
-
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
78 |
-
}
|
79 |
-
|
80 |
return $iterator;
|
81 |
}
|
82 |
|
31 |
$flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
|
32 |
}
|
33 |
|
34 |
+
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
35 |
+
|
36 |
+
if ($this->exclude) {
|
37 |
+
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
38 |
+
}
|
39 |
+
|
40 |
+
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
41 |
|
42 |
if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
|
43 |
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
|
47 |
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
50 |
if ($this->names || $this->notNames) {
|
51 |
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
|
52 |
}
|
67 |
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
68 |
}
|
69 |
|
70 |
+
if ($this->paths || $this->notPaths) {
|
71 |
+
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
72 |
+
}
|
73 |
+
|
74 |
if ($this->sort) {
|
75 |
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
76 |
$iterator = $iteratorAggregate->getIterator();
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
79 |
return $iterator;
|
80 |
}
|
81 |
|
vendor/symfony/finder/Finder.php
CHANGED
@@ -39,8 +39,6 @@ use Symfony\Component\Finder\Iterator\SortableIterator;
|
|
39 |
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
40 |
*
|
41 |
* @author Fabien Potencier <fabien@symfony.com>
|
42 |
-
*
|
43 |
-
* @api
|
44 |
*/
|
45 |
class Finder implements \IteratorAggregate, \Countable
|
46 |
{
|
@@ -88,8 +86,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
88 |
* Creates a new Finder.
|
89 |
*
|
90 |
* @return Finder A new Finder instance
|
91 |
-
*
|
92 |
-
* @api
|
93 |
*/
|
94 |
public static function create()
|
95 |
{
|
@@ -176,8 +172,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
176 |
* Restricts the matching to directories only.
|
177 |
*
|
178 |
* @return Finder The current Finder instance
|
179 |
-
*
|
180 |
-
* @api
|
181 |
*/
|
182 |
public function directories()
|
183 |
{
|
@@ -190,8 +184,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
190 |
* Restricts the matching to files only.
|
191 |
*
|
192 |
* @return Finder The current Finder instance
|
193 |
-
*
|
194 |
-
* @api
|
195 |
*/
|
196 |
public function files()
|
197 |
{
|
@@ -214,8 +206,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
214 |
*
|
215 |
* @see DepthRangeFilterIterator
|
216 |
* @see NumberComparator
|
217 |
-
*
|
218 |
-
* @api
|
219 |
*/
|
220 |
public function depth($level)
|
221 |
{
|
@@ -241,8 +231,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
241 |
* @see strtotime
|
242 |
* @see DateRangeFilterIterator
|
243 |
* @see DateComparator
|
244 |
-
*
|
245 |
-
* @api
|
246 |
*/
|
247 |
public function date($date)
|
248 |
{
|
@@ -265,8 +253,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
265 |
* @return Finder The current Finder instance
|
266 |
*
|
267 |
* @see FilenameFilterIterator
|
268 |
-
*
|
269 |
-
* @api
|
270 |
*/
|
271 |
public function name($pattern)
|
272 |
{
|
@@ -283,8 +269,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
283 |
* @return Finder The current Finder instance
|
284 |
*
|
285 |
* @see FilenameFilterIterator
|
286 |
-
*
|
287 |
-
* @api
|
288 |
*/
|
289 |
public function notName($pattern)
|
290 |
{
|
@@ -394,8 +378,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
394 |
*
|
395 |
* @see SizeRangeFilterIterator
|
396 |
* @see NumberComparator
|
397 |
-
*
|
398 |
-
* @api
|
399 |
*/
|
400 |
public function size($size)
|
401 |
{
|
@@ -412,8 +394,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
412 |
* @return Finder The current Finder instance
|
413 |
*
|
414 |
* @see ExcludeDirectoryFilterIterator
|
415 |
-
*
|
416 |
-
* @api
|
417 |
*/
|
418 |
public function exclude($dirs)
|
419 |
{
|
@@ -430,8 +410,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
430 |
* @return Finder The current Finder instance
|
431 |
*
|
432 |
* @see ExcludeDirectoryFilterIterator
|
433 |
-
*
|
434 |
-
* @api
|
435 |
*/
|
436 |
public function ignoreDotFiles($ignoreDotFiles)
|
437 |
{
|
@@ -452,8 +430,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
452 |
* @return Finder The current Finder instance
|
453 |
*
|
454 |
* @see ExcludeDirectoryFilterIterator
|
455 |
-
*
|
456 |
-
* @api
|
457 |
*/
|
458 |
public function ignoreVCS($ignoreVCS)
|
459 |
{
|
@@ -494,8 +470,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
494 |
* @return Finder The current Finder instance
|
495 |
*
|
496 |
* @see SortableIterator
|
497 |
-
*
|
498 |
-
* @api
|
499 |
*/
|
500 |
public function sort(\Closure $closure)
|
501 |
{
|
@@ -512,8 +486,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
512 |
* @return Finder The current Finder instance
|
513 |
*
|
514 |
* @see SortableIterator
|
515 |
-
*
|
516 |
-
* @api
|
517 |
*/
|
518 |
public function sortByName()
|
519 |
{
|
@@ -530,8 +502,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
530 |
* @return Finder The current Finder instance
|
531 |
*
|
532 |
* @see SortableIterator
|
533 |
-
*
|
534 |
-
* @api
|
535 |
*/
|
536 |
public function sortByType()
|
537 |
{
|
@@ -550,8 +520,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
550 |
* @return Finder The current Finder instance
|
551 |
*
|
552 |
* @see SortableIterator
|
553 |
-
*
|
554 |
-
* @api
|
555 |
*/
|
556 |
public function sortByAccessedTime()
|
557 |
{
|
@@ -572,8 +540,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
572 |
* @return Finder The current Finder instance
|
573 |
*
|
574 |
* @see SortableIterator
|
575 |
-
*
|
576 |
-
* @api
|
577 |
*/
|
578 |
public function sortByChangedTime()
|
579 |
{
|
@@ -592,8 +558,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
592 |
* @return Finder The current Finder instance
|
593 |
*
|
594 |
* @see SortableIterator
|
595 |
-
*
|
596 |
-
* @api
|
597 |
*/
|
598 |
public function sortByModifiedTime()
|
599 |
{
|
@@ -613,8 +577,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
613 |
* @return Finder The current Finder instance
|
614 |
*
|
615 |
* @see CustomFilterIterator
|
616 |
-
*
|
617 |
-
* @api
|
618 |
*/
|
619 |
public function filter(\Closure $closure)
|
620 |
{
|
@@ -627,8 +589,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
627 |
* Forces the following of symlinks.
|
628 |
*
|
629 |
* @return Finder The current Finder instance
|
630 |
-
*
|
631 |
-
* @api
|
632 |
*/
|
633 |
public function followLinks()
|
634 |
{
|
@@ -661,8 +621,6 @@ class Finder implements \IteratorAggregate, \Countable
|
|
661 |
* @return Finder The current Finder instance
|
662 |
*
|
663 |
* @throws \InvalidArgumentException if one of the directories does not exist
|
664 |
-
*
|
665 |
-
* @api
|
666 |
*/
|
667 |
public function in($dirs)
|
668 |
{
|
39 |
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
40 |
*
|
41 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
42 |
*/
|
43 |
class Finder implements \IteratorAggregate, \Countable
|
44 |
{
|
86 |
* Creates a new Finder.
|
87 |
*
|
88 |
* @return Finder A new Finder instance
|
|
|
|
|
89 |
*/
|
90 |
public static function create()
|
91 |
{
|
172 |
* Restricts the matching to directories only.
|
173 |
*
|
174 |
* @return Finder The current Finder instance
|
|
|
|
|
175 |
*/
|
176 |
public function directories()
|
177 |
{
|
184 |
* Restricts the matching to files only.
|
185 |
*
|
186 |
* @return Finder The current Finder instance
|
|
|
|
|
187 |
*/
|
188 |
public function files()
|
189 |
{
|
206 |
*
|
207 |
* @see DepthRangeFilterIterator
|
208 |
* @see NumberComparator
|
|
|
|
|
209 |
*/
|
210 |
public function depth($level)
|
211 |
{
|
231 |
* @see strtotime
|
232 |
* @see DateRangeFilterIterator
|
233 |
* @see DateComparator
|
|
|
|
|
234 |
*/
|
235 |
public function date($date)
|
236 |
{
|
253 |
* @return Finder The current Finder instance
|
254 |
*
|
255 |
* @see FilenameFilterIterator
|
|
|
|
|
256 |
*/
|
257 |
public function name($pattern)
|
258 |
{
|
269 |
* @return Finder The current Finder instance
|
270 |
*
|
271 |
* @see FilenameFilterIterator
|
|
|
|
|
272 |
*/
|
273 |
public function notName($pattern)
|
274 |
{
|
378 |
*
|
379 |
* @see SizeRangeFilterIterator
|
380 |
* @see NumberComparator
|
|
|
|
|
381 |
*/
|
382 |
public function size($size)
|
383 |
{
|
394 |
* @return Finder The current Finder instance
|
395 |
*
|
396 |
* @see ExcludeDirectoryFilterIterator
|
|
|
|
|
397 |
*/
|
398 |
public function exclude($dirs)
|
399 |
{
|
410 |
* @return Finder The current Finder instance
|
411 |
*
|
412 |
* @see ExcludeDirectoryFilterIterator
|
|
|
|
|
413 |
*/
|
414 |
public function ignoreDotFiles($ignoreDotFiles)
|
415 |
{
|
430 |
* @return Finder The current Finder instance
|
431 |
*
|
432 |
* @see ExcludeDirectoryFilterIterator
|
|
|
|
|
433 |
*/
|
434 |
public function ignoreVCS($ignoreVCS)
|
435 |
{
|
470 |
* @return Finder The current Finder instance
|
471 |
*
|
472 |
* @see SortableIterator
|
|
|
|
|
473 |
*/
|
474 |
public function sort(\Closure $closure)
|
475 |
{
|
486 |
* @return Finder The current Finder instance
|
487 |
*
|
488 |
* @see SortableIterator
|
|
|
|
|
489 |
*/
|
490 |
public function sortByName()
|
491 |
{
|
502 |
* @return Finder The current Finder instance
|
503 |
*
|
504 |
* @see SortableIterator
|
|
|
|
|
505 |
*/
|
506 |
public function sortByType()
|
507 |
{
|
520 |
* @return Finder The current Finder instance
|
521 |
*
|
522 |
* @see SortableIterator
|
|
|
|
|
523 |
*/
|
524 |
public function sortByAccessedTime()
|
525 |
{
|
540 |
* @return Finder The current Finder instance
|
541 |
*
|
542 |
* @see SortableIterator
|
|
|
|
|
543 |
*/
|
544 |
public function sortByChangedTime()
|
545 |
{
|
558 |
* @return Finder The current Finder instance
|
559 |
*
|
560 |
* @see SortableIterator
|
|
|
|
|
561 |
*/
|
562 |
public function sortByModifiedTime()
|
563 |
{
|
577 |
* @return Finder The current Finder instance
|
578 |
*
|
579 |
* @see CustomFilterIterator
|
|
|
|
|
580 |
*/
|
581 |
public function filter(\Closure $closure)
|
582 |
{
|
589 |
* Forces the following of symlinks.
|
590 |
*
|
591 |
* @return Finder The current Finder instance
|
|
|
|
|
592 |
*/
|
593 |
public function followLinks()
|
594 |
{
|
621 |
* @return Finder The current Finder instance
|
622 |
*
|
623 |
* @throws \InvalidArgumentException if one of the directories does not exist
|
|
|
|
|
624 |
*/
|
625 |
public function in($dirs)
|
626 |
{
|
vendor/symfony/finder/Iterator/CustomFilterIterator.php
CHANGED
@@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator
|
|
26 |
/**
|
27 |
* Constructor.
|
28 |
*
|
29 |
-
* @param \Iterator
|
30 |
-
* @param
|
31 |
*
|
32 |
* @throws \InvalidArgumentException
|
33 |
*/
|
26 |
/**
|
27 |
* Constructor.
|
28 |
*
|
29 |
+
* @param \Iterator $iterator The Iterator to filter
|
30 |
+
* @param callable[] $filters An array of PHP callbacks
|
31 |
*
|
32 |
* @throws \InvalidArgumentException
|
33 |
*/
|
vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php
CHANGED
@@ -16,9 +16,12 @@ namespace Symfony\Component\Finder\Iterator;
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class ExcludeDirectoryFilterIterator extends FilterIterator
|
20 |
{
|
21 |
-
private $
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
24 |
* Constructor.
|
@@ -28,8 +31,18 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
|
|
28 |
*/
|
29 |
public function __construct(\Iterator $iterator, array $directories)
|
30 |
{
|
|
|
|
|
|
|
31 |
foreach ($directories as $directory) {
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
parent::__construct($iterator);
|
@@ -42,14 +55,31 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
|
|
42 |
*/
|
43 |
public function accept()
|
44 |
{
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
return true;
|
54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
|
20 |
{
|
21 |
+
private $iterator;
|
22 |
+
private $isRecursive;
|
23 |
+
private $excludedDirs = array();
|
24 |
+
private $excludedPattern;
|
25 |
|
26 |
/**
|
27 |
* Constructor.
|
31 |
*/
|
32 |
public function __construct(\Iterator $iterator, array $directories)
|
33 |
{
|
34 |
+
$this->iterator = $iterator;
|
35 |
+
$this->isRecursive = $iterator instanceof \RecursiveIterator;
|
36 |
+
$patterns = array();
|
37 |
foreach ($directories as $directory) {
|
38 |
+
if (!$this->isRecursive || false !== strpos($directory, '/')) {
|
39 |
+
$patterns[] = preg_quote($directory, '#');
|
40 |
+
} else {
|
41 |
+
$this->excludedDirs[$directory] = true;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
if ($patterns) {
|
45 |
+
$this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
|
46 |
}
|
47 |
|
48 |
parent::__construct($iterator);
|
55 |
*/
|
56 |
public function accept()
|
57 |
{
|
58 |
+
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($this->excludedPattern) {
|
63 |
+
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
|
64 |
+
$path = str_replace('\\', '/', $path);
|
65 |
+
|
66 |
+
return !preg_match($this->excludedPattern, $path);
|
67 |
}
|
68 |
|
69 |
return true;
|
70 |
}
|
71 |
+
|
72 |
+
public function hasChildren()
|
73 |
+
{
|
74 |
+
return $this->isRecursive && $this->iterator->hasChildren();
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getChildren()
|
78 |
+
{
|
79 |
+
$children = new self($this->iterator->getChildren(), array());
|
80 |
+
$children->excludedDirs = $this->excludedDirs;
|
81 |
+
$children->excludedPattern = $this->excludedPattern;
|
82 |
+
|
83 |
+
return $children;
|
84 |
+
}
|
85 |
}
|
vendor/symfony/finder/Iterator/PathFilterIterator.php
CHANGED
@@ -29,7 +29,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
|
|
29 |
$filename = $this->current()->getRelativePathname();
|
30 |
|
31 |
if ('\\' === DIRECTORY_SEPARATOR) {
|
32 |
-
$filename =
|
33 |
}
|
34 |
|
35 |
// should at least not match one rule to exclude
|
29 |
$filename = $this->current()->getRelativePathname();
|
30 |
|
31 |
if ('\\' === DIRECTORY_SEPARATOR) {
|
32 |
+
$filename = str_replace('\\', '/', $filename);
|
33 |
}
|
34 |
|
35 |
// should at least not match one rule to exclude
|
vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php
CHANGED
@@ -31,6 +31,11 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|
31 |
*/
|
32 |
private $rewindable;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* Constructor.
|
36 |
*
|
@@ -48,6 +53,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|
48 |
|
49 |
parent::__construct($path, $flags);
|
50 |
$this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -57,7 +66,17 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|
57 |
*/
|
58 |
public function current()
|
59 |
{
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -73,6 +92,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|
73 |
if ($children instanceof self) {
|
74 |
// parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore
|
75 |
$children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
return $children;
|
31 |
*/
|
32 |
private $rewindable;
|
33 |
|
34 |
+
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
|
35 |
+
private $rootPath;
|
36 |
+
private $subPath;
|
37 |
+
private $directorySeparator = '/';
|
38 |
+
|
39 |
/**
|
40 |
* Constructor.
|
41 |
*
|
53 |
|
54 |
parent::__construct($path, $flags);
|
55 |
$this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
|
56 |
+
$this->rootPath = (string) $path;
|
57 |
+
if ('/' !== DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
|
58 |
+
$this->directorySeparator = DIRECTORY_SEPARATOR;
|
59 |
+
}
|
60 |
}
|
61 |
|
62 |
/**
|
66 |
*/
|
67 |
public function current()
|
68 |
{
|
69 |
+
// the logic here avoids redoing the same work in all iterations
|
70 |
+
|
71 |
+
if (null === $subPathname = $this->subPath) {
|
72 |
+
$subPathname = $this->subPath = (string) $this->getSubPath();
|
73 |
+
}
|
74 |
+
if ('' !== $subPathname) {
|
75 |
+
$subPathname .= $this->directorySeparator;
|
76 |
+
}
|
77 |
+
$subPathname .= $this->getFilename();
|
78 |
+
|
79 |
+
return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
|
80 |
}
|
81 |
|
82 |
/**
|
92 |
if ($children instanceof self) {
|
93 |
// parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore
|
94 |
$children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
|
95 |
+
|
96 |
+
// performance optimization to avoid redoing the same work in all children
|
97 |
+
$children->rewindable = &$this->rewindable;
|
98 |
+
$children->rootPath = $this->rootPath;
|
99 |
}
|
100 |
|
101 |
return $children;
|
vendor/symfony/finder/Tests/Comparator/ComparatorTest.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Comparator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Comparator\Comparator;
|
15 |
-
|
16 |
-
class ComparatorTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function testGetSetOperator()
|
19 |
-
{
|
20 |
-
$comparator = new Comparator();
|
21 |
-
try {
|
22 |
-
$comparator->setOperator('foo');
|
23 |
-
$this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
24 |
-
} catch (\Exception $e) {
|
25 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
26 |
-
}
|
27 |
-
|
28 |
-
$comparator = new Comparator();
|
29 |
-
$comparator->setOperator('>');
|
30 |
-
$this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testGetSetTarget()
|
34 |
-
{
|
35 |
-
$comparator = new Comparator();
|
36 |
-
$comparator->setTarget(8);
|
37 |
-
$this->assertEquals(8, $comparator->getTarget(), '->getTarget() returns the target');
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @dataProvider getTestData
|
42 |
-
*/
|
43 |
-
public function testTest($operator, $target, $match, $noMatch)
|
44 |
-
{
|
45 |
-
$c = new Comparator();
|
46 |
-
$c->setOperator($operator);
|
47 |
-
$c->setTarget($target);
|
48 |
-
|
49 |
-
foreach ($match as $m) {
|
50 |
-
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
51 |
-
}
|
52 |
-
|
53 |
-
foreach ($noMatch as $m) {
|
54 |
-
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getTestData()
|
59 |
-
{
|
60 |
-
return array(
|
61 |
-
array('<', '1000', array('500', '999'), array('1000', '1500')),
|
62 |
-
);
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Comparator/DateComparatorTest.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Comparator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Comparator\DateComparator;
|
15 |
-
|
16 |
-
class DateComparatorTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function testConstructor()
|
19 |
-
{
|
20 |
-
try {
|
21 |
-
new DateComparator('foobar');
|
22 |
-
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
23 |
-
} catch (\Exception $e) {
|
24 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
25 |
-
}
|
26 |
-
|
27 |
-
try {
|
28 |
-
new DateComparator('');
|
29 |
-
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
30 |
-
} catch (\Exception $e) {
|
31 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @dataProvider getTestData
|
37 |
-
*/
|
38 |
-
public function testTest($test, $match, $noMatch)
|
39 |
-
{
|
40 |
-
$c = new DateComparator($test);
|
41 |
-
|
42 |
-
foreach ($match as $m) {
|
43 |
-
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
44 |
-
}
|
45 |
-
|
46 |
-
foreach ($noMatch as $m) {
|
47 |
-
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
public function getTestData()
|
52 |
-
{
|
53 |
-
return array(
|
54 |
-
array('< 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
55 |
-
array('until 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
56 |
-
array('before 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
57 |
-
array('> 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
58 |
-
array('after 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
59 |
-
array('since 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
60 |
-
array('!= 2005-10-10', array(strtotime('2005-10-11')), array(strtotime('2005-10-10'))),
|
61 |
-
);
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Comparator/NumberComparatorTest.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Comparator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Comparator\NumberComparator;
|
15 |
-
|
16 |
-
class NumberComparatorTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getConstructorTestData
|
20 |
-
*/
|
21 |
-
public function testConstructor($successes, $failures)
|
22 |
-
{
|
23 |
-
foreach ($successes as $s) {
|
24 |
-
new NumberComparator($s);
|
25 |
-
}
|
26 |
-
|
27 |
-
foreach ($failures as $f) {
|
28 |
-
try {
|
29 |
-
new NumberComparator($f);
|
30 |
-
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
31 |
-
} catch (\Exception $e) {
|
32 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
33 |
-
}
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @dataProvider getTestData
|
39 |
-
*/
|
40 |
-
public function testTest($test, $match, $noMatch)
|
41 |
-
{
|
42 |
-
$c = new NumberComparator($test);
|
43 |
-
|
44 |
-
foreach ($match as $m) {
|
45 |
-
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
46 |
-
}
|
47 |
-
|
48 |
-
foreach ($noMatch as $m) {
|
49 |
-
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
public function getTestData()
|
54 |
-
{
|
55 |
-
return array(
|
56 |
-
array('< 1000', array('500', '999'), array('1000', '1500')),
|
57 |
-
|
58 |
-
array('< 1K', array('500', '999'), array('1000', '1500')),
|
59 |
-
array('<1k', array('500', '999'), array('1000', '1500')),
|
60 |
-
array(' < 1 K ', array('500', '999'), array('1000', '1500')),
|
61 |
-
array('<= 1K', array('1000'), array('1001')),
|
62 |
-
array('> 1K', array('1001'), array('1000')),
|
63 |
-
array('>= 1K', array('1000'), array('999')),
|
64 |
-
|
65 |
-
array('< 1KI', array('500', '1023'), array('1024', '1500')),
|
66 |
-
array('<= 1KI', array('1024'), array('1025')),
|
67 |
-
array('> 1KI', array('1025'), array('1024')),
|
68 |
-
array('>= 1KI', array('1024'), array('1023')),
|
69 |
-
|
70 |
-
array('1KI', array('1024'), array('1023', '1025')),
|
71 |
-
array('==1KI', array('1024'), array('1023', '1025')),
|
72 |
-
|
73 |
-
array('==1m', array('1000000'), array('999999', '1000001')),
|
74 |
-
array('==1mi', array(1024 * 1024), array(1024 * 1024 - 1, 1024 * 1024 + 1)),
|
75 |
-
|
76 |
-
array('==1g', array('1000000000'), array('999999999', '1000000001')),
|
77 |
-
array('==1gi', array(1024 * 1024 * 1024), array(1024 * 1024 * 1024 - 1, 1024 * 1024 * 1024 + 1)),
|
78 |
-
|
79 |
-
array('!= 1000', array('500', '999'), array('1000')),
|
80 |
-
);
|
81 |
-
}
|
82 |
-
|
83 |
-
public function getConstructorTestData()
|
84 |
-
{
|
85 |
-
return array(
|
86 |
-
array(
|
87 |
-
array(
|
88 |
-
'1', '0',
|
89 |
-
'3.5', '33.55', '123.456', '123456.78',
|
90 |
-
'.1', '.123',
|
91 |
-
'.0', '0.0',
|
92 |
-
'1.', '0.', '123.',
|
93 |
-
'==1', '!=1', '<1', '>1', '<=1', '>=1',
|
94 |
-
'==1k', '==1ki', '==1m', '==1mi', '==1g', '==1gi',
|
95 |
-
'1k', '1ki', '1m', '1mi', '1g', '1gi',
|
96 |
-
),
|
97 |
-
array(
|
98 |
-
false, null, '',
|
99 |
-
' ', 'foobar',
|
100 |
-
'=1', '===1',
|
101 |
-
'0 . 1', '123 .45', '234. 567',
|
102 |
-
'..', '.0.', '0.1.2',
|
103 |
-
),
|
104 |
-
),
|
105 |
-
);
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Expression/ExpressionTest.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Expression;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Expression\Expression;
|
15 |
-
|
16 |
-
class ExpressionTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getTypeGuesserData
|
20 |
-
*/
|
21 |
-
public function testTypeGuesser($expr, $type)
|
22 |
-
{
|
23 |
-
$this->assertEquals($type, Expression::create($expr)->getType());
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @dataProvider getCaseSensitiveData
|
28 |
-
*/
|
29 |
-
public function testCaseSensitive($expr, $isCaseSensitive)
|
30 |
-
{
|
31 |
-
$this->assertEquals($isCaseSensitive, Expression::create($expr)->isCaseSensitive());
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @dataProvider getRegexRenderingData
|
36 |
-
*/
|
37 |
-
public function testRegexRendering($expr, $body)
|
38 |
-
{
|
39 |
-
$this->assertEquals($body, Expression::create($expr)->renderPattern());
|
40 |
-
}
|
41 |
-
|
42 |
-
public function getTypeGuesserData()
|
43 |
-
{
|
44 |
-
return array(
|
45 |
-
array('{foo}', Expression::TYPE_REGEX),
|
46 |
-
array('/foo/', Expression::TYPE_REGEX),
|
47 |
-
array('foo', Expression::TYPE_GLOB),
|
48 |
-
array('foo*', Expression::TYPE_GLOB),
|
49 |
-
);
|
50 |
-
}
|
51 |
-
|
52 |
-
public function getCaseSensitiveData()
|
53 |
-
{
|
54 |
-
return array(
|
55 |
-
array('{foo}m', true),
|
56 |
-
array('/foo/i', false),
|
57 |
-
array('foo*', true),
|
58 |
-
);
|
59 |
-
}
|
60 |
-
|
61 |
-
public function getRegexRenderingData()
|
62 |
-
{
|
63 |
-
return array(
|
64 |
-
array('{foo}m', 'foo'),
|
65 |
-
array('/foo/i', 'foo'),
|
66 |
-
);
|
67 |
-
}
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Expression/GlobTest.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Expression;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Expression\Expression;
|
15 |
-
|
16 |
-
class GlobTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getToRegexData
|
20 |
-
*/
|
21 |
-
public function testGlobToRegex($glob, $match, $noMatch)
|
22 |
-
{
|
23 |
-
foreach ($match as $m) {
|
24 |
-
$this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
|
25 |
-
}
|
26 |
-
|
27 |
-
foreach ($noMatch as $m) {
|
28 |
-
$this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getToRegexData()
|
33 |
-
{
|
34 |
-
return array(
|
35 |
-
array('', array(''), array('f', '/')),
|
36 |
-
array('*', array('foo'), array('foo/', '/foo')),
|
37 |
-
array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
|
38 |
-
array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
|
39 |
-
array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
|
40 |
-
array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
|
41 |
-
array('foo,bar', array('foo,bar'), array('foo', 'bar')),
|
42 |
-
array('fo{o,\\,}', array('foo', 'fo,'), array()),
|
43 |
-
array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
|
44 |
-
array('/foo', array('/foo'), array('foo')),
|
45 |
-
);
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Expression/RegexTest.php
DELETED
@@ -1,143 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Expression;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Expression\Expression;
|
15 |
-
|
16 |
-
class RegexTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getHasFlagsData
|
20 |
-
*/
|
21 |
-
public function testHasFlags($regex, $start, $end)
|
22 |
-
{
|
23 |
-
$expr = new Expression($regex);
|
24 |
-
|
25 |
-
$this->assertEquals($start, $expr->getRegex()->hasStartFlag());
|
26 |
-
$this->assertEquals($end, $expr->getRegex()->hasEndFlag());
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @dataProvider getHasJokersData
|
31 |
-
*/
|
32 |
-
public function testHasJokers($regex, $start, $end)
|
33 |
-
{
|
34 |
-
$expr = new Expression($regex);
|
35 |
-
|
36 |
-
$this->assertEquals($start, $expr->getRegex()->hasStartJoker());
|
37 |
-
$this->assertEquals($end, $expr->getRegex()->hasEndJoker());
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @dataProvider getSetFlagsData
|
42 |
-
*/
|
43 |
-
public function testSetFlags($regex, $start, $end, $expected)
|
44 |
-
{
|
45 |
-
$expr = new Expression($regex);
|
46 |
-
$expr->getRegex()->setStartFlag($start)->setEndFlag($end);
|
47 |
-
|
48 |
-
$this->assertEquals($expected, $expr->render());
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @dataProvider getSetJokersData
|
53 |
-
*/
|
54 |
-
public function testSetJokers($regex, $start, $end, $expected)
|
55 |
-
{
|
56 |
-
$expr = new Expression($regex);
|
57 |
-
$expr->getRegex()->setStartJoker($start)->setEndJoker($end);
|
58 |
-
|
59 |
-
$this->assertEquals($expected, $expr->render());
|
60 |
-
}
|
61 |
-
|
62 |
-
public function testOptions()
|
63 |
-
{
|
64 |
-
$expr = new Expression('~abc~is');
|
65 |
-
$expr->getRegex()->removeOption('i')->addOption('m');
|
66 |
-
|
67 |
-
$this->assertEquals('~abc~sm', $expr->render());
|
68 |
-
}
|
69 |
-
|
70 |
-
public function testMixFlagsAndJokers()
|
71 |
-
{
|
72 |
-
$expr = new Expression('~^.*abc.*$~is');
|
73 |
-
|
74 |
-
$expr->getRegex()->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
|
75 |
-
$this->assertEquals('~abc~is', $expr->render());
|
76 |
-
|
77 |
-
$expr->getRegex()->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
|
78 |
-
$this->assertEquals('~^.*abc.*$~is', $expr->render());
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @dataProvider getReplaceJokersTestData
|
83 |
-
*/
|
84 |
-
public function testReplaceJokers($regex, $expected)
|
85 |
-
{
|
86 |
-
$expr = new Expression($regex);
|
87 |
-
$expr = $expr->getRegex()->replaceJokers('@');
|
88 |
-
|
89 |
-
$this->assertEquals($expected, $expr->renderPattern());
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getHasFlagsData()
|
93 |
-
{
|
94 |
-
return array(
|
95 |
-
array('~^abc~', true, false),
|
96 |
-
array('~abc$~', false, true),
|
97 |
-
array('~abc~', false, false),
|
98 |
-
array('~^abc$~', true, true),
|
99 |
-
array('~^abc\\$~', true, false),
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
public function getHasJokersData()
|
104 |
-
{
|
105 |
-
return array(
|
106 |
-
array('~.*abc~', true, false),
|
107 |
-
array('~abc.*~', false, true),
|
108 |
-
array('~abc~', false, false),
|
109 |
-
array('~.*abc.*~', true, true),
|
110 |
-
array('~.*abc\\.*~', true, false),
|
111 |
-
);
|
112 |
-
}
|
113 |
-
|
114 |
-
public function getSetFlagsData()
|
115 |
-
{
|
116 |
-
return array(
|
117 |
-
array('~abc~', true, false, '~^abc~'),
|
118 |
-
array('~abc~', false, true, '~abc$~'),
|
119 |
-
array('~abc~', false, false, '~abc~'),
|
120 |
-
array('~abc~', true, true, '~^abc$~'),
|
121 |
-
);
|
122 |
-
}
|
123 |
-
|
124 |
-
public function getSetJokersData()
|
125 |
-
{
|
126 |
-
return array(
|
127 |
-
array('~abc~', true, false, '~.*abc~'),
|
128 |
-
array('~abc~', false, true, '~abc.*~'),
|
129 |
-
array('~abc~', false, false, '~abc~'),
|
130 |
-
array('~abc~', true, true, '~.*abc.*~'),
|
131 |
-
);
|
132 |
-
}
|
133 |
-
|
134 |
-
public function getReplaceJokersTestData()
|
135 |
-
{
|
136 |
-
return array(
|
137 |
-
array('~.abc~', '@abc'),
|
138 |
-
array('~\\.abc~', '\\.abc'),
|
139 |
-
array('~\\\\.abc~', '\\\\@abc'),
|
140 |
-
array('~\\\\\\.abc~', '\\\\\\.abc'),
|
141 |
-
);
|
142 |
-
}
|
143 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/FakeAdapter/DummyAdapter.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\FakeAdapter;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Adapter\AbstractAdapter;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Jean-François Simon <contact@jfsimon.fr>
|
18 |
-
*/
|
19 |
-
class DummyAdapter extends AbstractAdapter
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var \Iterator
|
23 |
-
*/
|
24 |
-
private $iterator;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param \Iterator $iterator
|
28 |
-
*/
|
29 |
-
public function __construct(\Iterator $iterator)
|
30 |
-
{
|
31 |
-
$this->iterator = $iterator;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
-
public function searchInDirectory($dir)
|
38 |
-
{
|
39 |
-
return $this->iterator;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
-
public function getName()
|
46 |
-
{
|
47 |
-
return 'yes';
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* {@inheritdoc}
|
52 |
-
*/
|
53 |
-
protected function canBeUsed()
|
54 |
-
{
|
55 |
-
return true;
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/FakeAdapter/FailingAdapter.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\FakeAdapter;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Adapter\AbstractAdapter;
|
15 |
-
use Symfony\Component\Finder\Exception\AdapterFailureException;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Jean-François Simon <contact@jfsimon.fr>
|
19 |
-
*/
|
20 |
-
class FailingAdapter extends AbstractAdapter
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* {@inheritdoc}
|
24 |
-
*/
|
25 |
-
public function searchInDirectory($dir)
|
26 |
-
{
|
27 |
-
throw new AdapterFailureException($this);
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* {@inheritdoc}
|
32 |
-
*/
|
33 |
-
public function getName()
|
34 |
-
{
|
35 |
-
return 'failing';
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
-
protected function canBeUsed()
|
42 |
-
{
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/FakeAdapter/NamedAdapter.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\FakeAdapter;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Adapter\AbstractAdapter;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Jean-François Simon <contact@jfsimon.fr>
|
18 |
-
*/
|
19 |
-
class NamedAdapter extends AbstractAdapter
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
private $name;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param string $name
|
28 |
-
*/
|
29 |
-
public function __construct($name)
|
30 |
-
{
|
31 |
-
$this->name = $name;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
-
public function searchInDirectory($dir)
|
38 |
-
{
|
39 |
-
return new \ArrayIterator(array());
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
-
public function getName()
|
46 |
-
{
|
47 |
-
return $this->name;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* {@inheritdoc}
|
52 |
-
*/
|
53 |
-
protected function canBeUsed()
|
54 |
-
{
|
55 |
-
return true;
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/FakeAdapter/UnsupportedAdapter.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\FakeAdapter;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Adapter\AbstractAdapter;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Jean-François Simon <contact@jfsimon.fr>
|
18 |
-
*/
|
19 |
-
class UnsupportedAdapter extends AbstractAdapter
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* {@inheritdoc}
|
23 |
-
*/
|
24 |
-
public function searchInDirectory($dir)
|
25 |
-
{
|
26 |
-
return new \ArrayIterator(array());
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* {@inheritdoc}
|
31 |
-
*/
|
32 |
-
public function getName()
|
33 |
-
{
|
34 |
-
return 'unsupported';
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* {@inheritdoc}
|
39 |
-
*/
|
40 |
-
protected function canBeUsed()
|
41 |
-
{
|
42 |
-
return false;
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/FinderTest.php
DELETED
@@ -1,866 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Finder;
|
15 |
-
use Symfony\Component\Finder\Adapter;
|
16 |
-
|
17 |
-
class FinderTest extends Iterator\RealIteratorTestCase
|
18 |
-
{
|
19 |
-
public function testCreate()
|
20 |
-
{
|
21 |
-
$this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create());
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @dataProvider getAdaptersTestData
|
26 |
-
*/
|
27 |
-
public function testDirectories($adapter)
|
28 |
-
{
|
29 |
-
$finder = $this->buildFinder($adapter);
|
30 |
-
$this->assertSame($finder, $finder->directories());
|
31 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
32 |
-
|
33 |
-
$finder = $this->buildFinder($adapter);
|
34 |
-
$finder->directories();
|
35 |
-
$finder->files();
|
36 |
-
$finder->directories();
|
37 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @dataProvider getAdaptersTestData
|
42 |
-
*/
|
43 |
-
public function testFiles($adapter)
|
44 |
-
{
|
45 |
-
$finder = $this->buildFinder($adapter);
|
46 |
-
$this->assertSame($finder, $finder->files());
|
47 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
48 |
-
|
49 |
-
$finder = $this->buildFinder($adapter);
|
50 |
-
$finder->files();
|
51 |
-
$finder->directories();
|
52 |
-
$finder->files();
|
53 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @dataProvider getAdaptersTestData
|
58 |
-
*/
|
59 |
-
public function testDepth($adapter)
|
60 |
-
{
|
61 |
-
$finder = $this->buildFinder($adapter);
|
62 |
-
$this->assertSame($finder, $finder->depth('< 1'));
|
63 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
64 |
-
|
65 |
-
$finder = $this->buildFinder($adapter);
|
66 |
-
$this->assertSame($finder, $finder->depth('<= 0'));
|
67 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
68 |
-
|
69 |
-
$finder = $this->buildFinder($adapter);
|
70 |
-
$this->assertSame($finder, $finder->depth('>= 1'));
|
71 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
|
72 |
-
|
73 |
-
$finder = $this->buildFinder($adapter);
|
74 |
-
$finder->depth('< 1')->depth('>= 1');
|
75 |
-
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @dataProvider getAdaptersTestData
|
80 |
-
*/
|
81 |
-
public function testName($adapter)
|
82 |
-
{
|
83 |
-
$finder = $this->buildFinder($adapter);
|
84 |
-
$this->assertSame($finder, $finder->name('*.php'));
|
85 |
-
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
86 |
-
|
87 |
-
$finder = $this->buildFinder($adapter);
|
88 |
-
$finder->name('test.ph*');
|
89 |
-
$finder->name('test.py');
|
90 |
-
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
91 |
-
|
92 |
-
$finder = $this->buildFinder($adapter);
|
93 |
-
$finder->name('~^test~i');
|
94 |
-
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
95 |
-
|
96 |
-
$finder = $this->buildFinder($adapter);
|
97 |
-
$finder->name('~\\.php$~i');
|
98 |
-
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
99 |
-
|
100 |
-
$finder = $this->buildFinder($adapter);
|
101 |
-
$finder->name('test.p{hp,y}');
|
102 |
-
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @dataProvider getAdaptersTestData
|
107 |
-
*/
|
108 |
-
public function testNotName($adapter)
|
109 |
-
{
|
110 |
-
$finder = $this->buildFinder($adapter);
|
111 |
-
$this->assertSame($finder, $finder->notName('*.php'));
|
112 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
113 |
-
|
114 |
-
$finder = $this->buildFinder($adapter);
|
115 |
-
$finder->notName('*.php');
|
116 |
-
$finder->notName('*.py');
|
117 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
118 |
-
|
119 |
-
$finder = $this->buildFinder($adapter);
|
120 |
-
$finder->name('test.ph*');
|
121 |
-
$finder->name('test.py');
|
122 |
-
$finder->notName('*.php');
|
123 |
-
$finder->notName('*.py');
|
124 |
-
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
125 |
-
|
126 |
-
$finder = $this->buildFinder($adapter);
|
127 |
-
$finder->name('test.ph*');
|
128 |
-
$finder->name('test.py');
|
129 |
-
$finder->notName('*.p{hp,y}');
|
130 |
-
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @dataProvider getRegexNameTestData
|
135 |
-
*/
|
136 |
-
public function testRegexName($adapter, $regex)
|
137 |
-
{
|
138 |
-
$finder = $this->buildFinder($adapter);
|
139 |
-
$finder->name($regex);
|
140 |
-
$this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @dataProvider getAdaptersTestData
|
145 |
-
*/
|
146 |
-
public function testSize($adapter)
|
147 |
-
{
|
148 |
-
$finder = $this->buildFinder($adapter);
|
149 |
-
$this->assertSame($finder, $finder->files()->size('< 1K')->size('> 500'));
|
150 |
-
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* @dataProvider getAdaptersTestData
|
155 |
-
*/
|
156 |
-
public function testDate($adapter)
|
157 |
-
{
|
158 |
-
$finder = $this->buildFinder($adapter);
|
159 |
-
$this->assertSame($finder, $finder->files()->date('until last month'));
|
160 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @dataProvider getAdaptersTestData
|
165 |
-
*/
|
166 |
-
public function testExclude($adapter)
|
167 |
-
{
|
168 |
-
$finder = $this->buildFinder($adapter);
|
169 |
-
$this->assertSame($finder, $finder->exclude('foo'));
|
170 |
-
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* @dataProvider getAdaptersTestData
|
175 |
-
*/
|
176 |
-
public function testIgnoreVCS($adapter)
|
177 |
-
{
|
178 |
-
$finder = $this->buildFinder($adapter);
|
179 |
-
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
|
180 |
-
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
181 |
-
|
182 |
-
$finder = $this->buildFinder($adapter);
|
183 |
-
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
|
184 |
-
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
185 |
-
|
186 |
-
$finder = $this->buildFinder($adapter);
|
187 |
-
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
|
188 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* @dataProvider getAdaptersTestData
|
193 |
-
*/
|
194 |
-
public function testIgnoreDotFiles($adapter)
|
195 |
-
{
|
196 |
-
$finder = $this->buildFinder($adapter);
|
197 |
-
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
|
198 |
-
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
199 |
-
|
200 |
-
$finder = $this->buildFinder($adapter);
|
201 |
-
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
|
202 |
-
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
203 |
-
|
204 |
-
$finder = $this->buildFinder($adapter);
|
205 |
-
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
|
206 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* @dataProvider getAdaptersTestData
|
211 |
-
*/
|
212 |
-
public function testSortByName($adapter)
|
213 |
-
{
|
214 |
-
$finder = $this->buildFinder($adapter);
|
215 |
-
$this->assertSame($finder, $finder->sortByName());
|
216 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* @dataProvider getAdaptersTestData
|
221 |
-
*/
|
222 |
-
public function testSortByType($adapter)
|
223 |
-
{
|
224 |
-
$finder = $this->buildFinder($adapter);
|
225 |
-
$this->assertSame($finder, $finder->sortByType());
|
226 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* @dataProvider getAdaptersTestData
|
231 |
-
*/
|
232 |
-
public function testSortByAccessedTime($adapter)
|
233 |
-
{
|
234 |
-
$finder = $this->buildFinder($adapter);
|
235 |
-
$this->assertSame($finder, $finder->sortByAccessedTime());
|
236 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* @dataProvider getAdaptersTestData
|
241 |
-
*/
|
242 |
-
public function testSortByChangedTime($adapter)
|
243 |
-
{
|
244 |
-
$finder = $this->buildFinder($adapter);
|
245 |
-
$this->assertSame($finder, $finder->sortByChangedTime());
|
246 |
-
$this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* @dataProvider getAdaptersTestData
|
251 |
-
*/
|
252 |
-
public function testSortByModifiedTime($adapter)
|
253 |
-
{
|
254 |
-
$finder = $this->buildFinder($adapter);
|
255 |
-
$this->assertSame($finder, $finder->sortByModifiedTime());
|
256 |
-
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* @dataProvider getAdaptersTestData
|
261 |
-
*/
|
262 |
-
public function testSort($adapter)
|
263 |
-
{
|
264 |
-
$finder = $this->buildFinder($adapter);
|
265 |
-
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
|
266 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* @dataProvider getAdaptersTestData
|
271 |
-
*/
|
272 |
-
public function testFilter($adapter)
|
273 |
-
{
|
274 |
-
$finder = $this->buildFinder($adapter);
|
275 |
-
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); }));
|
276 |
-
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* @dataProvider getAdaptersTestData
|
281 |
-
*/
|
282 |
-
public function testFollowLinks($adapter)
|
283 |
-
{
|
284 |
-
if ('\\' == DIRECTORY_SEPARATOR) {
|
285 |
-
return;
|
286 |
-
}
|
287 |
-
|
288 |
-
$finder = $this->buildFinder($adapter);
|
289 |
-
$this->assertSame($finder, $finder->followLinks());
|
290 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* @dataProvider getAdaptersTestData
|
295 |
-
*/
|
296 |
-
public function testIn($adapter)
|
297 |
-
{
|
298 |
-
$finder = $this->buildFinder($adapter);
|
299 |
-
try {
|
300 |
-
$finder->in('foobar');
|
301 |
-
$this->fail('->in() throws a \InvalidArgumentException if the directory does not exist');
|
302 |
-
} catch (\Exception $e) {
|
303 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '->in() throws a \InvalidArgumentException if the directory does not exist');
|
304 |
-
}
|
305 |
-
|
306 |
-
$finder = $this->buildFinder($adapter);
|
307 |
-
$iterator = $finder->files()->name('*.php')->depth('< 1')->in(array(self::$tmpDir, __DIR__))->getIterator();
|
308 |
-
|
309 |
-
$this->assertIterator(array(self::$tmpDir.DIRECTORY_SEPARATOR.'test.php', __DIR__.DIRECTORY_SEPARATOR.'FinderTest.php', __DIR__.DIRECTORY_SEPARATOR.'GlobTest.php'), $iterator);
|
310 |
-
}
|
311 |
-
|
312 |
-
/**
|
313 |
-
* @dataProvider getAdaptersTestData
|
314 |
-
*/
|
315 |
-
public function testInWithGlob($adapter)
|
316 |
-
{
|
317 |
-
$finder = $this->buildFinder($adapter);
|
318 |
-
$finder->in(array(__DIR__.'/Fixtures/*/B/C', __DIR__.'/Fixtures/*/*/B/C'))->getIterator();
|
319 |
-
|
320 |
-
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
|
321 |
-
}
|
322 |
-
|
323 |
-
/**
|
324 |
-
* @dataProvider getAdaptersTestData
|
325 |
-
* @expectedException \InvalidArgumentException
|
326 |
-
*/
|
327 |
-
public function testInWithNonDirectoryGlob($adapter)
|
328 |
-
{
|
329 |
-
$finder = $this->buildFinder($adapter);
|
330 |
-
$finder->in(__DIR__.'/Fixtures/A/a*');
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* @dataProvider getAdaptersTestData
|
335 |
-
*/
|
336 |
-
public function testInWithGlobBrace($adapter)
|
337 |
-
{
|
338 |
-
$finder = $this->buildFinder($adapter);
|
339 |
-
$finder->in(array(__DIR__.'/Fixtures/{A,copy/A}/B/C'))->getIterator();
|
340 |
-
|
341 |
-
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* @dataProvider getAdaptersTestData
|
346 |
-
*/
|
347 |
-
public function testGetIterator($adapter)
|
348 |
-
{
|
349 |
-
$finder = $this->buildFinder($adapter);
|
350 |
-
try {
|
351 |
-
$finder->getIterator();
|
352 |
-
$this->fail('->getIterator() throws a \LogicException if the in() method has not been called');
|
353 |
-
} catch (\Exception $e) {
|
354 |
-
$this->assertInstanceOf('LogicException', $e, '->getIterator() throws a \LogicException if the in() method has not been called');
|
355 |
-
}
|
356 |
-
|
357 |
-
$finder = $this->buildFinder($adapter);
|
358 |
-
$dirs = array();
|
359 |
-
foreach ($finder->directories()->in(self::$tmpDir) as $dir) {
|
360 |
-
$dirs[] = (string) $dir;
|
361 |
-
}
|
362 |
-
|
363 |
-
$expected = $this->toAbsolute(array('foo', 'toto'));
|
364 |
-
|
365 |
-
sort($dirs);
|
366 |
-
sort($expected);
|
367 |
-
|
368 |
-
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
|
369 |
-
|
370 |
-
$finder = $this->buildFinder($adapter);
|
371 |
-
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
372 |
-
|
373 |
-
$finder = $this->buildFinder($adapter);
|
374 |
-
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
375 |
-
$a = array_values(array_map(function ($a) { return (string) $a; }, $a));
|
376 |
-
sort($a);
|
377 |
-
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* @dataProvider getAdaptersTestData
|
382 |
-
*/
|
383 |
-
public function testRelativePath($adapter)
|
384 |
-
{
|
385 |
-
$finder = $this->buildFinder($adapter)->in(self::$tmpDir);
|
386 |
-
|
387 |
-
$paths = array();
|
388 |
-
|
389 |
-
foreach ($finder as $file) {
|
390 |
-
$paths[] = $file->getRelativePath();
|
391 |
-
}
|
392 |
-
|
393 |
-
$ref = array('', '', '', '', 'foo', '');
|
394 |
-
|
395 |
-
sort($ref);
|
396 |
-
sort($paths);
|
397 |
-
|
398 |
-
$this->assertEquals($ref, $paths);
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* @dataProvider getAdaptersTestData
|
403 |
-
*/
|
404 |
-
public function testRelativePathname($adapter)
|
405 |
-
{
|
406 |
-
$finder = $this->buildFinder($adapter)->in(self::$tmpDir)->sortByName();
|
407 |
-
|
408 |
-
$paths = array();
|
409 |
-
|
410 |
-
foreach ($finder as $file) {
|
411 |
-
$paths[] = $file->getRelativePathname();
|
412 |
-
}
|
413 |
-
|
414 |
-
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
|
415 |
-
|
416 |
-
sort($paths);
|
417 |
-
sort($ref);
|
418 |
-
|
419 |
-
$this->assertEquals($ref, $paths);
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* @dataProvider getAdaptersTestData
|
424 |
-
*/
|
425 |
-
public function testAppendWithAFinder($adapter)
|
426 |
-
{
|
427 |
-
$finder = $this->buildFinder($adapter);
|
428 |
-
$finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
429 |
-
|
430 |
-
$finder1 = $this->buildFinder($adapter);
|
431 |
-
$finder1->directories()->in(self::$tmpDir);
|
432 |
-
|
433 |
-
$finder = $finder->append($finder1);
|
434 |
-
|
435 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
436 |
-
}
|
437 |
-
|
438 |
-
/**
|
439 |
-
* @dataProvider getAdaptersTestData
|
440 |
-
*/
|
441 |
-
public function testAppendWithAnArray($adapter)
|
442 |
-
{
|
443 |
-
$finder = $this->buildFinder($adapter);
|
444 |
-
$finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
445 |
-
|
446 |
-
$finder->append($this->toAbsolute(array('foo', 'toto')));
|
447 |
-
|
448 |
-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
449 |
-
}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* @dataProvider getAdaptersTestData
|
453 |
-
*/
|
454 |
-
public function testAppendReturnsAFinder($adapter)
|
455 |
-
{
|
456 |
-
$this->assertInstanceOf('Symfony\\Component\\Finder\\Finder', $this->buildFinder($adapter)->append(array()));
|
457 |
-
}
|
458 |
-
|
459 |
-
/**
|
460 |
-
* @dataProvider getAdaptersTestData
|
461 |
-
*/
|
462 |
-
public function testAppendDoesNotRequireIn($adapter)
|
463 |
-
{
|
464 |
-
$finder = $this->buildFinder($adapter);
|
465 |
-
$finder->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
466 |
-
|
467 |
-
$finder1 = Finder::create()->append($finder);
|
468 |
-
|
469 |
-
$this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator());
|
470 |
-
}
|
471 |
-
|
472 |
-
public function testCountDirectories()
|
473 |
-
{
|
474 |
-
$directory = Finder::create()->directories()->in(self::$tmpDir);
|
475 |
-
$i = 0;
|
476 |
-
|
477 |
-
foreach ($directory as $dir) {
|
478 |
-
++$i;
|
479 |
-
}
|
480 |
-
|
481 |
-
$this->assertCount($i, $directory);
|
482 |
-
}
|
483 |
-
|
484 |
-
public function testCountFiles()
|
485 |
-
{
|
486 |
-
$files = Finder::create()->files()->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
487 |
-
$i = 0;
|
488 |
-
|
489 |
-
foreach ($files as $file) {
|
490 |
-
++$i;
|
491 |
-
}
|
492 |
-
|
493 |
-
$this->assertCount($i, $files);
|
494 |
-
}
|
495 |
-
|
496 |
-
/**
|
497 |
-
* @expectedException \LogicException
|
498 |
-
*/
|
499 |
-
public function testCountWithoutIn()
|
500 |
-
{
|
501 |
-
$finder = Finder::create()->files();
|
502 |
-
count($finder);
|
503 |
-
}
|
504 |
-
|
505 |
-
/**
|
506 |
-
* @dataProvider getContainsTestData
|
507 |
-
*/
|
508 |
-
public function testContains($adapter, $matchPatterns, $noMatchPatterns, $expected)
|
509 |
-
{
|
510 |
-
$finder = $this->buildFinder($adapter);
|
511 |
-
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
|
512 |
-
->name('*.txt')->sortByName()
|
513 |
-
->contains($matchPatterns)
|
514 |
-
->notContains($noMatchPatterns);
|
515 |
-
|
516 |
-
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* @dataProvider getAdaptersTestData
|
521 |
-
*/
|
522 |
-
public function testContainsOnDirectory(Adapter\AdapterInterface $adapter)
|
523 |
-
{
|
524 |
-
$finder = $this->buildFinder($adapter);
|
525 |
-
$finder->in(__DIR__)
|
526 |
-
->directories()
|
527 |
-
->name('Fixtures')
|
528 |
-
->contains('abc');
|
529 |
-
$this->assertIterator(array(), $finder);
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* @dataProvider getAdaptersTestData
|
534 |
-
*/
|
535 |
-
public function testNotContainsOnDirectory(Adapter\AdapterInterface $adapter)
|
536 |
-
{
|
537 |
-
$finder = $this->buildFinder($adapter);
|
538 |
-
$finder->in(__DIR__)
|
539 |
-
->directories()
|
540 |
-
->name('Fixtures')
|
541 |
-
->notContains('abc');
|
542 |
-
$this->assertIterator(array(), $finder);
|
543 |
-
}
|
544 |
-
|
545 |
-
/**
|
546 |
-
* Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator
|
547 |
-
* with inner FilesystemIterator in an invalid state.
|
548 |
-
*
|
549 |
-
* @see https://bugs.php.net/bug.php?id=49104
|
550 |
-
*
|
551 |
-
* @dataProvider getAdaptersTestData
|
552 |
-
*/
|
553 |
-
public function testMultipleLocations(Adapter\AdapterInterface $adapter)
|
554 |
-
{
|
555 |
-
$locations = array(
|
556 |
-
self::$tmpDir.'/',
|
557 |
-
self::$tmpDir.'/toto/',
|
558 |
-
);
|
559 |
-
|
560 |
-
// it is expected that there are test.py test.php in the tmpDir
|
561 |
-
$finder = $this->buildFinder($adapter);
|
562 |
-
$finder->in($locations)->depth('< 1')->name('test.php');
|
563 |
-
|
564 |
-
$this->assertCount(1, $finder);
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* Iterator keys must be the file pathname.
|
569 |
-
*
|
570 |
-
* @dataProvider getAdaptersTestData
|
571 |
-
*/
|
572 |
-
public function testIteratorKeys(Adapter\AdapterInterface $adapter)
|
573 |
-
{
|
574 |
-
$finder = $this->buildFinder($adapter)->in(self::$tmpDir);
|
575 |
-
foreach ($finder as $key => $file) {
|
576 |
-
$this->assertEquals($file->getPathname(), $key);
|
577 |
-
}
|
578 |
-
}
|
579 |
-
|
580 |
-
/**
|
581 |
-
* @dataProvider getAdaptersTestData
|
582 |
-
*/
|
583 |
-
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter)
|
584 |
-
{
|
585 |
-
$finder = $this->buildFinder($adapter);
|
586 |
-
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
|
587 |
-
->path('/^dir/');
|
588 |
-
|
589 |
-
$expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
|
590 |
-
'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
|
591 |
-
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
592 |
-
}
|
593 |
-
|
594 |
-
public function testAdaptersOrdering()
|
595 |
-
{
|
596 |
-
$finder = Finder::create()
|
597 |
-
->removeAdapters()
|
598 |
-
->addAdapter(new FakeAdapter\NamedAdapter('a'), 0)
|
599 |
-
->addAdapter(new FakeAdapter\NamedAdapter('b'), -50)
|
600 |
-
->addAdapter(new FakeAdapter\NamedAdapter('c'), 50)
|
601 |
-
->addAdapter(new FakeAdapter\NamedAdapter('d'), -25)
|
602 |
-
->addAdapter(new FakeAdapter\NamedAdapter('e'), 25);
|
603 |
-
|
604 |
-
$this->assertEquals(
|
605 |
-
array('c', 'e', 'a', 'd', 'b'),
|
606 |
-
array_map(function (Adapter\AdapterInterface $adapter) {
|
607 |
-
return $adapter->getName();
|
608 |
-
}, $finder->getAdapters())
|
609 |
-
);
|
610 |
-
}
|
611 |
-
|
612 |
-
public function testAdaptersChaining()
|
613 |
-
{
|
614 |
-
$iterator = new \ArrayIterator(array());
|
615 |
-
$filenames = $this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto'));
|
616 |
-
foreach ($filenames as $file) {
|
617 |
-
$iterator->append(new \Symfony\Component\Finder\SplFileInfo($file, null, null));
|
618 |
-
}
|
619 |
-
|
620 |
-
$finder = Finder::create()
|
621 |
-
->removeAdapters()
|
622 |
-
->addAdapter(new FakeAdapter\UnsupportedAdapter(), 3)
|
623 |
-
->addAdapter(new FakeAdapter\FailingAdapter(), 2)
|
624 |
-
->addAdapter(new FakeAdapter\DummyAdapter($iterator), 1);
|
625 |
-
|
626 |
-
$this->assertIterator($filenames, $finder->in(sys_get_temp_dir())->getIterator());
|
627 |
-
}
|
628 |
-
|
629 |
-
public function getAdaptersTestData()
|
630 |
-
{
|
631 |
-
return array_map(
|
632 |
-
function ($adapter) { return array($adapter); },
|
633 |
-
$this->getValidAdapters()
|
634 |
-
);
|
635 |
-
}
|
636 |
-
|
637 |
-
public function getContainsTestData()
|
638 |
-
{
|
639 |
-
$tests = array(
|
640 |
-
array('', '', array()),
|
641 |
-
array('foo', 'bar', array()),
|
642 |
-
array('', 'foobar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
|
643 |
-
array('lorem ipsum dolor sit amet', 'foobar', array('lorem.txt')),
|
644 |
-
array('sit', 'bar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
|
645 |
-
array('dolor sit amet', '@^L@m', array('dolor.txt', 'ipsum.txt')),
|
646 |
-
array('/^lorem ipsum dolor sit amet$/m', 'foobar', array('lorem.txt')),
|
647 |
-
array('lorem', 'foobar', array('lorem.txt')),
|
648 |
-
array('', 'lorem', array('dolor.txt', 'ipsum.txt')),
|
649 |
-
array('ipsum dolor sit amet', '/^IPSUM/m', array('lorem.txt')),
|
650 |
-
);
|
651 |
-
|
652 |
-
return $this->buildTestData($tests);
|
653 |
-
}
|
654 |
-
|
655 |
-
public function getRegexNameTestData()
|
656 |
-
{
|
657 |
-
$tests = array(
|
658 |
-
array('~.+\\.p.+~i'),
|
659 |
-
array('~t.*s~i'),
|
660 |
-
);
|
661 |
-
|
662 |
-
return $this->buildTestData($tests);
|
663 |
-
}
|
664 |
-
|
665 |
-
/**
|
666 |
-
* @dataProvider getTestPathData
|
667 |
-
*/
|
668 |
-
public function testPath(Adapter\AdapterInterface $adapter, $matchPatterns, $noMatchPatterns, array $expected)
|
669 |
-
{
|
670 |
-
$finder = $this->buildFinder($adapter);
|
671 |
-
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
|
672 |
-
->path($matchPatterns)
|
673 |
-
->notPath($noMatchPatterns);
|
674 |
-
|
675 |
-
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
676 |
-
}
|
677 |
-
|
678 |
-
public function testAdapterSelection()
|
679 |
-
{
|
680 |
-
// test that by default, PhpAdapter is selected
|
681 |
-
$adapters = Finder::create()->getAdapters();
|
682 |
-
$this->assertTrue($adapters[0] instanceof Adapter\PhpAdapter);
|
683 |
-
|
684 |
-
// test another adapter selection
|
685 |
-
$adapters = Finder::create()->setAdapter('gnu_find')->getAdapters();
|
686 |
-
$this->assertTrue($adapters[0] instanceof Adapter\GnuFindAdapter);
|
687 |
-
|
688 |
-
// test that useBestAdapter method removes selection
|
689 |
-
$adapters = Finder::create()->useBestAdapter()->getAdapters();
|
690 |
-
$this->assertFalse($adapters[0] instanceof Adapter\PhpAdapter);
|
691 |
-
}
|
692 |
-
|
693 |
-
public function getTestPathData()
|
694 |
-
{
|
695 |
-
$tests = array(
|
696 |
-
array('', '', array()),
|
697 |
-
array('/^A\/B\/C/', '/C$/',
|
698 |
-
array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'),
|
699 |
-
),
|
700 |
-
array('/^A\/B/', 'foobar',
|
701 |
-
array(
|
702 |
-
'A'.DIRECTORY_SEPARATOR.'B',
|
703 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
704 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
705 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
706 |
-
),
|
707 |
-
),
|
708 |
-
array('A/B/C', 'foobar',
|
709 |
-
array(
|
710 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
711 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
712 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
713 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
|
714 |
-
),
|
715 |
-
),
|
716 |
-
array('A/B', 'foobar',
|
717 |
-
array(
|
718 |
-
//dirs
|
719 |
-
'A'.DIRECTORY_SEPARATOR.'B',
|
720 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
721 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B',
|
722 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
723 |
-
//files
|
724 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
725 |
-
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
726 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy',
|
727 |
-
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
|
728 |
-
),
|
729 |
-
),
|
730 |
-
array('/^with space\//', 'foobar',
|
731 |
-
array(
|
732 |
-
'with space'.DIRECTORY_SEPARATOR.'foo.txt',
|
733 |
-
),
|
734 |
-
),
|
735 |
-
);
|
736 |
-
|
737 |
-
return $this->buildTestData($tests);
|
738 |
-
}
|
739 |
-
|
740 |
-
/**
|
741 |
-
* @dataProvider getAdaptersTestData
|
742 |
-
*/
|
743 |
-
public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
|
744 |
-
{
|
745 |
-
if ('\\' === DIRECTORY_SEPARATOR) {
|
746 |
-
$this->markTestSkipped('chmod is not supported on Windows');
|
747 |
-
}
|
748 |
-
|
749 |
-
$finder = $this->buildFinder($adapter);
|
750 |
-
$finder->files()->in(self::$tmpDir);
|
751 |
-
|
752 |
-
// make 'foo' directory non-readable
|
753 |
-
$testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
|
754 |
-
chmod($testDir, 0333);
|
755 |
-
|
756 |
-
if (false === $couldRead = is_readable($testDir)) {
|
757 |
-
try {
|
758 |
-
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
759 |
-
$this->fail('Finder should throw an exception when opening a non-readable directory.');
|
760 |
-
} catch (\Exception $e) {
|
761 |
-
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
|
762 |
-
if ($e instanceof \PHPUnit_Framework_ExpectationFailedException) {
|
763 |
-
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
764 |
-
}
|
765 |
-
|
766 |
-
$this->assertInstanceOf($expectedExceptionClass, $e);
|
767 |
-
}
|
768 |
-
}
|
769 |
-
|
770 |
-
// restore original permissions
|
771 |
-
chmod($testDir, 0777);
|
772 |
-
clearstatcache($testDir);
|
773 |
-
|
774 |
-
if ($couldRead) {
|
775 |
-
$this->markTestSkipped('could read test files while test requires unreadable');
|
776 |
-
}
|
777 |
-
}
|
778 |
-
|
779 |
-
/**
|
780 |
-
* @dataProvider getAdaptersTestData
|
781 |
-
*/
|
782 |
-
public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapter)
|
783 |
-
{
|
784 |
-
if ('\\' === DIRECTORY_SEPARATOR) {
|
785 |
-
$this->markTestSkipped('chmod is not supported on Windows');
|
786 |
-
}
|
787 |
-
|
788 |
-
$finder = $this->buildFinder($adapter);
|
789 |
-
$finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir);
|
790 |
-
|
791 |
-
// make 'foo' directory non-readable
|
792 |
-
$testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
|
793 |
-
chmod($testDir, 0333);
|
794 |
-
|
795 |
-
if (false === ($couldRead = is_readable($testDir))) {
|
796 |
-
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
797 |
-
}
|
798 |
-
|
799 |
-
// restore original permissions
|
800 |
-
chmod($testDir, 0777);
|
801 |
-
clearstatcache($testDir);
|
802 |
-
|
803 |
-
if ($couldRead) {
|
804 |
-
$this->markTestSkipped('could read test files while test requires unreadable');
|
805 |
-
}
|
806 |
-
}
|
807 |
-
|
808 |
-
private function buildTestData(array $tests)
|
809 |
-
{
|
810 |
-
$data = array();
|
811 |
-
foreach ($this->getValidAdapters() as $adapter) {
|
812 |
-
foreach ($tests as $test) {
|
813 |
-
$data[] = array_merge(array($adapter), $test);
|
814 |
-
}
|
815 |
-
}
|
816 |
-
|
817 |
-
return $data;
|
818 |
-
}
|
819 |
-
|
820 |
-
private function buildFinder(Adapter\AdapterInterface $adapter)
|
821 |
-
{
|
822 |
-
return Finder::create()
|
823 |
-
->removeAdapters()
|
824 |
-
->addAdapter($adapter);
|
825 |
-
}
|
826 |
-
|
827 |
-
private function getValidAdapters()
|
828 |
-
{
|
829 |
-
return array_filter(
|
830 |
-
array(
|
831 |
-
new Adapter\BsdFindAdapter(),
|
832 |
-
new Adapter\GnuFindAdapter(),
|
833 |
-
new Adapter\PhpAdapter(),
|
834 |
-
),
|
835 |
-
function (Adapter\AdapterInterface $adapter) {
|
836 |
-
return $adapter->isSupported();
|
837 |
-
}
|
838 |
-
);
|
839 |
-
}
|
840 |
-
|
841 |
-
/**
|
842 |
-
* Searching in multiple locations with sub directories involves
|
843 |
-
* AppendIterator which does an unnecessary rewind which leaves
|
844 |
-
* FilterIterator with inner FilesystemIterator in an invalid state.
|
845 |
-
*
|
846 |
-
* @see https://bugs.php.net/bug.php?id=49104
|
847 |
-
*/
|
848 |
-
public function testMultipleLocationsWithSubDirectories()
|
849 |
-
{
|
850 |
-
$locations = array(
|
851 |
-
__DIR__.'/Fixtures/one',
|
852 |
-
self::$tmpDir.DIRECTORY_SEPARATOR.'toto',
|
853 |
-
);
|
854 |
-
|
855 |
-
$finder = new Finder();
|
856 |
-
$finder->in($locations)->depth('< 10')->name('*.neon');
|
857 |
-
|
858 |
-
$expected = array(
|
859 |
-
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
|
860 |
-
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
|
861 |
-
);
|
862 |
-
|
863 |
-
$this->assertIterator($expected, $finder);
|
864 |
-
$this->assertIteratorInForeach($expected, $finder);
|
865 |
-
}
|
866 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Fixtures/A/B/C/abc.dat
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/A/B/ab.dat
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/A/a.dat
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/copy/A/B/C/abc.dat.copy
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/copy/A/B/ab.dat.copy
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/copy/A/a.dat.copy
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/dolor.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
dolor sit amet
|
2 |
-
DOLOR SIT AMET
|
|
|
|
vendor/symfony/finder/Tests/Fixtures/ipsum.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
ipsum dolor sit amet
|
2 |
-
IPSUM DOLOR SIT AMET
|
|
|
|
vendor/symfony/finder/Tests/Fixtures/lorem.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
lorem ipsum dolor sit amet
|
2 |
-
LOREM IPSUM DOLOR SIT AMET
|
|
|
|
vendor/symfony/finder/Tests/Fixtures/one/a
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/one/b/c.neon
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/one/b/d.neon
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat
DELETED
File without changes
|
vendor/symfony/finder/Tests/Fixtures/with space/foo.txt
DELETED
File without changes
|
vendor/symfony/finder/Tests/GlobTest.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Glob;
|
15 |
-
|
16 |
-
class GlobTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function testGlobToRegexDelimiters()
|
19 |
-
{
|
20 |
-
$this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*'));
|
21 |
-
$this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, ''));
|
22 |
-
$this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/'));
|
23 |
-
}
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/CustomFilterIteratorTest.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
15 |
-
|
16 |
-
class CustomFilterIteratorTest extends IteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @expectedException \InvalidArgumentException
|
20 |
-
*/
|
21 |
-
public function testWithInvalidFilter()
|
22 |
-
{
|
23 |
-
new CustomFilterIterator(new Iterator(), array('foo'));
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @dataProvider getAcceptData
|
28 |
-
*/
|
29 |
-
public function testAccept($filters, $expected)
|
30 |
-
{
|
31 |
-
$inner = new Iterator(array('test.php', 'test.py', 'foo.php'));
|
32 |
-
|
33 |
-
$iterator = new CustomFilterIterator($inner, $filters);
|
34 |
-
|
35 |
-
$this->assertIterator($expected, $iterator);
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getAcceptData()
|
39 |
-
{
|
40 |
-
return array(
|
41 |
-
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
|
42 |
-
array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')),
|
43 |
-
array(array('is_dir'), array()),
|
44 |
-
);
|
45 |
-
}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/DateRangeFilterIteratorTest.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
15 |
-
use Symfony\Component\Finder\Comparator\DateComparator;
|
16 |
-
|
17 |
-
class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @dataProvider getAcceptData
|
21 |
-
*/
|
22 |
-
public function testAccept($size, $expected)
|
23 |
-
{
|
24 |
-
$files = self::$files;
|
25 |
-
$files[] = self::toAbsolute('doesnotexist');
|
26 |
-
$inner = new Iterator($files);
|
27 |
-
|
28 |
-
$iterator = new DateRangeFilterIterator($inner, $size);
|
29 |
-
|
30 |
-
$this->assertIterator($expected, $iterator);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getAcceptData()
|
34 |
-
{
|
35 |
-
$since20YearsAgo = array(
|
36 |
-
'.git',
|
37 |
-
'test.py',
|
38 |
-
'foo',
|
39 |
-
'foo/bar.tmp',
|
40 |
-
'test.php',
|
41 |
-
'toto',
|
42 |
-
'.bar',
|
43 |
-
'.foo',
|
44 |
-
'.foo/.bar',
|
45 |
-
'foo bar',
|
46 |
-
'.foo/bar',
|
47 |
-
);
|
48 |
-
|
49 |
-
$since2MonthsAgo = array(
|
50 |
-
'.git',
|
51 |
-
'test.py',
|
52 |
-
'foo',
|
53 |
-
'toto',
|
54 |
-
'.bar',
|
55 |
-
'.foo',
|
56 |
-
'.foo/.bar',
|
57 |
-
'foo bar',
|
58 |
-
'.foo/bar',
|
59 |
-
);
|
60 |
-
|
61 |
-
$untilLastMonth = array(
|
62 |
-
'foo/bar.tmp',
|
63 |
-
'test.php',
|
64 |
-
);
|
65 |
-
|
66 |
-
return array(
|
67 |
-
array(array(new DateComparator('since 20 years ago')), $this->toAbsolute($since20YearsAgo)),
|
68 |
-
array(array(new DateComparator('since 2 months ago')), $this->toAbsolute($since2MonthsAgo)),
|
69 |
-
array(array(new DateComparator('until last month')), $this->toAbsolute($untilLastMonth)),
|
70 |
-
);
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
15 |
-
|
16 |
-
class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getAcceptData
|
20 |
-
*/
|
21 |
-
public function testAccept($minDepth, $maxDepth, $expected)
|
22 |
-
{
|
23 |
-
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
24 |
-
|
25 |
-
$iterator = new DepthRangeFilterIterator($inner, $minDepth, $maxDepth);
|
26 |
-
|
27 |
-
$actual = array_keys(iterator_to_array($iterator));
|
28 |
-
sort($expected);
|
29 |
-
sort($actual);
|
30 |
-
$this->assertEquals($expected, $actual);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getAcceptData()
|
34 |
-
{
|
35 |
-
$lessThan1 = array(
|
36 |
-
'.git',
|
37 |
-
'test.py',
|
38 |
-
'foo',
|
39 |
-
'test.php',
|
40 |
-
'toto',
|
41 |
-
'.foo',
|
42 |
-
'.bar',
|
43 |
-
'foo bar',
|
44 |
-
);
|
45 |
-
|
46 |
-
$lessThanOrEqualTo1 = array(
|
47 |
-
'.git',
|
48 |
-
'test.py',
|
49 |
-
'foo',
|
50 |
-
'foo/bar.tmp',
|
51 |
-
'test.php',
|
52 |
-
'toto',
|
53 |
-
'.foo',
|
54 |
-
'.foo/.bar',
|
55 |
-
'.bar',
|
56 |
-
'foo bar',
|
57 |
-
'.foo/bar',
|
58 |
-
);
|
59 |
-
|
60 |
-
$graterThanOrEqualTo1 = array(
|
61 |
-
'foo/bar.tmp',
|
62 |
-
'.foo/.bar',
|
63 |
-
'.foo/bar',
|
64 |
-
);
|
65 |
-
|
66 |
-
$equalTo1 = array(
|
67 |
-
'foo/bar.tmp',
|
68 |
-
'.foo/.bar',
|
69 |
-
'.foo/bar',
|
70 |
-
);
|
71 |
-
|
72 |
-
return array(
|
73 |
-
array(0, 0, $this->toAbsolute($lessThan1)),
|
74 |
-
array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
|
75 |
-
array(2, PHP_INT_MAX, array()),
|
76 |
-
array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
|
77 |
-
array(1, 1, $this->toAbsolute($equalTo1)),
|
78 |
-
);
|
79 |
-
}
|
80 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
|
15 |
-
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
16 |
-
|
17 |
-
class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @dataProvider getAcceptData
|
21 |
-
*/
|
22 |
-
public function testAccept($directories, $expected)
|
23 |
-
{
|
24 |
-
$inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
25 |
-
|
26 |
-
$iterator = new ExcludeDirectoryFilterIterator($inner, $directories);
|
27 |
-
|
28 |
-
$this->assertIterator($expected, $iterator);
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getAcceptData()
|
32 |
-
{
|
33 |
-
$foo = array(
|
34 |
-
'.bar',
|
35 |
-
'.foo',
|
36 |
-
'.foo/.bar',
|
37 |
-
'.foo/bar',
|
38 |
-
'.git',
|
39 |
-
'test.py',
|
40 |
-
'test.php',
|
41 |
-
'toto',
|
42 |
-
'foo bar',
|
43 |
-
);
|
44 |
-
|
45 |
-
$fo = array(
|
46 |
-
'.bar',
|
47 |
-
'.foo',
|
48 |
-
'.foo/.bar',
|
49 |
-
'.foo/bar',
|
50 |
-
'.git',
|
51 |
-
'test.py',
|
52 |
-
'foo',
|
53 |
-
'foo/bar.tmp',
|
54 |
-
'test.php',
|
55 |
-
'toto',
|
56 |
-
'foo bar',
|
57 |
-
);
|
58 |
-
|
59 |
-
return array(
|
60 |
-
array(array('foo'), $this->toAbsolute($foo)),
|
61 |
-
array(array('fo'), $this->toAbsolute($fo)),
|
62 |
-
);
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/FilePathsIteratorTest.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\FilePathsIterator;
|
15 |
-
|
16 |
-
class FilePathsIteratorTest extends RealIteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getSubPathData
|
20 |
-
*/
|
21 |
-
public function testSubPath($baseDir, array $paths, array $subPaths, array $subPathnames)
|
22 |
-
{
|
23 |
-
$iterator = new FilePathsIterator($paths, $baseDir);
|
24 |
-
|
25 |
-
foreach ($iterator as $index => $file) {
|
26 |
-
$this->assertEquals($paths[$index], $file->getPathname());
|
27 |
-
$this->assertEquals($subPaths[$index], $iterator->getSubPath());
|
28 |
-
$this->assertEquals($subPathnames[$index], $iterator->getSubPathname());
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getSubPathData()
|
33 |
-
{
|
34 |
-
$tmpDir = sys_get_temp_dir().'/symfony_finder';
|
35 |
-
|
36 |
-
return array(
|
37 |
-
array(
|
38 |
-
$tmpDir,
|
39 |
-
array(
|
40 |
-
// paths
|
41 |
-
$tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git',
|
42 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py',
|
43 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo',
|
44 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
|
45 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
|
46 |
-
$tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
|
47 |
-
),
|
48 |
-
array(
|
49 |
-
// subPaths
|
50 |
-
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
|
51 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
|
52 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
|
53 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo',
|
54 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
|
55 |
-
$tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
|
56 |
-
),
|
57 |
-
array(
|
58 |
-
// subPathnames
|
59 |
-
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
|
60 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
|
61 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',
|
62 |
-
$tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
|
63 |
-
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => 'test.php',
|
64 |
-
$tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto',
|
65 |
-
),
|
66 |
-
),
|
67 |
-
);
|
68 |
-
}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\FileTypeFilterIterator;
|
15 |
-
|
16 |
-
class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getAcceptData
|
20 |
-
*/
|
21 |
-
public function testAccept($mode, $expected)
|
22 |
-
{
|
23 |
-
$inner = new InnerTypeIterator(self::$files);
|
24 |
-
|
25 |
-
$iterator = new FileTypeFilterIterator($inner, $mode);
|
26 |
-
|
27 |
-
$this->assertIterator($expected, $iterator);
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getAcceptData()
|
31 |
-
{
|
32 |
-
$onlyFiles = array(
|
33 |
-
'test.py',
|
34 |
-
'foo/bar.tmp',
|
35 |
-
'test.php',
|
36 |
-
'.bar',
|
37 |
-
'.foo/.bar',
|
38 |
-
'.foo/bar',
|
39 |
-
'foo bar',
|
40 |
-
);
|
41 |
-
|
42 |
-
$onlyDirectories = array(
|
43 |
-
'.git',
|
44 |
-
'foo',
|
45 |
-
'toto',
|
46 |
-
'.foo',
|
47 |
-
);
|
48 |
-
|
49 |
-
return array(
|
50 |
-
array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
|
51 |
-
array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
|
52 |
-
);
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
class InnerTypeIterator extends \ArrayIterator
|
57 |
-
{
|
58 |
-
public function current()
|
59 |
-
{
|
60 |
-
return new \SplFileInfo(parent::current());
|
61 |
-
}
|
62 |
-
|
63 |
-
public function isFile()
|
64 |
-
{
|
65 |
-
return $this->current()->isFile();
|
66 |
-
}
|
67 |
-
|
68 |
-
public function isDir()
|
69 |
-
{
|
70 |
-
return $this->current()->isDir();
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/FilecontentFilterIteratorTest.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
|
15 |
-
|
16 |
-
class FilecontentFilterIteratorTest extends IteratorTestCase
|
17 |
-
{
|
18 |
-
public function testAccept()
|
19 |
-
{
|
20 |
-
$inner = new MockFileListIterator(array('test.txt'));
|
21 |
-
$iterator = new FilecontentFilterIterator($inner, array(), array());
|
22 |
-
$this->assertIterator(array('test.txt'), $iterator);
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testDirectory()
|
26 |
-
{
|
27 |
-
$inner = new MockFileListIterator(array('directory'));
|
28 |
-
$iterator = new FilecontentFilterIterator($inner, array('directory'), array());
|
29 |
-
$this->assertIterator(array(), $iterator);
|
30 |
-
}
|
31 |
-
|
32 |
-
public function testUnreadableFile()
|
33 |
-
{
|
34 |
-
$inner = new MockFileListIterator(array('file r-'));
|
35 |
-
$iterator = new FilecontentFilterIterator($inner, array('file r-'), array());
|
36 |
-
$this->assertIterator(array(), $iterator);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @dataProvider getTestFilterData
|
41 |
-
*/
|
42 |
-
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
43 |
-
{
|
44 |
-
$iterator = new FilecontentFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
45 |
-
$this->assertIterator($resultArray, $iterator);
|
46 |
-
}
|
47 |
-
|
48 |
-
public function getTestFilterData()
|
49 |
-
{
|
50 |
-
$inner = new MockFileListIterator();
|
51 |
-
|
52 |
-
$inner[] = new MockSplFileInfo(array(
|
53 |
-
'name' => 'a.txt',
|
54 |
-
'contents' => 'Lorem ipsum...',
|
55 |
-
'type' => 'file',
|
56 |
-
'mode' => 'r+', )
|
57 |
-
);
|
58 |
-
|
59 |
-
$inner[] = new MockSplFileInfo(array(
|
60 |
-
'name' => 'b.yml',
|
61 |
-
'contents' => 'dolor sit...',
|
62 |
-
'type' => 'file',
|
63 |
-
'mode' => 'r+', )
|
64 |
-
);
|
65 |
-
|
66 |
-
$inner[] = new MockSplFileInfo(array(
|
67 |
-
'name' => 'some/other/dir/third.php',
|
68 |
-
'contents' => 'amet...',
|
69 |
-
'type' => 'file',
|
70 |
-
'mode' => 'r+', )
|
71 |
-
);
|
72 |
-
|
73 |
-
$inner[] = new MockSplFileInfo(array(
|
74 |
-
'name' => 'unreadable-file.txt',
|
75 |
-
'contents' => false,
|
76 |
-
'type' => 'file',
|
77 |
-
'mode' => 'r+', )
|
78 |
-
);
|
79 |
-
|
80 |
-
return array(
|
81 |
-
array($inner, array('.'), array(), array('a.txt', 'b.yml', 'some/other/dir/third.php')),
|
82 |
-
array($inner, array('ipsum'), array(), array('a.txt')),
|
83 |
-
array($inner, array('i', 'amet'), array('Lorem', 'amet'), array('b.yml')),
|
84 |
-
);
|
85 |
-
}
|
86 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/FilenameFilterIteratorTest.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
|
15 |
-
|
16 |
-
class FilenameFilterIteratorTest extends IteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getAcceptData
|
20 |
-
*/
|
21 |
-
public function testAccept($matchPatterns, $noMatchPatterns, $expected)
|
22 |
-
{
|
23 |
-
$inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php'));
|
24 |
-
|
25 |
-
$iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
26 |
-
|
27 |
-
$this->assertIterator($expected, $iterator);
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getAcceptData()
|
31 |
-
{
|
32 |
-
return array(
|
33 |
-
array(array('test.*'), array(), array('test.php', 'test.py')),
|
34 |
-
array(array(), array('test.*'), array('foo.php')),
|
35 |
-
array(array('*.php'), array('test.*'), array('foo.php')),
|
36 |
-
array(array('*.php', '*.py'), array('foo.*'), array('test.php', 'test.py')),
|
37 |
-
array(array('/\.php$/'), array(), array('test.php', 'foo.php')),
|
38 |
-
array(array(), array('/\.php$/'), array('test.py')),
|
39 |
-
);
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
class InnerNameIterator extends \ArrayIterator
|
44 |
-
{
|
45 |
-
public function current()
|
46 |
-
{
|
47 |
-
return new \SplFileInfo(parent::current());
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getFilename()
|
51 |
-
{
|
52 |
-
return parent::current();
|
53 |
-
}
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/FilterIteratorTest.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @author Alex Bogomazov
|
16 |
-
*/
|
17 |
-
class FilterIteratorTest extends RealIteratorTestCase
|
18 |
-
{
|
19 |
-
public function testFilterFilesystemIterators()
|
20 |
-
{
|
21 |
-
$i = new \FilesystemIterator($this->toAbsolute());
|
22 |
-
|
23 |
-
// it is expected that there are test.py test.php in the tmpDir
|
24 |
-
$i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
|
25 |
-
$i->expects($this->any())
|
26 |
-
->method('accept')
|
27 |
-
->will($this->returnCallback(function () use ($i) {
|
28 |
-
return (bool) preg_match('/\.php/', (string) $i->current());
|
29 |
-
})
|
30 |
-
);
|
31 |
-
|
32 |
-
$c = 0;
|
33 |
-
foreach ($i as $item) {
|
34 |
-
++$c;
|
35 |
-
}
|
36 |
-
|
37 |
-
$this->assertEquals(1, $c);
|
38 |
-
|
39 |
-
$i->rewind();
|
40 |
-
|
41 |
-
$c = 0;
|
42 |
-
foreach ($i as $item) {
|
43 |
-
++$c;
|
44 |
-
}
|
45 |
-
|
46 |
-
// This would fail with \FilterIterator but works with Symfony\Component\Finder\Iterator\FilterIterator
|
47 |
-
// see https://bugs.php.net/bug.php?id=49104
|
48 |
-
$this->assertEquals(1, $c);
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/Iterator.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
class Iterator implements \Iterator
|
15 |
-
{
|
16 |
-
protected $values = array();
|
17 |
-
|
18 |
-
public function __construct(array $values = array())
|
19 |
-
{
|
20 |
-
foreach ($values as $value) {
|
21 |
-
$this->attach(new \SplFileInfo($value));
|
22 |
-
}
|
23 |
-
$this->rewind();
|
24 |
-
}
|
25 |
-
|
26 |
-
public function attach(\SplFileInfo $fileinfo)
|
27 |
-
{
|
28 |
-
$this->values[] = $fileinfo;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function rewind()
|
32 |
-
{
|
33 |
-
reset($this->values);
|
34 |
-
}
|
35 |
-
|
36 |
-
public function valid()
|
37 |
-
{
|
38 |
-
return false !== $this->current();
|
39 |
-
}
|
40 |
-
|
41 |
-
public function next()
|
42 |
-
{
|
43 |
-
next($this->values);
|
44 |
-
}
|
45 |
-
|
46 |
-
public function current()
|
47 |
-
{
|
48 |
-
return current($this->values);
|
49 |
-
}
|
50 |
-
|
51 |
-
public function key()
|
52 |
-
{
|
53 |
-
return key($this->values);
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/IteratorTestCase.php
DELETED
@@ -1,98 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
abstract class IteratorTestCase extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
protected function assertIterator($expected, \Traversable $iterator)
|
17 |
-
{
|
18 |
-
// set iterator_to_array $use_key to false to avoid values merge
|
19 |
-
// this made FinderTest::testAppendWithAnArray() failed with GnuFinderAdapter
|
20 |
-
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator, false));
|
21 |
-
|
22 |
-
$expected = array_map(function ($path) { return str_replace('/', DIRECTORY_SEPARATOR, $path); }, $expected);
|
23 |
-
|
24 |
-
sort($values);
|
25 |
-
sort($expected);
|
26 |
-
|
27 |
-
$this->assertEquals($expected, array_values($values));
|
28 |
-
}
|
29 |
-
|
30 |
-
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
31 |
-
{
|
32 |
-
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
|
33 |
-
|
34 |
-
$this->assertEquals($expected, array_values($values));
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Same as assertOrderedIterator, but checks the order of groups of
|
39 |
-
* array elements.
|
40 |
-
*
|
41 |
-
* @param array $expected - an array of arrays. For any two subarrays
|
42 |
-
* $a and $b such that $a goes before $b in $expected, the method
|
43 |
-
* asserts that any element of $a goes before any element of $b
|
44 |
-
* in the sequence generated by $iterator
|
45 |
-
* @param \Traversable $iterator
|
46 |
-
*/
|
47 |
-
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
|
48 |
-
{
|
49 |
-
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
|
50 |
-
|
51 |
-
foreach ($expected as $subarray) {
|
52 |
-
$temp = array();
|
53 |
-
while (count($values) && count($temp) < count($subarray)) {
|
54 |
-
$temp[] = array_shift($values);
|
55 |
-
}
|
56 |
-
sort($temp);
|
57 |
-
sort($subarray);
|
58 |
-
$this->assertEquals($subarray, $temp);
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Same as IteratorTestCase::assertIterator with foreach usage.
|
64 |
-
*
|
65 |
-
* @param array $expected
|
66 |
-
* @param \Traversable $iterator
|
67 |
-
*/
|
68 |
-
protected function assertIteratorInForeach($expected, \Traversable $iterator)
|
69 |
-
{
|
70 |
-
$values = array();
|
71 |
-
foreach ($iterator as $file) {
|
72 |
-
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
73 |
-
$values[] = $file->getPathname();
|
74 |
-
}
|
75 |
-
|
76 |
-
sort($values);
|
77 |
-
sort($expected);
|
78 |
-
|
79 |
-
$this->assertEquals($expected, array_values($values));
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Same as IteratorTestCase::assertOrderedIterator with foreach usage.
|
84 |
-
*
|
85 |
-
* @param array $expected
|
86 |
-
* @param \Traversable $iterator
|
87 |
-
*/
|
88 |
-
protected function assertOrderedIteratorInForeach($expected, \Traversable $iterator)
|
89 |
-
{
|
90 |
-
$values = array();
|
91 |
-
foreach ($iterator as $file) {
|
92 |
-
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
93 |
-
$values[] = $file->getPathname();
|
94 |
-
}
|
95 |
-
|
96 |
-
$this->assertEquals($expected, array_values($values));
|
97 |
-
}
|
98 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/MockFileListIterator.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
class MockFileListIterator extends \ArrayIterator
|
15 |
-
{
|
16 |
-
public function __construct(array $filesArray = array())
|
17 |
-
{
|
18 |
-
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
|
19 |
-
parent::__construct($files);
|
20 |
-
}
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/MockSplFileInfo.php
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
class MockSplFileInfo extends \SplFileInfo
|
15 |
-
{
|
16 |
-
const TYPE_DIRECTORY = 1;
|
17 |
-
const TYPE_FILE = 2;
|
18 |
-
const TYPE_UNKNOWN = 3;
|
19 |
-
|
20 |
-
private $contents = null;
|
21 |
-
private $mode = null;
|
22 |
-
private $type = null;
|
23 |
-
private $relativePath = null;
|
24 |
-
private $relativePathname = null;
|
25 |
-
|
26 |
-
public function __construct($param)
|
27 |
-
{
|
28 |
-
if (is_string($param)) {
|
29 |
-
parent::__construct($param);
|
30 |
-
} elseif (is_array($param)) {
|
31 |
-
$defaults = array(
|
32 |
-
'name' => 'file.txt',
|
33 |
-
'contents' => null,
|
34 |
-
'mode' => null,
|
35 |
-
'type' => null,
|
36 |
-
'relativePath' => null,
|
37 |
-
'relativePathname' => null,
|
38 |
-
);
|
39 |
-
$defaults = array_merge($defaults, $param);
|
40 |
-
parent::__construct($defaults['name']);
|
41 |
-
$this->setContents($defaults['contents']);
|
42 |
-
$this->setMode($defaults['mode']);
|
43 |
-
$this->setType($defaults['type']);
|
44 |
-
$this->setRelativePath($defaults['relativePath']);
|
45 |
-
$this->setRelativePathname($defaults['relativePathname']);
|
46 |
-
} else {
|
47 |
-
throw new \RuntimeException(sprintf('Incorrect parameter "%s"', $param));
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
public function isFile()
|
52 |
-
{
|
53 |
-
if (null === $this->type) {
|
54 |
-
return false !== strpos($this->getFilename(), 'file');
|
55 |
-
};
|
56 |
-
|
57 |
-
return self::TYPE_FILE === $this->type;
|
58 |
-
}
|
59 |
-
|
60 |
-
public function isDir()
|
61 |
-
{
|
62 |
-
if (null === $this->type) {
|
63 |
-
return false !== strpos($this->getFilename(), 'directory');
|
64 |
-
}
|
65 |
-
|
66 |
-
return self::TYPE_DIRECTORY === $this->type;
|
67 |
-
}
|
68 |
-
|
69 |
-
public function isReadable()
|
70 |
-
{
|
71 |
-
if (null === $this->mode) {
|
72 |
-
return preg_match('/r\+/', $this->getFilename());
|
73 |
-
}
|
74 |
-
|
75 |
-
return preg_match('/r\+/', $this->mode);
|
76 |
-
}
|
77 |
-
|
78 |
-
public function getContents()
|
79 |
-
{
|
80 |
-
return $this->contents;
|
81 |
-
}
|
82 |
-
|
83 |
-
public function setContents($contents)
|
84 |
-
{
|
85 |
-
$this->contents = $contents;
|
86 |
-
}
|
87 |
-
|
88 |
-
public function setMode($mode)
|
89 |
-
{
|
90 |
-
$this->mode = $mode;
|
91 |
-
}
|
92 |
-
|
93 |
-
public function setType($type)
|
94 |
-
{
|
95 |
-
if (is_string($type)) {
|
96 |
-
switch ($type) {
|
97 |
-
case 'directory':
|
98 |
-
$this->type = self::TYPE_DIRECTORY;
|
99 |
-
case 'd':
|
100 |
-
$this->type = self::TYPE_DIRECTORY;
|
101 |
-
break;
|
102 |
-
case 'file':
|
103 |
-
$this->type = self::TYPE_FILE;
|
104 |
-
case 'f':
|
105 |
-
$this->type = self::TYPE_FILE;
|
106 |
-
break;
|
107 |
-
default:
|
108 |
-
$this->type = self::TYPE_UNKNOWN;
|
109 |
-
}
|
110 |
-
} else {
|
111 |
-
$this->type = $type;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
public function setRelativePath($relativePath)
|
116 |
-
{
|
117 |
-
$this->relativePath = $relativePath;
|
118 |
-
}
|
119 |
-
|
120 |
-
public function setRelativePathname($relativePathname)
|
121 |
-
{
|
122 |
-
$this->relativePathname = $relativePathname;
|
123 |
-
}
|
124 |
-
|
125 |
-
public function getRelativePath()
|
126 |
-
{
|
127 |
-
return $this->relativePath;
|
128 |
-
}
|
129 |
-
|
130 |
-
public function getRelativePathname()
|
131 |
-
{
|
132 |
-
return $this->relativePathname;
|
133 |
-
}
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
|
15 |
-
|
16 |
-
class MultiplePcreFilterIteratorTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getIsRegexFixtures
|
20 |
-
*/
|
21 |
-
public function testIsRegex($string, $isRegex, $message)
|
22 |
-
{
|
23 |
-
$testIterator = new TestMultiplePcreFilterIterator();
|
24 |
-
$this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getIsRegexFixtures()
|
28 |
-
{
|
29 |
-
return array(
|
30 |
-
array('foo', false, 'string'),
|
31 |
-
array(' foo ', false, '" " is not a valid delimiter'),
|
32 |
-
array('\\foo\\', false, '"\\" is not a valid delimiter'),
|
33 |
-
array('afooa', false, '"a" is not a valid delimiter'),
|
34 |
-
array('//', false, 'the pattern should contain at least 1 character'),
|
35 |
-
array('/a/', true, 'valid regex'),
|
36 |
-
array('/foo/', true, 'valid regex'),
|
37 |
-
array('/foo/i', true, 'valid regex with a single modifier'),
|
38 |
-
array('/foo/imsxu', true, 'valid regex with multiple modifiers'),
|
39 |
-
array('#foo#', true, '"#" is a valid delimiter'),
|
40 |
-
array('{foo}', true, '"{,}" is a valid delimiter pair'),
|
41 |
-
array('*foo.*', false, '"*" is not considered as a valid delimiter'),
|
42 |
-
array('?foo.?', false, '"?" is not considered as a valid delimiter'),
|
43 |
-
);
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
|
48 |
-
{
|
49 |
-
public function __construct()
|
50 |
-
{
|
51 |
-
}
|
52 |
-
|
53 |
-
public function accept()
|
54 |
-
{
|
55 |
-
throw new \BadFunctionCallException('Not implemented');
|
56 |
-
}
|
57 |
-
|
58 |
-
public function isRegex($str)
|
59 |
-
{
|
60 |
-
return parent::isRegex($str);
|
61 |
-
}
|
62 |
-
|
63 |
-
public function toRegex($str)
|
64 |
-
{
|
65 |
-
throw new \BadFunctionCallException('Not implemented');
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/PathFilterIteratorTest.php
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\PathFilterIterator;
|
15 |
-
|
16 |
-
class PathFilterIteratorTest extends IteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getTestFilterData
|
20 |
-
*/
|
21 |
-
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
22 |
-
{
|
23 |
-
$iterator = new PathFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
24 |
-
$this->assertIterator($resultArray, $iterator);
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getTestFilterData()
|
28 |
-
{
|
29 |
-
$inner = new MockFileListIterator();
|
30 |
-
|
31 |
-
//PATH: A/B/C/abc.dat
|
32 |
-
$inner[] = new MockSplFileInfo(array(
|
33 |
-
'name' => 'abc.dat',
|
34 |
-
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
35 |
-
));
|
36 |
-
|
37 |
-
//PATH: A/B/ab.dat
|
38 |
-
$inner[] = new MockSplFileInfo(array(
|
39 |
-
'name' => 'ab.dat',
|
40 |
-
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
41 |
-
));
|
42 |
-
|
43 |
-
//PATH: A/a.dat
|
44 |
-
$inner[] = new MockSplFileInfo(array(
|
45 |
-
'name' => 'a.dat',
|
46 |
-
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'a.dat',
|
47 |
-
));
|
48 |
-
|
49 |
-
//PATH: copy/A/B/C/abc.dat.copy
|
50 |
-
$inner[] = new MockSplFileInfo(array(
|
51 |
-
'name' => 'abc.dat.copy',
|
52 |
-
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
53 |
-
));
|
54 |
-
|
55 |
-
//PATH: copy/A/B/ab.dat.copy
|
56 |
-
$inner[] = new MockSplFileInfo(array(
|
57 |
-
'name' => 'ab.dat.copy',
|
58 |
-
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
59 |
-
));
|
60 |
-
|
61 |
-
//PATH: copy/A/a.dat.copy
|
62 |
-
$inner[] = new MockSplFileInfo(array(
|
63 |
-
'name' => 'a.dat.copy',
|
64 |
-
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'a.dat',
|
65 |
-
));
|
66 |
-
|
67 |
-
return array(
|
68 |
-
array($inner, array('/^A/'), array(), array('abc.dat', 'ab.dat', 'a.dat')),
|
69 |
-
array($inner, array('/^A\/B/'), array(), array('abc.dat', 'ab.dat')),
|
70 |
-
array($inner, array('/^A\/B\/C/'), array(), array('abc.dat')),
|
71 |
-
array($inner, array('/A\/B\/C/'), array(), array('abc.dat', 'abc.dat.copy')),
|
72 |
-
|
73 |
-
array($inner, array('A'), array(), array('abc.dat', 'ab.dat', 'a.dat', 'abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
|
74 |
-
array($inner, array('A/B'), array(), array('abc.dat', 'ab.dat', 'abc.dat.copy', 'ab.dat.copy')),
|
75 |
-
array($inner, array('A/B/C'), array(), array('abc.dat', 'abc.dat.copy')),
|
76 |
-
|
77 |
-
array($inner, array('copy/A'), array(), array('abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
|
78 |
-
array($inner, array('copy/A/B'), array(), array('abc.dat.copy', 'ab.dat.copy')),
|
79 |
-
array($inner, array('copy/A/B/C'), array(), array('abc.dat.copy')),
|
80 |
-
|
81 |
-
);
|
82 |
-
}
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/RealIteratorTestCase.php
DELETED
@@ -1,109 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
abstract class RealIteratorTestCase extends IteratorTestCase
|
15 |
-
{
|
16 |
-
protected static $tmpDir;
|
17 |
-
protected static $files;
|
18 |
-
|
19 |
-
public static function setUpBeforeClass()
|
20 |
-
{
|
21 |
-
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
|
22 |
-
|
23 |
-
self::$files = array(
|
24 |
-
'.git/',
|
25 |
-
'.foo/',
|
26 |
-
'.foo/.bar',
|
27 |
-
'.foo/bar',
|
28 |
-
'.bar',
|
29 |
-
'test.py',
|
30 |
-
'foo/',
|
31 |
-
'foo/bar.tmp',
|
32 |
-
'test.php',
|
33 |
-
'toto/',
|
34 |
-
'foo bar',
|
35 |
-
);
|
36 |
-
|
37 |
-
self::$files = self::toAbsolute(self::$files);
|
38 |
-
|
39 |
-
if (is_dir(self::$tmpDir)) {
|
40 |
-
self::tearDownAfterClass();
|
41 |
-
} else {
|
42 |
-
mkdir(self::$tmpDir);
|
43 |
-
}
|
44 |
-
|
45 |
-
foreach (self::$files as $file) {
|
46 |
-
if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
|
47 |
-
mkdir($file);
|
48 |
-
} else {
|
49 |
-
touch($file);
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800));
|
54 |
-
file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000));
|
55 |
-
|
56 |
-
touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15'));
|
57 |
-
touch(self::toAbsolute('test.php'), strtotime('2005-10-15'));
|
58 |
-
}
|
59 |
-
|
60 |
-
public static function tearDownAfterClass()
|
61 |
-
{
|
62 |
-
foreach (array_reverse(self::$files) as $file) {
|
63 |
-
if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
|
64 |
-
@rmdir($file);
|
65 |
-
} else {
|
66 |
-
@unlink($file);
|
67 |
-
}
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
protected static function toAbsolute($files = null)
|
72 |
-
{
|
73 |
-
/*
|
74 |
-
* Without the call to setUpBeforeClass() property can be null.
|
75 |
-
*/
|
76 |
-
if (!self::$tmpDir) {
|
77 |
-
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
|
78 |
-
}
|
79 |
-
|
80 |
-
if (is_array($files)) {
|
81 |
-
$f = array();
|
82 |
-
foreach ($files as $file) {
|
83 |
-
if (is_array($file)) {
|
84 |
-
$f[] = self::toAbsolute($file);
|
85 |
-
} else {
|
86 |
-
$f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
return $f;
|
91 |
-
}
|
92 |
-
|
93 |
-
if (is_string($files)) {
|
94 |
-
return self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $files);
|
95 |
-
}
|
96 |
-
|
97 |
-
return self::$tmpDir;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected static function toAbsoluteFixtures($files)
|
101 |
-
{
|
102 |
-
$f = array();
|
103 |
-
foreach ($files as $file) {
|
104 |
-
$f[] = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$file);
|
105 |
-
}
|
106 |
-
|
107 |
-
return $f;
|
108 |
-
}
|
109 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
15 |
-
|
16 |
-
class RecursiveDirectoryIteratorTest extends IteratorTestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getPaths
|
20 |
-
*
|
21 |
-
* @param string $path
|
22 |
-
* @param bool $seekable
|
23 |
-
* @param array $contains
|
24 |
-
* @param string $message
|
25 |
-
*/
|
26 |
-
public function testRewind($path, $seekable, $contains, $message = null)
|
27 |
-
{
|
28 |
-
try {
|
29 |
-
$i = new RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
|
30 |
-
} catch (\UnexpectedValueException $e) {
|
31 |
-
$this->markTestSkipped(sprintf('Unsupported stream "%s".', $path));
|
32 |
-
}
|
33 |
-
|
34 |
-
$i->rewind();
|
35 |
-
|
36 |
-
$this->assertTrue(true, $message);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @dataProvider getPaths
|
41 |
-
*
|
42 |
-
* @param string $path
|
43 |
-
* @param bool $seekable
|
44 |
-
* @param array $contains
|
45 |
-
* @param string $message
|
46 |
-
*/
|
47 |
-
public function testSeek($path, $seekable, $contains, $message = null)
|
48 |
-
{
|
49 |
-
try {
|
50 |
-
$i = new RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
|
51 |
-
} catch (\UnexpectedValueException $e) {
|
52 |
-
$this->markTestSkipped(sprintf('Unsupported stream "%s".', $path));
|
53 |
-
}
|
54 |
-
|
55 |
-
$actual = array();
|
56 |
-
|
57 |
-
$i->seek(0);
|
58 |
-
$actual[] = $i->getPathname();
|
59 |
-
|
60 |
-
$i->seek(1);
|
61 |
-
$actual[] = $i->getPathname();
|
62 |
-
|
63 |
-
$i->seek(2);
|
64 |
-
$actual[] = $i->getPathname();
|
65 |
-
|
66 |
-
$this->assertEquals($contains, $actual);
|
67 |
-
}
|
68 |
-
|
69 |
-
public function getPaths()
|
70 |
-
{
|
71 |
-
$data = array();
|
72 |
-
|
73 |
-
// ftp
|
74 |
-
$contains = array(
|
75 |
-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'README',
|
76 |
-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'index.html',
|
77 |
-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'pub',
|
78 |
-
);
|
79 |
-
$data[] = array('ftp://ftp.mozilla.org/', false, $contains);
|
80 |
-
|
81 |
-
return $data;
|
82 |
-
}
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/SizeRangeFilterIteratorTest.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
|
15 |
-
use Symfony\Component\Finder\Comparator\NumberComparator;
|
16 |
-
|
17 |
-
class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @dataProvider getAcceptData
|
21 |
-
*/
|
22 |
-
public function testAccept($size, $expected)
|
23 |
-
{
|
24 |
-
$inner = new InnerSizeIterator(self::$files);
|
25 |
-
|
26 |
-
$iterator = new SizeRangeFilterIterator($inner, $size);
|
27 |
-
|
28 |
-
$this->assertIterator($expected, $iterator);
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getAcceptData()
|
32 |
-
{
|
33 |
-
$lessThan1KGreaterThan05K = array(
|
34 |
-
'.foo',
|
35 |
-
'.git',
|
36 |
-
'foo',
|
37 |
-
'test.php',
|
38 |
-
'toto',
|
39 |
-
);
|
40 |
-
|
41 |
-
return array(
|
42 |
-
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
|
43 |
-
);
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
class InnerSizeIterator extends \ArrayIterator
|
48 |
-
{
|
49 |
-
public function current()
|
50 |
-
{
|
51 |
-
return new \SplFileInfo(parent::current());
|
52 |
-
}
|
53 |
-
|
54 |
-
public function getFilename()
|
55 |
-
{
|
56 |
-
return parent::current();
|
57 |
-
}
|
58 |
-
|
59 |
-
public function isFile()
|
60 |
-
{
|
61 |
-
return $this->current()->isFile();
|
62 |
-
}
|
63 |
-
|
64 |
-
public function getSize()
|
65 |
-
{
|
66 |
-
return $this->current()->getSize();
|
67 |
-
}
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Iterator/SortableIteratorTest.php
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Iterator;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Iterator\SortableIterator;
|
15 |
-
|
16 |
-
class SortableIteratorTest extends RealIteratorTestCase
|
17 |
-
{
|
18 |
-
public function testConstructor()
|
19 |
-
{
|
20 |
-
try {
|
21 |
-
new SortableIterator(new Iterator(array()), 'foobar');
|
22 |
-
$this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid');
|
23 |
-
} catch (\Exception $e) {
|
24 |
-
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid');
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @dataProvider getAcceptData
|
30 |
-
*/
|
31 |
-
public function testAccept($mode, $expected)
|
32 |
-
{
|
33 |
-
if (!is_callable($mode)) {
|
34 |
-
switch ($mode) {
|
35 |
-
case SortableIterator::SORT_BY_ACCESSED_TIME :
|
36 |
-
file_get_contents(self::toAbsolute('.git'));
|
37 |
-
sleep(1);
|
38 |
-
file_get_contents(self::toAbsolute('.bar'));
|
39 |
-
break;
|
40 |
-
case SortableIterator::SORT_BY_CHANGED_TIME :
|
41 |
-
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
42 |
-
sleep(1);
|
43 |
-
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
44 |
-
break;
|
45 |
-
case SortableIterator::SORT_BY_MODIFIED_TIME :
|
46 |
-
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
47 |
-
sleep(1);
|
48 |
-
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
49 |
-
break;
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
$inner = new Iterator(self::$files);
|
54 |
-
|
55 |
-
$iterator = new SortableIterator($inner, $mode);
|
56 |
-
|
57 |
-
if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME
|
58 |
-
|| $mode === SortableIterator::SORT_BY_CHANGED_TIME
|
59 |
-
|| $mode === SortableIterator::SORT_BY_MODIFIED_TIME) {
|
60 |
-
$this->assertOrderedIteratorForGroups($expected, $iterator);
|
61 |
-
} else {
|
62 |
-
$this->assertOrderedIterator($expected, $iterator);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
public function getAcceptData()
|
67 |
-
{
|
68 |
-
$sortByName = array(
|
69 |
-
'.bar',
|
70 |
-
'.foo',
|
71 |
-
'.foo/.bar',
|
72 |
-
'.foo/bar',
|
73 |
-
'.git',
|
74 |
-
'foo',
|
75 |
-
'foo bar',
|
76 |
-
'foo/bar.tmp',
|
77 |
-
'test.php',
|
78 |
-
'test.py',
|
79 |
-
'toto',
|
80 |
-
);
|
81 |
-
|
82 |
-
$sortByType = array(
|
83 |
-
'.foo',
|
84 |
-
'.git',
|
85 |
-
'foo',
|
86 |
-
'toto',
|
87 |
-
'.bar',
|
88 |
-
'.foo/.bar',
|
89 |
-
'.foo/bar',
|
90 |
-
'foo bar',
|
91 |
-
'foo/bar.tmp',
|
92 |
-
'test.php',
|
93 |
-
'test.py',
|
94 |
-
);
|
95 |
-
|
96 |
-
$customComparison = array(
|
97 |
-
'.bar',
|
98 |
-
'.foo',
|
99 |
-
'.foo/.bar',
|
100 |
-
'.foo/bar',
|
101 |
-
'.git',
|
102 |
-
'foo',
|
103 |
-
'foo bar',
|
104 |
-
'foo/bar.tmp',
|
105 |
-
'test.php',
|
106 |
-
'test.py',
|
107 |
-
'toto',
|
108 |
-
);
|
109 |
-
|
110 |
-
$sortByAccessedTime = array(
|
111 |
-
// For these two files the access time was set to 2005-10-15
|
112 |
-
array('foo/bar.tmp', 'test.php'),
|
113 |
-
// These files were created more or less at the same time
|
114 |
-
array(
|
115 |
-
'.git',
|
116 |
-
'.foo',
|
117 |
-
'.foo/.bar',
|
118 |
-
'.foo/bar',
|
119 |
-
'test.py',
|
120 |
-
'foo',
|
121 |
-
'toto',
|
122 |
-
'foo bar',
|
123 |
-
),
|
124 |
-
// This file was accessed after sleeping for 1 sec
|
125 |
-
array('.bar'),
|
126 |
-
);
|
127 |
-
|
128 |
-
$sortByChangedTime = array(
|
129 |
-
array(
|
130 |
-
'.git',
|
131 |
-
'.foo',
|
132 |
-
'.foo/.bar',
|
133 |
-
'.foo/bar',
|
134 |
-
'.bar',
|
135 |
-
'foo',
|
136 |
-
'foo/bar.tmp',
|
137 |
-
'toto',
|
138 |
-
'foo bar',
|
139 |
-
),
|
140 |
-
array('test.php'),
|
141 |
-
array('test.py'),
|
142 |
-
);
|
143 |
-
|
144 |
-
$sortByModifiedTime = array(
|
145 |
-
array(
|
146 |
-
'.git',
|
147 |
-
'.foo',
|
148 |
-
'.foo/.bar',
|
149 |
-
'.foo/bar',
|
150 |
-
'.bar',
|
151 |
-
'foo',
|
152 |
-
'foo/bar.tmp',
|
153 |
-
'toto',
|
154 |
-
'foo bar',
|
155 |
-
),
|
156 |
-
array('test.php'),
|
157 |
-
array('test.py'),
|
158 |
-
);
|
159 |
-
|
160 |
-
return array(
|
161 |
-
array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
|
162 |
-
array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
|
163 |
-
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
164 |
-
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
165 |
-
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
166 |
-
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
|
167 |
-
);
|
168 |
-
}
|
169 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/Tests/Shell/CommandTest.php
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Symfony package.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier <fabien@symfony.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Symfony\Component\Finder\Tests\Shell;
|
13 |
-
|
14 |
-
use Symfony\Component\Finder\Shell\Command;
|
15 |
-
|
16 |
-
class CommandTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function testCreate()
|
19 |
-
{
|
20 |
-
$this->assertInstanceOf('Symfony\Component\Finder\Shell\Command', Command::create());
|
21 |
-
}
|
22 |
-
|
23 |
-
public function testAdd()
|
24 |
-
{
|
25 |
-
$cmd = Command::create()->add('--force');
|
26 |
-
$this->assertSame('--force', $cmd->join());
|
27 |
-
}
|
28 |
-
|
29 |
-
public function testAddAsFirst()
|
30 |
-
{
|
31 |
-
$cmd = Command::create()->add('--force');
|
32 |
-
|
33 |
-
$cmd->addAtIndex(Command::create()->add('-F'), 0);
|
34 |
-
$this->assertSame('-F --force', $cmd->join());
|
35 |
-
}
|
36 |
-
|
37 |
-
public function testAddAsLast()
|
38 |
-
{
|
39 |
-
$cmd = Command::create()->add('--force');
|
40 |
-
|
41 |
-
$cmd->addAtIndex(Command::create()->add('-F'), 1);
|
42 |
-
$this->assertSame('--force -F', $cmd->join());
|
43 |
-
}
|
44 |
-
|
45 |
-
public function testAddInBetween()
|
46 |
-
{
|
47 |
-
$cmd = Command::create()->add('--force');
|
48 |
-
$cmd->addAtIndex(Command::create()->add('-F'), 0);
|
49 |
-
|
50 |
-
$cmd->addAtIndex(Command::create()->add('-X'), 1);
|
51 |
-
$this->assertSame('-F -X --force', $cmd->join());
|
52 |
-
}
|
53 |
-
|
54 |
-
public function testCount()
|
55 |
-
{
|
56 |
-
$cmd = Command::create();
|
57 |
-
$this->assertSame(0, $cmd->length());
|
58 |
-
|
59 |
-
$cmd->add('--force');
|
60 |
-
$this->assertSame(1, $cmd->length());
|
61 |
-
|
62 |
-
$cmd->add('--run');
|
63 |
-
$this->assertSame(2, $cmd->length());
|
64 |
-
}
|
65 |
-
|
66 |
-
public function testTop()
|
67 |
-
{
|
68 |
-
$cmd = Command::create()->add('--force');
|
69 |
-
|
70 |
-
$cmd->top('--run');
|
71 |
-
$this->assertSame('--run --force', $cmd->join());
|
72 |
-
}
|
73 |
-
|
74 |
-
public function testTopLabeled()
|
75 |
-
{
|
76 |
-
$cmd = Command::create()->add('--force');
|
77 |
-
|
78 |
-
$cmd->top('--run');
|
79 |
-
$cmd->ins('--something');
|
80 |
-
$cmd->top('--something');
|
81 |
-
$this->assertSame('--something --run --force ', $cmd->join());
|
82 |
-
}
|
83 |
-
|
84 |
-
public function testArg()
|
85 |
-
{
|
86 |
-
$cmd = Command::create()->add('--force');
|
87 |
-
|
88 |
-
$cmd->arg('--run');
|
89 |
-
$this->assertSame('--force \'--run\'', $cmd->join());
|
90 |
-
}
|
91 |
-
|
92 |
-
public function testCmd()
|
93 |
-
{
|
94 |
-
$cmd = Command::create()->add('--force');
|
95 |
-
|
96 |
-
$cmd->cmd('run');
|
97 |
-
$this->assertSame('--force run', $cmd->join());
|
98 |
-
}
|
99 |
-
|
100 |
-
public function testInsDuplicateLabelException()
|
101 |
-
{
|
102 |
-
$cmd = Command::create()->add('--force');
|
103 |
-
|
104 |
-
$cmd->ins('label');
|
105 |
-
$this->setExpectedException('RuntimeException');
|
106 |
-
$cmd->ins('label');
|
107 |
-
}
|
108 |
-
|
109 |
-
public function testEnd()
|
110 |
-
{
|
111 |
-
$parent = Command::create();
|
112 |
-
$cmd = Command::create($parent);
|
113 |
-
|
114 |
-
$this->assertSame($parent, $cmd->end());
|
115 |
-
}
|
116 |
-
|
117 |
-
public function testEndNoParentException()
|
118 |
-
{
|
119 |
-
$cmd = Command::create();
|
120 |
-
|
121 |
-
$this->setExpectedException('RuntimeException');
|
122 |
-
$cmd->end();
|
123 |
-
}
|
124 |
-
|
125 |
-
public function testGetMissingLabelException()
|
126 |
-
{
|
127 |
-
$cmd = Command::create();
|
128 |
-
|
129 |
-
$this->setExpectedException('RuntimeException');
|
130 |
-
$cmd->get('invalid');
|
131 |
-
}
|
132 |
-
|
133 |
-
public function testErrorHandler()
|
134 |
-
{
|
135 |
-
$cmd = Command::create();
|
136 |
-
$handler = function() { return 'error-handler'; };
|
137 |
-
$cmd->setErrorHandler($handler);
|
138 |
-
|
139 |
-
$this->assertSame($handler, $cmd->getErrorHandler());
|
140 |
-
}
|
141 |
-
|
142 |
-
public function testExecute()
|
143 |
-
{
|
144 |
-
$cmd = Command::create();
|
145 |
-
$cmd->add('php');
|
146 |
-
$cmd->add('--version');
|
147 |
-
$result = $cmd->execute();
|
148 |
-
|
149 |
-
$this->assertTrue(is_array($result));
|
150 |
-
$this->assertNotEmpty($result);
|
151 |
-
$this->assertRegexp('/PHP|HipHop/', $result[0]);
|
152 |
-
}
|
153 |
-
|
154 |
-
public function testCastToString()
|
155 |
-
{
|
156 |
-
$cmd = Command::create();
|
157 |
-
$cmd->add('--force');
|
158 |
-
$cmd->add('--run');
|
159 |
-
|
160 |
-
$this->assertSame('--force --run', (string) $cmd);
|
161 |
-
}
|
162 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/symfony/finder/composer.json
CHANGED
@@ -18,9 +18,6 @@
|
|
18 |
"require": {
|
19 |
"php": ">=5.3.9"
|
20 |
},
|
21 |
-
"require-dev": {
|
22 |
-
"symfony/phpunit-bridge": "~2.7"
|
23 |
-
},
|
24 |
"autoload": {
|
25 |
"psr-4": { "Symfony\\Component\\Finder\\": "" }
|
26 |
},
|
18 |
"require": {
|
19 |
"php": ">=5.3.9"
|
20 |
},
|
|
|
|
|
|
|
21 |
"autoload": {
|
22 |
"psr-4": { "Symfony\\Component\\Finder\\": "" }
|
23 |
},
|