Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
287 stars 205 forks source link

In WordPress > 4.9.1, co-authors do not save correctly #470

Closed benlk closed 10 months ago

benlk commented 6 years ago

Steps to reproduce:

  1. Create a post
  2. Assign a co-author to the post
  3. Save or publish the post.
  4. Add a second co-author to the post and remove the original co-author.
  5. Update or publish the post.

In 4.9.0, the above steps resulted in the second co-author being the sole co-author on the post. In 4.9.1., the second co-author is nowhere to be found and the first co-author remains on the post.

This was discovered in WP Engine's production and staging environments; I will attempt to replicate in different environments and update this ticket.

benlk commented 6 years ago

Well, we were able to replicate it on Flywheel's server, and on a Laravel Valet test environment in WordPress 4.9.2. Enabling CAP causes non-guest-authors who have authored posts to show different post counts, and there's the issue with the inability to set coauthors.

Looking through the support forums, I think https://wordpress.org/support/topic/uninstalled-and-reinstalled-and-now-broken/ and https://wordpress.org/support/topic/authors-help/ are experiencing this same issue.

nmeh20 commented 6 years ago

The issue mentioned in the comment posted on Dec 21, 2017 cannot be reproduced. Could you please provide screenshots of the steps to reproduce it?

Also, could you please provide more details with the screenshots for the issues mentioned in the last comment regarding different post counts and inability to set coauthors?

benlk commented 6 years ago

Here's a minimal test case. A WordPress user hstockton has created a post, and the linked guest author halle-stockton appears in the co-author bylines box in the post editor. We wish to add the guest author author-saima-sitwat:

screen shot 2018-02-05 at 2 56 02 pm

The prediction makes a request to admin-ajax, the complete response of which is:

6471 | author/saima-sitwat | Saima Sitwat |  | author-saima-sitwat

Press save, here's the submitted form data:

full form data _wpnonce:7b81791385 _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 user_ID:32 action:editpost originalaction:editpost post_author:5 post_type:post original_post_status:publish referredby:https://www.publicsource.test/wp-admin/post.php?post=122238&action=edit _wp_original_http_referer:https://www.publicsource.test/wp-admin/post.php?post=122238&action=edit post_ID:122238 meta-box-order-nonce:7c5cc5f52c closedpostboxesnonce:c442410420 post_title:As homeschooling becomes more mainstream, is it right for my child? Here’s what I've learned. samplepermalinknonce:273d257bd5 content: ``` The question surprised both of us. “Do you like being homeschooled?” a woman asked my 8-year-old daughter Alina at our gym in Wexford. She was out of school sick that day. I didn’t think homeschool was the most obvious reason to figure a child wouldn’t be in school. But, as Alina tried to decipher what “homeschooling” meant, I remembered that some of my friends have chosen to homeschool and recalled the kids I’ve been noticing during the daytime at grocery stores, how they practice spelling ingredients on the packages or calculating the bill at the register. While some of them could be enrolled in cyber schools, it made me wonder if homeschooling is becoming more mainstream — at least in my suburban world. In fact, homeschooling has been on the rise in Pennsylvania since the 2011-12 school year when there were about 20,900 homeschooled students in the state. In 2015-16, the state Department of Education recorded nearly 23,900 homeschoolers, which likely underestimates its prevalence because students homeschooled for religious reasons are exempt from the registration requirement. Still, homeschooled students represent only about 1.38 percent of K-12 students in Pennsylvania. Nationally, homeschoolers tend to be white (59 percent) and concentrated in the suburbs (39 percent), according to the National Center for Education Statistics [NCES]. The 2015-2016 state data showed 2,638 homeschooled students in the seven-county Pittsburgh metropolitan area, 40 percent of whom were living in Allegheny County. [caption id="attachment_122253" align="alignnone" width="771"] Lisa Smith is the founder of the Homeschool Co-op of Pittsburgh. A mother of six children, she has homeschooled her older five for the past six years. (Photo by Njaimeh Njie/PublicSource)[/caption] Homeschooling also seems to be getting more acceptance on a federal level. U.S. Secretary of Education Betsy DeVos has been called a "friend" of homeschoolers by the Homeschool Legal Defense Association [HSLDA], a homeschooling advocacy group. A proponent of school choice, she supports measures that would assist families who choose not to enroll their children in public schools, such as a tax credit plan or government-issued school vouchers. So homeschooling families must love her, right? Not universally. According to HSLDA, monetary benefits from the government would be a potential threat to a system that has so far stayed clear of strict regulation. HSLDA, a Christian group, has been a leading voice in opposing federal money for homeschooling. According to the Washington Post, the new tax law signed into law in December includes financial incentives for families to send their children to private school, a move supported by DeVos. While HSLDA has opposed government money for homeschooling, the group supported a proposal within the tax bill to expand the 529 tax-advantaged savings plan to apply to homeschooling expenses. The distinction cited by the group is that money in a 529 plan is “your own money, not government money.” Lawmakers, however, cut the provision from the bill in last-minute negotiations. Armed with the basics on homeschooling, I began to wonder: Why would families choose to homeschool when several options like public, private, cyber and parochial schools are available? Who ensures homeschooling curriculum and evaluation are at par with the state education requirements? Do homeschooled children acquire necessary social skills? These were the questions I set out to answer while confronting my own dilemma. Am I failing as a parent by sending my daughter off to be one of 24 children in her second-grade homeroom? Perhaps she would excel with a more relaxed routine and nuanced education. The morning and evening rush, struggles with the new curriculum standards and the stress of standardized tests — this could all be cast off in a flash if our family were to decide to homeschool. The answers, as I discovered, are not so clear.

Why families choose to keep kids at home

Homeschooling was legalized in Pennsylvania in 1988 and in all 50 states by 1993. According to the NCES, the homeschooling movement peaked in 2012 when the number of school-age children educated at home rose to 3.4 percent from 1.7 percent in 1999. [caption id="attachment_122266" align="alignnone" width="771"] Tahira Sarwar, of Chartiers Valley, homeschools three of her four children, including 5-year-old Abdullah Bhatti. She is able to incorporate Islamic religious education into the curriculum. (Photo by Njaimeh Njie/PublicSource)[/caption] In 2012, the top reasons for parents to homeschool were concerns about safety, drugs and negative peer pressure in the school environment. The concerns persist in 2016 with parents also mentioning dissatisfaction with academic instruction and a desire to provide religious instruction. Lisa Smith is the founder of the Homeschooling Co-op of Pittsburgh. She started the co-op in 2014 as a support group and avenue for homeschooling families to share their skills. “We had a certified Mandarin teacher, she just moved out of state, she taught Mandarin to our kids for two years,” Smith said. “Another one is a certified German teacher, we have a botanist, we have all kinds of talent in the group.” The co-op used to meet twice a month, but recently increased it to once a week at its new location at the Pittsburgh New Church School [PNCS]. Smith has homeschooled the older five of her six children for the past six years. They range in age from 4 to 11. She said most parents she knows homeschool to provide a better school environment, free of bullying and drug activity. “It was difficult for my generation, but I think that has become a much bigger problem in the next generation,” she said. “Families my age and parents my age don’t want to see this trend continue with our children.” For Smith, it was the one-size-fits-all approach of the traditional school that helped her make up her mind about whether or not to homeschool. Smith said her oldest child had a difficult time in her preschool program because she was so shy. “She had a hard time socializing with other kids,” she said. “For kindergarten, we tried cyber school, still trying to figure out where we fit into this whole scheme.” Her daughter didn’t like cyber school. “Because she was expected to be on the computer for hours a day. It was a lot of busy work, and she was bored really quickly.” [caption id="attachment_122268" align="alignnone" width="771"] Rabia Khan's 7-year-old daughter Mariam works on math worksheets from her Mount Lebanon home. (Photo by Njaimeh Njie/PublicSource)[/caption] The desire to provide individualized support, especially during a child’s formative years of elementary school is also what motivated my friend Rabia Khan of Mount Lebanon to homeschool her daughter, one of her three children. Tahira Sarwar of Chartiers Valley homeschools three of her four children. Sarwar’s oldest daughter attended kindergarten at the local school district but, like Smith’s daughter, did not seem to thrive socially. She said she chose to homeschool because she is able to incorporate Islamic religious education into the curriculum and homeschoolers do not have to follow the PA Core.

Homeschooling standards and oversight

Since March 1, 2014, public school districts across Pennsylvania have been required to incorporate PA Core standards into their curricula to ensure a common academic standard. Student progress is evaluated through standardized tests like Keystone Exams and the Pennsylvania System of School Assessment (PSSAs). Though none of these requirements apply to homeschooling, Pennsylvania is considered to be one of the three states, alongside New York and Washington, with “more robust oversight,” according to the Education Commission of the States, an independent education policy think tank. Take Michigan, where parents are not required to register their homeschooled child; Pennsylvania requires guardians to formally notify the home school district of the decision to homeschool. Pennsylvania also mandates the homeschool instructor to have at least a high school diploma or equivalent, which is not the case nationally. While students in public schools are taking standardized tests each year from grades 3 to 8, homeschooled students are only required to take standardized tests in grades 3, 5 and 8. But homeschool students do go through an annual evaluation. Though most evaluators review portfolios maintained by homeschooled students, changes made to homeschool law in 2014 mean school districts do not track the completion of mandatory coursework by homeschooled students. The portfolios generally can include record of all academic and non-academic activities, from worksheets and test scores to pictures and stubs from field trips. In addition, the evaluator also interviews the child to assess knowledge and understanding of subjects. Prior to 2014, school districts were required to conduct evaluations for homeschoolers residing within their boundaries. In 2014, the rules were relaxed. Today — in addition to state-certified teachers and non-public school teachers and administrators — school superintendents can give special permission to people of varied qualifications to conduct evaluations. The evaluators with special permission can include experienced homeschooling parents. State law prohibits parents from evaluating portfolios of their own children, but according to the Pennsylvania homeschool law (Act 196 of 2014), homeschooling parents can issue high school diplomas to their own children. [caption id="attachment_122250" align="alignnone" width="771"] Tahira Sarwar's 6-year-old daughter, Hadia Kashif, during a day of homeschooling. (Photo by Njaimeh Njie/PublicSource)[/caption] While Sarwar likes the ability to choose the coursework and the evaluator, her children still take grade-appropriate standardized tests to assess their academic progress. Sarwar administers tests like the IOWA and the Stanford Achievement Test, which are provided to families by Bob Jones University. Families mail it back to the university for scoring and evaluation. In third grade, Sarwar’s daughter took PSSAs at the local school district; they plan to take the Stanford test online this year. The freedom homeschooling allows its proponents is not without its critics. Those sounding the alarm include lawyers Sarah Hunt and Carmen Green, co-founders of the Center of Home Education Policy. Hunt and Green say they were homeschooled in ways that made them feel controlled and isolated. Today, they litigate for clients who have experienced some of the worst homeschooling scenarios, from “educational neglect to physical and sexual abuse, to debilitating social alienation,” according to a Washington Post story. While Hunt and Green have been trying to make the case for more monitoring of homeschooling, DeVos has been pushing the school choice agenda through vouchers. School vouchers are issued by the state to parents who choose not to send their children to public school. The amount of the voucher is based on the cost of educating a child in public school. Parents can use school vouchers to send their kids to a school they choose, including private or parochial schools. Vouchers cannot be used for homeschooling. While it was proposed to allow vouchers to apply to homeschooling, it was not included in the tax bill approved by Congress. Despite DeVos’ efforts to make it sound like a “win-win” situation, neither homeschoolers nor advocates for traditional public schools are convinced about the efficacy of vouchers. HSLDA suspects federal dollars will not come without strings attached and will provide government a right to intervene in the system. At the same time, traditional schools and teachers’ unions are concerned that voucher money will be diverted from local educational agencies with high percentages of low-income students. Khan said she would not be in favor of any program that siphons funds from public schools. She homeschools her youngest daughter, while her two older children attend public school. “We need to have good public schools,” she said. “What if I am not able to provide her with the best education? What if she wants more than I can give her? Public schools will always be there to take it up. I will always have the option to send her there.”

Developing “sandbox” social skills

Stuck at home with no one to play with or try new things with? It’s not ideal. That’s why Khan and Sarwar say some homeschooling families don’t mind paying school district taxes. PA Act 67 of the homeschool law grants children enrolled in a home education program the right to participate in activities like clubs and sports teams in their local school district. At least one private school provides opportunities for homeschoolers to mingle and learn with others. Lisa Smith’s five children attend “Homeschool Wednesdays” at the Pittsburgh New Church School [PNCS]. In 2016, PNCS started its homeschooling enrichment program, where families can send their children once a week for a hands-on classes on science, art, literature and music. “We had a number of families in our church congregation who homeschooled for a variety of reasons, and it was a way of including their children in our school,” Lamar Odhner, office manager and marketing assistant at PNCS, wrote in an email. [caption id="attachment_122251" align="alignnone" width="771"] Katie Bruneczk is Carnegie Science Center’s program manager for summer camp classes and sleepovers. She is in charge of programming most out-of-school classes like those for homeschoolers. (Photo by Njaimeh Njie/PublicSource)[/caption] Other Pittsburgh institutions like the Pittsburgh Zoo, the Carnegie museums and libraries and the Carnegie Science Center offer resources for homeschoolers. Katie Bruneczk, the Carnegie Science Center’s program manager for summer camp classes and sleepovers, said the science center provides classes, including computer programming and robotics, for homeschooled children in two age groups, 6 to 8 and 9 to 12. With an ongoing expansion, she said they hope to soon accommodate high school-aged homeschoolers. While designing classes for homeschoolers, Bruneczk especially builds an opportunity for interaction between kids. Though Smith, Khan and Sarwar all talk about the great resources available in Pittsburgh to help nurture the social skills of their homeschoolers, many of my questions about homeschooling remain unanswered. I don’t know if the limited peer time that homeschoolers get is enough for my child to develop meaningful relationships with others later in life. Yes, we can certainly finish up third-grade coursework in second grade and model the curriculum to align with our preferences, but I would like to hear more from those who were homeschooled and have now stepped into the adult world. Homeschooling may be the best academic strategy, but would it qualify as a holistic educational experience? While parents like me in American suburbs continue their quest for the perfect educational choice for their children, I’m still uncertain if keeping kids away from school is fair to children themselves. Saima Sitwat is a freelance writer based in Pittsburgh. She can be reached at saimaadil@hotmail.com. ``` wp-preview: hidden_post_status:publish post_status:publish hidden_post_password: hidden_post_visibility:public visibility:public post_password: mm:01 jj:18 aa:2018 hh:06 mn:30 ss:07 hidden_mm:01 cur_mm:02 hidden_jj:18 cur_jj:05 hidden_aa:2018 cur_aa:2018 hidden_hh:06 cur_hh:15 hidden_mn:30 cur_mn:28 original_publish:Update save:Update post_category[]:0 post_category[]:8 newcategory:New Category Name newcategory_parent:-1 _ajax_nonce-add-category:1876d15fb1 tax_input[post_tag]:education newtag[post_tag]: tax_input[series][]:0 newseries:New Series Name newseries_parent:-1 _ajax_nonce-add-series:78e9522e97 featured_image_display_nonce:1b6b4d3822 _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 featured_image_display_nonce:1b6b4d3822 _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 largo_custom_related_posts: top_term:8 meta_box_nonce:d025babd31 _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 largo_byline_text: largo_byline_link: meta_box_nonce:d025babd31 _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 _wp_post_template: custom_sidebar:none tax_input[prominence][]:0 tax_input[prominence][]:964 coauthors-main:Halle Stockton coauthors[]:halle-stockton coauthorsinput[]:Saima Sitwat coauthors[]:author-saima-sitwat coauthorsinput[]:Search for an author coauthors-nonce:f047c8607b _wp_http_referer:/wp-admin/post.php?post=122238&action=edit&message=1 excerpt:Homeschooling has been on the rise in Pennsylvania since the 2011-12 school year when there were about 20,900 homeschooled students in the state. In 2015-16, the state Department of Education recorded nearly 23,900 homeschoolers, which likely underestimates its prevalence because students homeschooled for religious reasons are exempt from the registration requirement. Still, homeschooled students represent only about 1.38 percent of K-12 students in Pennsylvania. meta[184856][key]:apple_news_is_preview _ajax_nonce:edbb5f6646 meta[184856][value]: meta[184857][key]:apple_news_is_sponsored _ajax_nonce:edbb5f6646 meta[184857][value]: meta[184858][key]:apple_news_pullquote _ajax_nonce:edbb5f6646 meta[184858][value]: meta[184859][key]:apple_news_pullquote_position _ajax_nonce:edbb5f6646 meta[184859][value]:middle meta[184865][key]:custom_sidebar _ajax_nonce:edbb5f6646 meta[184865][value]:none meta[185139][key]:dsq_thread_id _ajax_nonce:edbb5f6646 meta[185139][value]:6420468381 meta[184861][key]:scaip_prevent_shortcode_addition _ajax_nonce:edbb5f6646 meta[184861][value]: meta[184875][key]:top_term _ajax_nonce:edbb5f6646 meta[184875][value]:8 meta[184849][key]:wide_assets _ajax_nonce:edbb5f6646 meta[184849][value]: metakeyselect:#NONE# metakeyinput: metavalue: _ajax_nonce-add-meta:3615a86a6b advanced_view:1 comment_status:open post_name:as-homeschooling-becomes-more-mainstream-is-it-right-for-my-child-heres-what-ive-learned

The following appears in my server's ngnix error log when saving:

2018/02/05 15:29:01 [error] 86055#0: *2852 FastCGI sent in stderr: "PHP message: PHP Notice: Trying to get property of non-object in /Users/blk/sites/publicsource/wp-content/plugins/co-authors-plus/co-authors-plus.php on line 834 PHP message: PHP Notice: Trying to get property of non-object in /Users/blk/sites/publicsource/wp-content/plugins/co-authors-plus/co-authors-plus.php on line 844 PHP message: PHP Notice: Undefined offset: 0 in /Users/blk/sites/publicsource/wp-includes/capabilities.php on line 127" while reading response header from upstream, client: 127.0.0.1, server: publicsource.test, request: "POST /wp-admin/post.php HTTP/2.0", upstream: "fastcgi://unix:/Users/blk/.valet/valet.sock:", host: "www.publicsource.test", referrer: "https://www.publicsource.test/wp-admin/post.php?post=122238&action=edit"

After the post saves, the user Saima Sitwat is not in the co-authors box:

screen shot 2018-02-05 at 3 16 36 pm

The inability to save author-saima-sitwat occurs whether or not we remove the existing halle-stockton byline. Removing the original author, which was mentioned in the first report, is not essential to reproduce.

If the role of the user who created the post matters, we can talk about that via email ben@inn.org. The WordPress user I'm using to perform this edit is an administrator that is not any of the users mentioned in the post meta.

Here's the output of `wp plugin list`: ``` +------------------------------+----------+-----------+---------+ | name | status | update | version | +------------------------------+----------+-----------+---------+ | akismet | inactive | available | 3.3.4 | | better-search-replace | inactive | available | 1.3.1 | | bwp-google-xml-sitemaps | active | none | 1.4.1 | | client-hosting-manager | inactive | none | 1.0.0 | | co-authors-plus | active | none | 3.2.2 | | disqus-comment-system | inactive | none | 2.87 | | documentcloud | active | none | 0.4.3 | | doubleclick-for-wp | inactive | none | 0.2 | | genius | inactive | none | 0.0.6 | | google-authenticator | inactive | none | 0.48 | | gravityforms | active | none | 2.1.2 | | gravityformssubtotal | active | none | 1.0 | | gravityformsmailchimp | active | none | 4.1 | | gravityformsstripe | active | none | 2.2 | | hello | inactive | none | 1.6 | | insert-headers-and-footers | inactive | none | 1.4.2 | | news-match-popup-basics | inactive | available | 0.1.2 | | no-nonsense-google-analytics | inactive | available | 1.1 | | php-compatibility-checker | inactive | available | 1.4.0 | | popup-maker | inactive | none | 1.6.6 | | publish-to-apple-news | inactive | available | 1.2.7 | | redirection | active | available | 2.6.2 | | regenerate-thumbnails | inactive | available | 2.2.6 | | slack | inactive | none | 0.6.0 | | super-cool-ad-inserter | inactive | none | 0.1.1 | | taxonomy-converter | inactive | none | 1.1 | | term-debt-consolidator | inactive | none | 0.1.0 | | tweetable-text | inactive | none | 1.1 | | wordpress-importer | inactive | none | 0.6.3 | +------------------------------+----------+-----------+---------+ ```

Enabling CAP causes non-guest-authors who have authored posts to show different post counts, and there's the issue with the inability to set coauthors.

With CAP enabled, nkhan has 248 posts listed at /wp-admin/users.php. With CAP disabled, nkhan has 385 posts - is this because the posts created by nkhan but filed under a different byline are being excluded from nkhan's post count in the users table? If it is, that's not a problem.

jonathanstegall commented 6 years ago

I've noticed that I get the same error message, but in a different situation. I'm not sure how similar it is, but it seems relevant. To be clear, here's my error log:

Notice: Trying to get property of non-object in /minnpost-wordpress/wp-content/plugins/co-authors-plus/co-authors-plus.php on line 834
Notice: Trying to get property of non-object in /minnpost-wordpress/wp-content/plugins/co-authors-plus/co-authors-plus.php on line 844

My situation is when I'm logged in as a user with a role of "author" or lower. That is, not an "editor" or "administrator". I see this error on /wp-admin/post-new.php, and the box for selecting myself as an author is missing.

lidocaine commented 6 years ago

I'm unable to reproduce the issue in the original comment (from Dec 21; detailed in the comment from Feb 5) using both full-user authors and guest authors under WP v4.9.4 under a VCCW vagrant box as an administrator. I did however notice an issue similar to @jonathanstegall when attempting to view a guest-author's page when logged in as an administrator:

Trying to get property of non-object in /var/www/html/wp-content/plugins/Co-Authors-Plus/co-authors-plus.php on line 728
Trying to get property of non-object in /var/www/html/wp-content/plugins/Co-Authors-Plus/co-authors-plus.php on line 729

I've separated comment regarding incorrect post counts to a separate issue: #494

TheCrowned commented 6 years ago

I've tried reproducing the issue, but did not manage to. From the behavior you are getting, it almost looks like you don't have permissions to set coauthors. I know you have said you used an admin account @benlk, but at this point it may be worth checking that $this->current_user_can_set_authors( $post ) returns true for you!

GaryJones commented 10 months ago

I'm going to close out this old issue, but if it can be recreated with the latest release, then it can be re-opened.