Git won't pick up changes to certain files - php

Have a very odd and annoying issue with Git/GitHub.
In a certain branch, any file that has the path as /views/admin/index.php, /views/teacher/index.php, /views/parents/index.php, /views/student/index.php won't detect any changes to the files no matter what. Deleting the file, removing all the code, or just making a small edit isn't picked up at all.
We are using Codeigniter v2.2.0 as the framework, if that is of any use.
This is happening through any folder with a file structure like that.
Have tried multiple different software including the GitHub native app and Sourcetree.
There is another branch we have that works fine.
Tried cloning the branch with the issue but it still has the problems on the new branch.
Any ideas that could help would be great :)

Whenever you have a file which seems to be ignore, you quickly can check that with git check-ignore:
git check-ignore -v -- /path/to/yourFile
That will help list the exact .gitignore referencing that file.

Massive facepalm moment.
I had index.php in the .gitignore, I needed to have /index.php to ignore only the index.php in the main directory.

If your using SourceTree as you mentioned, change the File Status combo from the Working Copy view to "Show Ignored".
It doesn't display ignored or untracked in "Show All".

Related

Editing hard or softlink's target location content with PHP

I know this is a security threat and is bad from a security aspect alltogether, but for a specific reason, i need this to work. I have a program running on Ubuntu 16.04. Let's say for this example, that it's a DNS server or whatever.
What i'm trying to do, is edit the DNS server configuration file, located in /etc/xxx from a web page, which is using PHP fopen, fwrite and fclose. Because you can't access a file directly located in /etc/xxx/somecfg.cfg anyways, since it doesn't have www-data permissions, i've tried linking it to /var/www/html, both soft and hard linking it. When i create a hard link, it changes the original cfg file too if i edit it by hand, but as soon as i edit it via PHP, only the hard-link file changes, but not the original file.
I've been trying to fix this during the weekend but i can't seem to be able to do it.
Does anyone have an idea on how i would go about fixing this? I'm open to other ideas too. The main goal is to edit a package configuration file from within a web page.
TL;DR: I'm trying to edit a config file in /etc/xxx from /var/www/html/someaction.php and doing it directly doesn't work (obviously), but hard links and soft links are acting weird - the links' content changes, but the original cfg file doesn't.
Thanks!
The issue was that i accidentally put unlink at the beginning of the code and the hard link was deleted, so i basically made a new file each time i wrote to it.
It's fixed now.

Magento 2 failed to open stream: No such file or directory 'vendor/magento/framework/registration.php'

I am not sure what's going on with my magento installation.
I downloaded the latest version of Magento 2.1.1 as zip.
Extracted, setup a database then tried running the install but I keep on getting this stup*d error and I could not find any answers online.
Can someone help me on this one please? Its been a while since I used magento since I got used to working with Wordpress websites.
I tried looking for the file manually, but just like the error said, it does not exist. Where can I find this registration.php file under magento/framework/ folder?
Try run this command in your magento root folder.
composer dumpautoload
Then reload page you've got this error.
Still not working ?. Fell free to reply :)
If you are using composer to Install, the solution is simple re run the commands from the Magento Root Folder.
Inside /vendor/autoload.php there is a Base Path Global Variable that take the path to execute the vendor_path.php, and, in my case, it take the path where I am and not the Root.
I hope this is helpful for someone.
Have a nice coding day
please run
composer dump-autoload
to reload composer autoload files this issue mostly when you update a library and then fall back to original but magento composer files doesn't fall back to original so you need to generate files again.

Git: Cannot remove .php~ files

I use Git on a Symfony 2 project. I would like to switch branches, but I get the following message:
These untracked working tree files would be overwritten by checkout.
Please move or remove them before you can checkout.
Here a list of the files:
srv/myproject/src/mycompany/mybundle/Entity/Contacts.php~
srv/myproject/src/mycompany/mybundle/Entity/Products.php~
srv/myproject/src/mycompany/mybundle/Entity/Orders.php~
What I tried so far:
For example, I tried to do
git rm --cached srv/myproject/src/mycompany/mybundle/Entity/Contacts.php~
which gives me the message that the file does not exist.
I cannot find any "php~" files in the "Entity"-Folder. I can only see the regular "php" files.
Why do these files have the char "~" at the end of the file name?
How do I solve this problem?
Files with names ending with ~ are typically backup files made by some editors. Whether they are made by your editor, I have no idea.
They are shown as untracked (Git says these untracked working tree files...), which means they are not in the index, so you cannot give them to git rm --cached which just removes things from the index. This in turn means that—at least at this point—you have done nothing wrong. :-) Which might be reassuring, but is not really helpful.
Nonetheless, git checkout <otherbranch> is complaining that the proposed checkout would overwrite them. This means that they are contained in the commit that this git checkout would check out. That, in turn, means that someone, at some point, did something wrong, by committing them in the first place. (Assuming, at least, that they are just editor backup files that should not be versioned like this.) That could be someone other than you, meaning you have done nothing wrong, but, well, still not helpful.
This also means that they are in your work-tree right now. How they got there is hard to say, though the most obvious candidate reason is that your editor made them as editor backup files.
What you need to do
What you need to do is to move or remove these files (assuming they're editor backups, it is likely safe to just remove them entirely) so that they are no longer in your work-tree. Then git checkout will be able to put the ones from the commit into your work-tree, without clobbering the ones you already have, since you no longer have them.
What else you and/or others need to do
Committing these files is a bad idea (assuming, as always, that these are editor backups). It's kind of hard to fix this in existing commits. It's up to you and your co-workers / colleages whether to bother. However, one way or another, future commits should not contain these files.
To that end, you, or someone, must not only remove them now, you must also check out the commit(s) that have them, then remove them (e.g., git rm *~), then either fix those commits or make new commits that tell Git "they were there, and they will be in commit history, but from that commit to this new one, remove them now."
Moreover, you, or someone, should probably set things up so that Git ignores these files by default, so that it will not put them into future commits. The usual method is to add a line *~ to the top level .gitignore file. (However, once files are tracked, adding them to .gitignore has no effect until they become un-tracked by an explicit remove. This is because .gitignore is the wrong name: it's not a list of files to ignore, it's a list of files to not add, and to not complain about forgetting to add.)
remove unwanted files from git:
git reset HEAD path/to/unwanted_file
create .gitignore file and add *~ to it.
do a new commit.

404 Not Found error after commit changes on PHP application Openshift

I'm having problems with my PHP applications, I have created and deleted several of them because everytime I commit changes my application crushes and it shows the "404 Not Found" error.
I'm sure there are no coding errors for two reasons:
1. The same code was working days ago, it was after wednesday that I'm getting this message.
2. The same code works on my development environment.
This happens after I commit any change, even for the first time, and after that there is no turning back, so I have to delete it and create it again.
Can anyone help me?
Thanks anyone for the help.
This is just a shot in the dark, but do you put your php files into a subdirectory called php? If so, openshift automatically sets that directory to be your document root. It would certainly result in a 404 if you navigated to the /index.html when index.html is actually one folder up.
You can read about the way that openshift automatically sets the document root here: https://blog.openshift.com/openshift-online-march-2014-release-blog/
I had this problem today because I was not commiting all of the files.
You should use:
git add -A
This will add all of the files in the directory to your next commit, without this command, only the files that already existed and were changed (apparently) would be commited.
After that, use:
git commit -a -m 'commit message'
Now your files should be uploaded to the server.
Also, use git status to see the files staged for commit and the ones that are not.

Why does Eclipse code completion not work on some projects?

I have Eclipse 3.3.2 with PDT doing PHP development.
All projects that I create, even SVN projects have code completion.
Now I just opened another SVN project and it has no code completion or PHP templates (CTRL-space does nothing in that project).
However, I can open the other projects and code completion all work in them.
Why would code completion and templates be "off" in just one project and how can I turn it back on?
Maybe Eclipse doesn't understand the project has a "PHP nature".
Try comparing the .project file on both projects to look for differences. It should contain something like:
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
</natures>
The .project file will be in your workspace under the project directories.
Look out for the file .buildpath in your project... put this line between the tag:
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
Save it and restart eclipse. Now everything should be OK... This worked for me. :)
Thank you!
I spent all day long to figure out why I did not have code completion...
The problem is that if you create a SVN project the .project is a basic file without codecompletion reference. You have to create a basic PHP project and compare the two files and replacing the missing part in the SVN project one.
Now I have code completion for every file in the project, even for Zend Framework library
It is just one line to add in the .project file and then restarting eclipse to get codecompletion:
Where it says
---
<natures>
</natures>
---
after the change has to be
---
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
</natures>
---
That should do.
#Guido PHPNature does not fix this.
#Edward Tanguay Yes, that's because when you create new PHP project, eclipse adds .buildpath file with
<?xml version="1.0" encoding="UTF-8"?><buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/></buildpath>
when you import existing project you eclipse does not generates .buildpath file, but you can add it by hand or create new PHP project with existin source (you can choose in wizard).
I have the same issue sometimes. For me it works to rebuild the PHP project with "Project" -> "Clean".
If you have this problem, follow these steps :
Select "PHP Include Path" in your project tree
Right click on it then click "Build Path>Configure Build Path"
On the opening window,add folder that you want to build, so it can do code assist.
Thats all :) I hope it resolves your problem, I solved my one :)
Be sure the file opens with the "PHP editor". Right-click the file, and select open with to select the right editor.
If it turns out you've been using the wrong editor, you can change the association under Preferences » General » Content Types
Right click in the edit screen, goto Java -> Editor -> Content Assist -> Advanced ...select proposals accordingly
ATTENTION
Besides the already mentioned solutions to get the whole autocomplete help to work, there is another quirk: it might not be enabled.
Go to Window > Properties and then to PHP > Editor > Code Assist (JAVA has a similar option) and set "Enable auto activation", preferably with a delay that you see comfortable (0ms). If you are bothered by the program suddenly deciding to do things for you without prompt (and doing it wrong), deselect "Insert single proposals automatically" and you should be fine.
I've noticed sometimes when you checkout a project from svn in eclipse (subversive or subsclipe "checkout a project as") and even though you check it out as a php project it will either delete the .project file or it would be a generic project. I've found to just go in that directory and delete the .project .settings/ and .cach/
Then create a new php project and point the directory where you checked out the files. And you should have code completion and svn should be link to your repo.
I had a problem that build path was empty, so no code completion for any of the files i tried to edit. Make sure you setup properly your build path, especially if you're linking the source from some other location than the workspace.
Like the apache htdocs folder for example.
I have solved this by enabling the Full C/C++ indexer (Windows-> properties -> C/C++ -> Indexer), and also hit the radio button "Use active button configuration". After that Clean, and Build all.
That worked on Eclipse CDT 3.4
If you came here looking for code completion in php eclipse not working, make sure your project is being supported as a php project. Right click on the project and then go to configure -> Add php support. If you have the right settings for code assist it should work instantaneously. Sometimes newbies as me tweak around with the projects or start projects as clean and not as php so eclipse doesn't know how to treat the project.
I had to right click the project in the PHP Explorer, go to "PHP Build Path". This was empty. I clicked "Add Folder", selected the checkbox next to the root folder of my project and clicked "OK", then "OK" again.
After that code completion seemed to work. Should just work out of the box if you ask me, but whatever.
Check the lib of your project. It may be that you have include two such jar files in which same class is available or say one class in code can be refrenced in two jar files. In such case also eclipse stops assisting code as it is totally confused.
Better way to check this is go to the file where assist is not working and comment all imports there, than add imports one by one and check at each import if code-assist is working or not.You can easily find the class with duplicate refrences.
One solution could be to include a dummy php file wich requires all your PHP classes. So that the PHP parser recognizes these classes too.
Example dummy file:
if(false) {
require_once 'class/one.php';
require_once 'class/two.php';
require_once 'class/three.php';
}

Categories