WordPress / WordPress/grunt-patch-wordpress

Uploaded patches are empty

Open
#46 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
51
Forks
13
PR merge metrics
No merged PRs in 30d

Description

When I use the upload_patch command the file that is uploaded is empty. However, adding the same file manually in trac works.

Operating System:
Mac OS 10.11.16.

Copy of the file ( I had to change the extension from .diff to .txt to upload here )
39800.txt

git diff master --no-prefix output:

diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php
index 737d6e6..ea7c22d 100644
--- a/src/wp-includes/nav-menu-template.php
+++ b/src/wp-includes/nav-menu-template.php
@@ -394,6 +394,18 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
                ) {
                        $classes[] = 'current-menu-item';
                        $menu_items[$key]->current = true;
+
+                       $_anc_id = (int) $menu_item->db_id;
+
+                       while(
+                               ( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
+                               ! in_array( $_anc_id, $active_ancestor_item_ids, true )
+                       ) {
+                               $active_ancestor_item_ids[] = $_anc_id;
+                       }
+
+                       $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
+
                // if the menu item corresponds to the currently-requested URL
                } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
                        $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php
index c6a028c..d0496a1 100644
--- a/tests/phpunit/tests/post/nav-menu.php
+++ b/tests/phpunit/tests/post/nav-menu.php
@@ -553,4 +553,63 @@ class Test_Nav_Menus extends WP_UnitTestCase {
                $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[0] ) );
                $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[1] ) );
        }
+
+
+       /**







diff --git src/wp-includes/nav-menu-template.php src/wp-includes/nav-menu-template.php
index 737d6e6..ea7c22d 100644
--- src/wp-includes/nav-menu-template.php
+++ src/wp-includes/nav-menu-template.php
@@ -394,6 +394,18 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
                ) {
                        $classes[] = 'current-menu-item';
                        $menu_items[$key]->current = true;
+
+                       $_anc_id = (int) $menu_item->db_id;
+
+                       while(
+                               ( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
+                               ! in_array( $_anc_id, $active_ancestor_item_ids, true )
+                       ) {
+                               $active_ancestor_item_ids[] = $_anc_id;
+                       }
+
+                       $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
+
                // if the menu item corresponds to the currently-requested URL
                } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
                        $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
                // if the menu item corresponds to the currently-requested URL
                } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
                        $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
diff --git tests/phpunit/tests/post/nav-menu.php tests/phpunit/tests/post/nav-menu.php
index c6a028c..d0496a1 100644
--- tests/phpunit/tests/post/nav-menu.php
+++ tests/phpunit/tests/post/nav-menu.php
@@ -553,4 +553,63 @@ class Test_Nav_Menus extends WP_UnitTestCase {
                $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[0] ) );
                $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[1] ) );
        }
+
+
+       /**
+        * @ticket 39800
+        */
+       function test_parent_ancestor_for_post_archive() {
+
+               register_post_type( 'books', array( 'label' => 'Books', 'public' => true, 'has_archive' => true ) );
+
+               $first_page_id  = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Top Level Page') );
+               $second_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Second Level Page') );
+
+
+               $first_menu_id = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type'      => 'post_type',
+                       'menu-item-object'    => 'page',
+                       'menu-item-object-id' => $first_page_id,
+                       'menu-item-status'    => 'publish',
+               ));
+
+               $second_menu_id = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type'      => 'post_type',
+                       'menu-item-object'    => 'page',
+                       'menu-item-object-id' => $second_page_id,
+                       'menu-item-status'    => 'publish',
+                       'menu-item-parent-id' => $first_menu_id
+               ));
+
+               wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type'      => 'post_type_archive',
+                       'menu-item-object'    => 'books',
+                       'menu-item-status'    => 'publish',
+                       'menu-item-parent-id' => $second_menu_id
+               ));
+
+               $this->go_to( get_post_type_archive_link( 'books') );
+
+               $menu_items = wp_get_nav_menu_items( $this->menu_id );
+               _wp_menu_item_classes_by_context( $menu_items );
+
+               $top_page_menu_item       = $menu_items[0];
+               $secondary_page_menu_item = $menu_items[1];
+               $post_archive_menu_item   = $menu_items[2];
+
+               $this->assertFalse( $top_page_menu_item->current_item_parent );
+               $this->assertTrue( $top_page_menu_item->current_item_ancestor );
+               $this->assertContains( 'current-menu-ancestor', $top_page_menu_item->classes );
+
+               $this->assertTrue( $secondary_page_menu_item->current_item_parent );
+               $this->assertTrue( $secondary_page_menu_item->current_item_ancestor  );
+               $this->assertContains( 'current-menu-parent', $secondary_page_menu_item->classes );
+               $this->assertContains( 'current-menu-ancestor', $secondary_page_menu_item->classes );
+
+               $this->assertFalse( $post_archive_menu_item->current_item_parent );
+               $this->assertFalse( $post_archive_menu_item->current_item_ancestor  );
+
+               $this->assertNotContains( 'current-menu-parent', $post_archive_menu_item->classes );
+               $this->assertNotContains( 'current-menu-ancestor', $post_archive_menu_item->classes );
+       }
 }
(END)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the upload_patch command and reproduce the empty-upload behavior using the attached patch file, comparing it with a manual Trac upload. Trace how the command reads and submits the file; done means the uploaded patch retains the complete diff instead of being empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.